summaryrefslogtreecommitdiffstats
path: root/aai-resources
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources')
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java1
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java73
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java47
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java39
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java8
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java12
6 files changed, 91 insertions, 89 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java b/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
index d7271c9..982a1bb 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
@@ -155,6 +155,7 @@ public class DataSnapshot {
Thread.sleep(5000);
} catch (java.lang.InterruptedException ie) {
System.out.println(" DB Clearing has been aborted. ");
+ Thread.currentThread().interrupt();
AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java b/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java
index 3b9c56e..1e323b0 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java
@@ -307,9 +307,8 @@ public class DupeTool {
LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(emsg);
exit(0);
- } else {
- obj = loader.introspectorFromName(nodeTypeVal);
}
+ obj = loader.introspectorFromName(nodeTypeVal);
if (skipHostCheck) {
logger.info(" We will skip the HostCheck as requested. ");
@@ -413,6 +412,7 @@ public class DupeTool {
Thread.sleep(sleepMsec);
} catch (InterruptedException ie) {
msg = "\n >>> Sleep Thread has been Interrupted <<< ";
+ Thread.currentThread().interrupt();
logger.info( msg );
System.out.println( msg );
exit(0);
@@ -760,7 +760,9 @@ public class DupeTool {
Graph gt = null;
try {
- if( graph == null ){
+ if( graph != null ){
+ gt = graph.newTransaction();
+ } else {
String emsg = "could not get graph object in DupeTool. \n";
System.out.println(emsg);
LoggingContext.statusCode(StatusCode.ERROR);
@@ -768,23 +770,9 @@ public class DupeTool {
logger.error(emsg);
exit(0);
}
- gt = graph.newTransaction();
- if (gt == null) {
- String emsg = "null graphTransaction object in DupeTool. \n";
- throw new AAIException("AAI_6101", emsg);
- }
-
}
- catch (AAIException e1) {
- String msg = e1.getErrorObject().toString();
- System.out.println(msg);
- LoggingContext.statusCode(StatusCode.ERROR);
- LoggingContext.responseCode(LoggingContext.DATA_ERROR);
- logger.error(msg);
- exit(0);
- }
- catch (Exception e2) {
- String msg = e2.toString();
+ catch (Exception e) {
+ String msg = e.toString();
System.out.println(msg);
LoggingContext.statusCode(StatusCode.ERROR);
LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR);
@@ -1033,39 +1021,38 @@ public class DupeTool {
}
}
}
-
- if(tgQ == null){
- msg = "Bad JanusGraphQuery object. ";
- System.out.println(msg);
- LoggingContext.statusCode(StatusCode.ERROR);
- LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
- logger.error(msg);
- exit(0);
- }
+ if(tgQ != null) {
Iterator<Vertex> vertItor = tgQ;
- while( vertItor.hasNext() ){
+ while (vertItor.hasNext()) {
Vertex tiV = vertItor.next();
- if( windowStartTime <= 0 ){
+ if (windowStartTime <= 0) {
// We're not applying a time-window
retVertList.add(tiV);
continue;
}
- Object objTimeStamp = tiV.property("aai-created-ts").orElse(null);
- if( objTimeStamp == null ){
- // No timestamp - so just take it
- retVertList.add(tiV);
- continue;
- }
-
- long thisNodeCreateTime = (long)objTimeStamp;
- if( thisNodeCreateTime > windowStartTime ){
- // It is in our window, so we can take it
- retVertList.add(tiV);
- }
- }
+ Object objTimeStamp = tiV.property("aai-created-ts").orElse(null);
+ if (objTimeStamp == null) {
+ // No timestamp - so just take it
+ retVertList.add(tiV);
+ continue;
+ }
+ long thisNodeCreateTime = (long) objTimeStamp;
+ if (thisNodeCreateTime > windowStartTime) {
+ // It is in our window, so we can take it
+ retVertList.add(tiV);
+ }
+ }
+ } else {
+ msg = "Bad JanusGraphQuery object. ";
+ System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
+ logger.error(msg);
+ exit(0);
+ }
if( retVertList.isEmpty() ){
logger.debug("DEBUG No node found for: [" + qStringForMsg + ", with aai-created-ts > " + windowStartTime );
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java b/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
index 96c5467..42d401b 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
@@ -276,7 +276,7 @@ public class ForceDeleteTool {
// name value pairs like this:
// "propName1|propVal1,propName2|propVal2" etc. We will look for a node or nodes
// that have properties that ALL match what was passed in.
-
+
int resCount = 0;
int firstPipeLoc = dataString.indexOf("|");
if( firstPipeLoc <= 0 ){
@@ -287,27 +287,30 @@ public class ForceDeleteTool {
logger.error(msg);
exit(0);
}
- GraphTraversal<Vertex, Vertex> g = graph.traversal().V();
- String qStringForMsg = " graph.traversal().V()";
- // Note - if they're only passing on parameter, there won't be any commas
- String [] paramArr = dataString.split(",");
- for( int i = 0; i < paramArr.length; i++ ){
- int pipeLoc = paramArr[i].indexOf("|");
- if( pipeLoc <= 0 ){
- msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
- System.out.println(msg);
- LoggingContext.statusCode(StatusCode.ERROR);
- LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
- logger.error(msg);
- exit(0);
- }
- else {
- String propName = paramArr[i].substring(0,pipeLoc);
- String propVal = paramArr[i].substring(pipeLoc + 1);
- g = g.has(propName,propVal);
- qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")";
- }
- }
+ GraphTraversal<Vertex, Vertex> g = null;
+ String qStringForMsg = null;
+ if (graph != null) {
+ g = graph.traversal().V();
+ qStringForMsg = " graph.traversal().V()";
+ // Note - if they're only passing on parameter, there won't be any commas
+ String[] paramArr = dataString.split(",");
+ for (int i = 0; i < paramArr.length; i++) {
+ int pipeLoc = paramArr[i].indexOf("|");
+ if (pipeLoc <= 0) {
+ msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
+ System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
+ logger.error(msg);
+ exit(0);
+ } else {
+ String propName = paramArr[i].substring(0, pipeLoc);
+ String propVal = paramArr[i].substring(pipeLoc + 1);
+ g = g.has(propName, propVal);
+ qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")";
+ }
+ }
+ }
if( (g != null)){
Iterator<Vertex> vertItor = g;
while( vertItor.hasNext() ){
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java
index 146b729..81adb68 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java
@@ -144,28 +144,29 @@ public class SchemaMod {
Thread.sleep(5000);
} catch (java.lang.InterruptedException ie) {
logAndPrint(logger, " DB Schema Update has been aborted. ");
+ Thread.currentThread().interrupt();
System.exit(1);
}
- logAndPrint(logger, " ---- NOTE --- about to open graph (takes a little while)\n");
-
- Version version = Version.getLatest();
- QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- ModelType introspectorFactoryType = ModelType.MOXY;
- Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- TransactionalGraphEngine engine = null;
- try {
- engine = new JanusGraphDBEngine(queryStyle, DBConnectionType.REALTIME, loader);
- SchemaModInternal internal = new SchemaModInternal(engine, logger, propName, targetDataType, targetIndexInfo, new Boolean(preserveDataFlag));
- internal.execute();
- engine.startTransaction();
- engine.tx().close();
- } catch (Exception e) {
- String emsg = "Not able to get a graph object in SchemaMod.java\n";
- logAndPrint(logger, e.getMessage());
- logAndPrint(logger, emsg);
- System.exit(1);
- }
+ logAndPrint(logger, " ---- NOTE --- about to open graph (takes a little while)\n");
+
+ Version version = Version.getLatest();
+ QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ ModelType introspectorFactoryType = ModelType.MOXY;
+ Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ TransactionalGraphEngine engine = null;
+ try {
+ engine = new JanusGraphDBEngine(queryStyle, DBConnectionType.REALTIME, loader);
+ SchemaModInternal internal = new SchemaModInternal(engine, logger, propName, targetDataType, targetIndexInfo, new Boolean(preserveDataFlag));
+ internal.execute();
+ engine.startTransaction();
+ engine.tx().close();
+ } catch (Exception e) {
+ String emsg = "Not able to get a graph object in SchemaMod.java\n";
+ logAndPrint(logger, e.getMessage());
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ }
}
/**
* Log and print.
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java
index d1ee6c4..6e10853 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java
@@ -158,6 +158,14 @@ public class UpdateEdgeTagsCmd implements Command {
}
return;
}
+ finally {
+ try {
+ g.close();
+ }
+ catch (Exception e) {
+ logger.error("Error occured while closing Transaction with graph" + e.getMessage());
+ }
+ }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
index a1b0d5c..113d441 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
@@ -79,11 +79,13 @@ public class MigrateDataFromASDCToConfiguration extends Migrator {
success= false;
logger.error("Found Exception" , a);
} finally {
- try {
- br.close();
- } catch (IOException e) {
- success = false;
- logger.error("Found Exception" , e);
+ if (br != null){
+ try {
+ br.close();
+ } catch (IOException e) {
+ success = false;
+ logger.error("Found Exception" , e);
+ }
}
}