From 2e971ba4b99e987a18237675e50adc4a5f21d0d6 Mon Sep 17 00:00:00 2001 From: "Kajur, Harish (vk250x)" Date: Wed, 10 Apr 2019 15:43:25 -0400 Subject: Make changes to integrate latest changes Add perm flags with metaspace flags as permgen has been replaced by metaspace in java 8 Update junits to remove the certificate Fix password configruation and schema changes to work with the increase nodes tool Correct service.name for making sure the correct DB connection name is set Add aaiconfig properties for the deleted objects to log Issue-ID: AAI-2327 Change-Id: I5a8a70f6d6630960b0e8ec4780fce3e1baf79cc1 Signed-off-by: Kajur, Harish (vk250x) --- aai-resources/src/main/docker/Dockerfile | 2 +- aai-resources/src/main/docker/docker-entrypoint.sh | 7 +- .../main/java/org/onap/aai/IncreaseNodesTool.java | 97 ++++++++++++----- .../src/main/java/org/onap/aai/ResourcesApp.java | 3 +- .../resources/etc/appprops/aaiconfig.properties | 10 +- aai-resources/src/main/resources/logback.xml | 119 ++++----------------- 6 files changed, 109 insertions(+), 129 deletions(-) (limited to 'aai-resources/src/main') diff --git a/aai-resources/src/main/docker/Dockerfile b/aai-resources/src/main/docker/Dockerfile index ec38c02..e6d9d6f 100644 --- a/aai-resources/src/main/docker/Dockerfile +++ b/aai-resources/src/main/docker/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /opt/app/aai-resources EXPOSE 8447 -HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD nc -z -v localhost 8447 || exit 1 +HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD nc -z -v localhost ${SERVER_PORT:-8447} || exit 1 ENTRYPOINT ["/bin/bash", "/opt/app/aai-resources/docker-entrypoint.sh"] diff --git a/aai-resources/src/main/docker/docker-entrypoint.sh b/aai-resources/src/main/docker/docker-entrypoint.sh index d2fe989..418fb26 100644 --- a/aai-resources/src/main/docker/docker-entrypoint.sh +++ b/aai-resources/src/main/docker/docker-entrypoint.sh @@ -90,8 +90,7 @@ fi; MIN_HEAP_SIZE=${MIN_HEAP_SIZE:-512m}; MAX_HEAP_SIZE=${MAX_HEAP_SIZE:-1024m}; -MAX_PERM_SIZE=${MAX_PERM_SIZE:-512m}; -PERM_SIZE=${PERM_SIZE:-512m}; +MAX_METASPACE_SIZE=${MAX_METASPACE_SIZE:-512m}; JAVA_CMD="exec gosu aaiadmin java"; @@ -102,8 +101,7 @@ JVM_OPTS="${JVM_OPTS} -Xmx${MAX_HEAP_SIZE}"; JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails"; JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps"; -JVM_OPTS="${JVM_OPTS} -XX:MaxPermSize=${MAX_PERM_SIZE}"; -JVM_OPTS="${JVM_OPTS} -XX:PermSize=${PERM_SIZE}"; +JVM_OPTS="${JVM_OPTS} -XX:MaxMetaspaceSize=${MAX_METASPACE_SIZE}"; JVM_OPTS="${JVM_OPTS} -server"; JVM_OPTS="${JVM_OPTS} -XX:NewSize=512m"; @@ -138,6 +136,7 @@ JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_VERSION=${AAI_BUILD_VERSION}"; JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom"; JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=./resources/logback.xml"; JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources"; +JAVA_OPTS="${JAVA_OPTS} -Dgroovy.use.classvalue=true"; JAVA_OPTS="${JAVA_OPTS} ${POST_JAVA_OPTS}"; JAVA_MAIN_JAR=$(ls lib/aai-resources*.jar); diff --git a/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java index a4c6ef5..23814bf 100644 --- a/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java +++ b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java @@ -23,16 +23,26 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import java.util.UUID; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.context.ApplicationContext; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphTransaction; +import org.onap.aai.config.PropertyPasswordConfiguration; +import org.onap.aai.config.SpringContextAware; import org.onap.aai.dbmap.AAIGraph; +import org.onap.aai.edges.EdgeIngestor; +import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.Loader; import org.onap.aai.introspection.LoaderFactory; import org.onap.aai.introspection.ModelType; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; +import org.onap.aai.logging.ErrorLogHelper; +import org.onap.aai.logging.LoggingContext; import org.onap.aai.setup.SchemaVersions; import org.onap.aai.util.AAISystemExitUtil; import org.onap.aai.util.PositiveNumValidator; @@ -41,35 +51,56 @@ import org.onap.aai.serialization.db.EdgeSerializer; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.beans.factory.annotation.Autowired; public class IncreaseNodesTool { public static long nodeCount = 0; - protected EdgeSerializer edgeSerializer; + + @Autowired + protected static EdgeSerializer edgeSerializer; + private LoaderFactory loaderFactory; private SchemaVersions schemaVersions; protected TransactionalGraphEngine engine; Vertex parentVtx; - + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(IncreaseNodesTool.class); public IncreaseNodesTool(LoaderFactory loaderFactory, SchemaVersions schemaVersions){ this.loaderFactory = loaderFactory; this.schemaVersions = schemaVersions; } - public static void main(String[] args) throws AAIUnknownObjectException, UnsupportedEncodingException { - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - "org.onap.aai.config", - "org.onap.aai.setup" - ); + public static void main(String[] args) throws AAIUnknownObjectException, UnsupportedEncodingException, AAIException { + + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration(); + initializer.initialize(context); + try { + context.scan( + "org.onap.aai.config", + "org.onap.aai.setup" + ); + context.refresh(); + } catch (Exception e) { + AAIException aai = ResourcesApp.schemaServiceExceptionTranslator(e); + LOGGER.error("Problems running the tool "+aai.getMessage()); + LoggingContext.statusCode(LoggingContext.StatusCode.ERROR); + LoggingContext.responseCode(LoggingContext.DATA_ERROR); + ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry"); + throw aai; + } LoaderFactory loaderFactory = context.getBean(LoaderFactory.class); - SchemaVersions schemaVersions = context.getBean(SchemaVersions.class); + SchemaVersions schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions"); IncreaseNodesTool increaseNodesTool = new IncreaseNodesTool(loaderFactory, schemaVersions); JanusGraph janusGraph = AAIGraph.getInstance().getGraph(); + + ApplicationContext ctx = (ApplicationContext) SpringContextAware.getApplicationContext(); + edgeSerializer = ctx.getBean(EdgeSerializer.class); + increaseNodesTool.run(janusGraph,args); AAISystemExitUtil.systemExitCloseAAIGraph(0); @@ -111,22 +142,7 @@ public class IncreaseNodesTool { for (long i = 1; i <= nodeCount; i++) { String randomId = UUID.randomUUID().toString(); Vertex v = g.addV().next(); - - if(cArgs.child.equals(true)){ - - if(parentVtx == null){ - String[] uriTokens = cArgs.uri.split("//"); - String ParentNodeType = uriTokens[uriTokens.length-4]; //parent node type - String keyVal = uriTokens[uriTokens.length-3]; // parent unique key - parentVtx = g.V().has(ParentNodeType,keyVal).next(); - edgeSerializer.addTreeEdgeIfPossible(g,parentVtx,v); - - } - else{ - edgeSerializer.addTreeEdgeIfPossible(g,parentVtx,v); - } - } - + v.property("aai-node-type", nodeType); v.property("source-of-truth", "IncreaseNodesTool"); v.property("aai-uri", cArgs.uri+"random-"+randomId); @@ -135,10 +151,41 @@ public class IncreaseNodesTool { for(String propName : propList){ if(propName.equals("in-maint")){ v.property(propName,"false"); + continue; } v.property(propName, "random-" + randomId); System.out.println("node " + i + " added " + propList.get(0)+": " + "random-"+randomId); } + + if(cArgs.child.equals("true")){ + + if(parentVtx == null){ + String[] uriTokens = cArgs.uri.split("/"); + String ParentNodeType = uriTokens[uriTokens.length-4]; //parent node type + String keyVal = uriTokens[uriTokens.length-3]; // parent unique key + Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()); + if (loader != null) + { + Introspector objParent = loader.introspectorFromName(ParentNodeType); + if (objParent != null) + { + List parentPropList = new ArrayList(); + parentPropList.addAll(objParent.getRequiredProperties()); + if (parentPropList.size() > 0) + { + System.out.println("parent node (" + ParentNodeType + ") key (" + parentPropList.get(0)+" ) =" + keyVal); + parentVtx = g.V().has(parentPropList.get(0),keyVal).next(); + edgeSerializer.addTreeEdgeIfPossible(g,parentVtx,v); + } + } + } + + } + else{ + edgeSerializer.addTreeEdgeIfPossible(g,parentVtx,v); + } + } + } } catch (Exception ex) { success = false; diff --git a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java index 36fcd41..f653487 100644 --- a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java +++ b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java @@ -188,6 +188,7 @@ public class ResourcesApp { } String currentDirectory = System.getProperty("user.dir"); + System.setProperty("aai.service.name", ResourcesApp.class.getSimpleName()); if (System.getProperty("AJSC_HOME") == null) { System.setProperty("AJSC_HOME", "."); @@ -203,7 +204,7 @@ public class ResourcesApp { } } } - private static AAIException schemaServiceExceptionTranslator(Exception ex) { + public static AAIException schemaServiceExceptionTranslator(Exception ex) { AAIException aai = null; if(ExceptionUtils.getRootCause(ex).getMessage().contains("NodeIngestor")){ aai = new AAIException("AAI_3026","Error reading OXM from SchemaService - Investigate"); diff --git a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties b/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties index 6f68c41..d1aace6 100644 --- a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties +++ b/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties @@ -114,4 +114,12 @@ aai.resourceversion.disabled.uuid=ajifsjisajfiasjf-oijfadao-43jj-a508-8539cd36ec aai.use.realtime=true # Threshold for margin of error (in ms) for resources_with_sot format to derive the most recent http method performed -aai.resource.formatter.threshold=10 \ No newline at end of file +aai.resource.formatter.threshold=10 + +# Indicating whether or not to log the implicit delete objects +# Set this property to true if you want to log implicit delete objects +aai.implied.delete.log.enabled=true +# Specifies how much upper bound the deletable objects should you log +# If this property is not specified it will log everything +# Uncomment it and specify an upper limit if you only want to log up to a certain deletes +#aai.implied.delete.log.limit=10000 diff --git a/aai-resources/src/main/resources/logback.xml b/aai-resources/src/main/resources/logback.xml index c903175..cb2f7e9 100644 --- a/aai-resources/src/main/resources/logback.xml +++ b/aai-resources/src/main/resources/logback.xml @@ -34,7 +34,6 @@ - @@ -250,106 +249,36 @@ ${eelfLogPattern} - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.log - - - ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip - - 1 - 9 - - - 5MB - - - "%d [%thread] %-5level %logger{1024} - %msg%n" - - - - - ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.log - - - ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip - - 1 - 9 - - - 5MB - - - "%d [%thread] %-5level %logger{1024} - %msg%n" - - - - - - - - - - + + + + + + - - + @@ -371,11 +300,6 @@ - - - - - @@ -387,5 +311,6 @@ + -- cgit 1.2.3-korg