From 4a65c6f42c9eb705d7e3155788278674ff2b0a67 Mon Sep 17 00:00:00 2001 From: Harish Venkata Kajur Date: Fri, 4 Jan 2019 13:34:33 -0500 Subject: Update the GenTester to exit properly Issue-ID: AAI-1958 Change-Id: Ifbffd1c15e474dce0cc7b3102f7b6961a72a864e Signed-off-by: Harish Venkata Kajur --- src/main/java/org/onap/aai/schema/GenTester.java | 36 ++++++++++++------------ src/main/scripts/common_functions.sh | 5 +++- 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/aai/schema/GenTester.java b/src/main/java/org/onap/aai/schema/GenTester.java index e79256f..663aaec 100644 --- a/src/main/java/org/onap/aai/schema/GenTester.java +++ b/src/main/java/org/onap/aai/schema/GenTester.java @@ -135,27 +135,27 @@ public class GenTester { // Load the propertyKeys, indexes and edge-Labels into the DB JanusGraphManagement graphMgt = graph.openManagement(); - imsg = "-- Loading new schema elements into JanusGraph --"; - System.out.println(imsg); - LOGGER.info(imsg); - SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, null); + imsg = "-- Loading new schema elements into JanusGraph --"; + System.out.println(imsg); + LOGGER.info(imsg); + SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, null); + if( graph != null ){ + imsg = "-- graph commit"; + System.out.println(imsg); + LOGGER.info(imsg); + graph.tx().commit(); + + imsg = "-- graph shutdown "; + System.out.println(imsg); + LOGGER.info(imsg); + graph.close(); + throw new RuntimeException(); + } } catch(Exception ex) { - ErrorLogHelper.logError("AAI_4000", ex.getMessage()); + ErrorLogHelper.logError("AAI_4000", ex.getMessage()); + System.exit(1); } - - - if( graph != null ){ - String imsg = "-- graph commit"; - System.out.println(imsg); - LOGGER.info(imsg); - graph.tx().commit(); - imsg = "-- graph shutdown "; - System.out.println(imsg); - LOGGER.info(imsg); - graph.close(); - } - LOGGER.auditEvent("-- all done, if program does not exit, please kill."); System.exit(0); } diff --git a/src/main/scripts/common_functions.sh b/src/main/scripts/common_functions.sh index ed795fe..55fb516 100644 --- a/src/main/scripts/common_functions.sh +++ b/src/main/scripts/common_functions.sh @@ -49,7 +49,10 @@ execute_spring_jar(){ JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}"; - ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@" + ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@" || { + echo "Failed to run the tool $0 successfully"; + exit 1; + } } # Prints the start date and the script that the user called -- cgit 1.2.3-korg