diff options
3 files changed, 15 insertions, 16 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java index b5486f57be..aac1202506 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java @@ -45,7 +45,7 @@ public final class ExportDataCommand { public static final String JOIN_DELIMITER_SPLITTER = "\\$\\#"; public static final String MAP_DELIMITER = "!@"; public static final String MAP_DELIMITER_SPLITTER = "\\!\\@"; - public static final int THREAD_POOL_SIZE = 4; + public static final int THREAD_POOL_SIZE = 6; private ExportDataCommand() { } @@ -56,7 +56,7 @@ public final class ExportDataCommand { CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem(); Path rootDir = Paths.get(ImportProperties.ROOT_DIRECTORY); initDir(rootDir); - try(Session session = CassandraSessionFactory.getSession()) { + try (Session session = CassandraSessionFactory.getSession()) { final Set<String> filteredItems = Sets.newHashSet(filterItem); Set<String> fis = filteredItems.stream().map(fi -> fi.replaceAll("\\r", "")).collect(Collectors.toSet()); Map<String, List<String>> queries; @@ -95,23 +95,28 @@ public final class ExportDataCommand { } - private static boolean executeQuery(final Session session, final String query, final Set<String> filteredItems, final String filteredColumn, + private static void executeQuery(final Session session, final String query, final Set<String> filteredItems, final String filteredColumn, final Set<String> vlms, final CountDownLatch donequerying, Executor executor) { ResultSetFuture resultSetFuture = session.executeAsync(query); Futures.addCallback(resultSetFuture, new FutureCallback<ResultSet>() { @Override public void onSuccess(ResultSet resultSet) { - new ExportSerializer().serializeResult(resultSet, filteredItems, filteredColumn, vlms); - donequerying.countDown(); + try { + Utils.printMessage(logger, "Start to serialize " + query); + new ExportSerializer().serializeResult(resultSet, filteredItems, filteredColumn, vlms); + donequerying.countDown(); + } catch (Exception e){ + Utils.logError(logger, "Serialization failed :" + query, e); + System.exit(-1); + } } @Override public void onFailure(Throwable t) { Utils.logError(logger, "Query failed :" + query, t); - donequerying.countDown(); + System.exit(-1); } }, executor); - return true; } private static void zipPath(Path rootDir) throws IOException { diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java index 3c917b1c7e..0098f21eb2 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java @@ -52,8 +52,7 @@ public class ExportSerializer { ColumnDefinition columnDefinition = tableData.definitions.get(i); Name name = dataTypesMap.get(columnDefinition.getType()); boolean checkForVLM = isElementTable && columnDefinition.getName().equals(ELEMENT_INFO_COLUMN_NAME); - Object data; - data = convertByType(vlms, row, i, name, checkForVLM); + Object data = convertByType(vlms, row, i, name, checkForVLM); rowData.add(data.toString()); } tableData.rows.add(rowData); @@ -128,7 +127,6 @@ public class ExportSerializer { } protected String extractVlm(String injson) { - try { if (injson == null){ return null; } @@ -145,8 +143,5 @@ public class ExportSerializer { return null; } return vendorId.getAsString(); - } catch (Exception ex){ - return null; - } } } diff --git a/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java b/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java index 7b43c4624f..a5a1ff2cbc 100644 --- a/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java +++ b/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java @@ -33,11 +33,10 @@ public class VLMExtractTest { } - @Test + @Test(expectedExceptions = IllegalStateException.class) public void failToExtractVLMBecauseJsonIsCorrupted(){ String elemenet_info_string = "gfhhhghgh"; - String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string); - assertNull(extractedVlmId); + new CustomExportSerializer().extractVlm(elemenet_info_string); } private static final class CustomExportSerializer extends ExportSerializer{ |