From 07957fb76bd3e450a17cc5a66c3db521e4344a36 Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Mon, 22 Jan 2018 14:33:20 +0200 Subject: Fix zusammen export tool No need for multithreading Issue-ID: SDC-941 Change-Id: If68b7ab79b2857a3ee6ab88dd80997ceb58a1aab Signed-off-by: shrek2000 --- .../core/tools/importinfo/ImportSingleTable.java | 38 +++++++--------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'openecomp-be/tools/zusammen-tools/src/main/java/org') diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java index 6351d7fa55..71a260798a 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java @@ -3,24 +3,10 @@ package org.openecomp.core.tools.importinfo; import com.datastax.driver.core.BoundStatement; import com.datastax.driver.core.DataType.Name; import com.datastax.driver.core.PreparedStatement; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.ResultSetFuture; import com.datastax.driver.core.Session; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Sets; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import org.apache.commons.lang3.StringUtils; -import org.codehaus.jackson.map.ObjectMapper; -import org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory; -import org.openecomp.core.tools.exportinfo.ExportDataCommand; -import org.openecomp.core.tools.model.ColumnDefinition; -import org.openecomp.core.tools.model.TableData; -import org.openecomp.core.tools.util.Utils; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; - import java.io.IOException; import java.nio.ByteBuffer; import java.nio.file.Path; @@ -31,6 +17,15 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; +import org.codehaus.jackson.map.ObjectMapper; +import org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory; +import org.openecomp.core.tools.exportinfo.ExportDataCommand; +import org.openecomp.core.tools.model.ColumnDefinition; +import org.openecomp.core.tools.model.TableData; +import org.openecomp.core.tools.util.Utils; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; public class ImportSingleTable { @@ -46,7 +41,7 @@ public class ImportSingleTable { TableData tableData = objectMapper.readValue(file.toFile(), TableData.class); Session session = CassandraSessionFactory.getSession(); PreparedStatement ps = getPrepareStatement(tableData, session); - tableData.rows.parallelStream().forEach(row -> executeQuery(session, ps, tableData.definitions, row)); + tableData.rows.forEach(row -> executeQuery(session, ps, tableData.definitions, row)); } catch (IOException e) { Utils.logError(logger, e); } @@ -71,18 +66,7 @@ public class ImportSingleTable { Name name = dataTypesMap.get(columnDefinition.getType()); handleByType(bind, i, rowData, name); } - ResultSetFuture resultSetFuture = session.executeAsync(bind); - Futures.addCallback(resultSetFuture, new FutureCallback() { - @Override - public void onSuccess(ResultSet resultSet) { - Utils.printMessage(logger, "successful write "); - } - - @Override - public void onFailure(Throwable t) { - Utils.logError(logger, t); - } - }); + session.execute(bind); } private void handleByType(BoundStatement bind, int i, String rowData, Name name) { -- cgit 1.2.3-korg