aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources')
-rw-r--r--aai-resources/pom.xml118
-rw-r--r--aai-resources/src/main/assembly/descriptor.xml6
-rw-r--r--aai-resources/src/main/docker/docker-entrypoint.sh12
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java12
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java40
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java28
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java182
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java309
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java273
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/tags/Command.java25
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java212
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java285
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java6
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java8
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java100
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java254
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java59
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java59
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java2
-rw-r--r--aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml2
-rw-r--r--aai-resources/src/main/kubernetes/kubectl.conf8
-rw-r--r--aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/default-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/error.properties2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/getres-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties (renamed from aai-resources/src/main/resources/etc/appprops/titan-cached.properties)2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties (renamed from aai-resources/src/main/resources/etc/appprops/titan-realtime.properties)3
-rw-r--r--aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/migration-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml2
-rw-r--r--aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml2
-rw-r--r--aai-resources/src/main/resources/logback.xml2
-rw-r--r--aai-resources/src/main/scripts/common_functions.sh15
-rw-r--r--aai-resources/src/main/scripts/createDBSchema.sh2
-rw-r--r--aai-resources/src/main/scripts/run_Migrations.sh2
-rw-r--r--aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml9
-rw-r--r--aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java10
-rw-r--r--aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java228
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java258
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java281
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java126
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java154
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java16
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java16
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java16
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java379
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java112
-rw-r--r--aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java112
-rw-r--r--aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java29
-rw-r--r--aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties2
-rw-r--r--aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties (renamed from aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties)6
-rw-r--r--aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties (renamed from aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties)4
-rw-r--r--aai-resources/src/test/resources/logback.xml2
-rw-r--r--aai-resources/src/test/resources/updateEdgeTestRules.json60
67 files changed, 3483 insertions, 493 deletions
diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml
index e47023c..cd0ce4f 100644
--- a/aai-resources/pom.xml
+++ b/aai-resources/pom.xml
@@ -80,8 +80,10 @@
<hamcrest.junit.version>2.0.0.0</hamcrest.junit.version>
<janino.version>2.7.8</janino.version>
<google.guava.version>16.0</google.guava.version>
- <titan.version>1.0.0</titan.version>
- <gremlin.driver.version>3.0.1-incubating</gremlin.driver.version>
+ <janusgraph.version>0.2.0</janusgraph.version>
+ <gremlin.driver.version>3.2.2</gremlin.driver.version>
+ <gremlin.core.version>3.2.2</gremlin.core.version>
+ <gremlin.version>3.2.2</gremlin.version>
<hbase.version>1.0.2</hbase.version>
<smack.version>3.0.4</smack.version>
<json.simple.version>1.1.1</json.simple.version>
@@ -148,6 +150,9 @@
<!-- This will be used for the docker images as the default format of maven build has issues -->
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+
+ <license.goal.type>check</license.goal.type>
+ <jacoco.line.coverage.limit>0.55</jacoco.line.coverage.limit>
</properties>
<profiles>
<!-- Docker profile to be used for building docker image and pushing to nexus -->
@@ -383,9 +388,9 @@
<version>${google.guava.version}</version>
</dependency>
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-core</artifactId>
- <version>${titan.version}</version>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-core</artifactId>
+ <version>${janusgraph.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -394,9 +399,10 @@
</exclusions>
</dependency>
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-cassandra</artifactId>
- <version>${titan.version}</version>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-hbase-parent</artifactId>
+ <version>${janusgraph.version}</version>
+ <type>pom</type>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -405,9 +411,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-hbase</artifactId>
- <version>${titan.version}</version>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-hbase</artifactId>
+ <version>${janusgraph.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -415,11 +421,31 @@
</exclusion>
</exclusions>
</dependency>
-
+ <dependency>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-cassandra</artifactId>
+ <version>${janusgraph.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>${gremlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ <version>${gremlin.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
- <version>${gremlin.driver.version}</version>
+ <version>${gremlin.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
@@ -745,6 +771,11 @@
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ <version>${gremlin.version}</version>
+ </dependency>
</dependencies>
<build>
<resources>
@@ -775,8 +806,8 @@
<resource>
<directory>${project.basedir}/src/main/resources/etc/appprops/</directory>
<includes>
- <include>titan-realtime.properties</include>
- <include>titan-cached.properties</include>
+ <include>janusgraph-realtime.properties</include>
+ <include>janusgraph-cached.properties</include>
<include>aaiconfig.properties</include>
</includes>
<targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-resources/appconfig
@@ -788,6 +819,7 @@
<includes>
<include>aai-client-cert.p12</include>
<include>tomcat_keystore</include>
+ <include>aai_policy.json</include>
</includes>
<targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-resources/appconfig
</targetPath>
@@ -820,32 +852,25 @@
<version>2.8</version>
<executions>
<execution>
- <id>copy-agent</id>
- <phase>process-test-classes</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- </execution>
- <execution>
<id>unpack-schema-dependency</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>${aai.core.version}</version>
+ <outputDirectory>${project.basedir}/src/main/resources/etc/</outputDirectory>
+ <includes>oxm/*.xml</includes>
+ </artifactItem>
+ </artifactItems>
+ <!-- other configurations here -->
+ </configuration>
</execution>
</executions>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-schema</artifactId>
- <version>${aai.core.version}</version>
- <outputDirectory>${project.basedir}/src/main/resources/etc</outputDirectory>
- <includes>oxm/*.xml</includes>
- </artifactItem>
- </artifactItems>
- <!-- other configurations here -->
- </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
@@ -971,6 +996,27 @@
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
+ <execution>
+ <id>default-check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
+ <rules>
+ <rule implementation="org.jacoco.maven.RuleConfiguration">
+ <element>BUNDLE</element>
+ <limits>
+ <limit implementation="org.jacoco.report.check.Limit">
+ <counter>LINE</counter>
+ <value>COVEREDRATIO</value>
+ <minimum>${jacoco.line.coverage.limit}</minimum>
+ </limit>
+ </limits>
+ </rule>
+ </rules>
+ </configuration>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -1027,9 +1073,9 @@
<execution>
<goals>
<!-- Set goal to "format" to auto update license headers -->
- <goal>check</goal>
+ <goal>${license.goal.type}</goal>
</goals>
- <phase>process-sources</phase>
+ <phase>initialize</phase>
</execution>
</executions>
</plugin>
diff --git a/aai-resources/src/main/assembly/descriptor.xml b/aai-resources/src/main/assembly/descriptor.xml
index 91e8e18..6dc677b 100644
--- a/aai-resources/src/main/assembly/descriptor.xml
+++ b/aai-resources/src/main/assembly/descriptor.xml
@@ -9,21 +9,21 @@
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
- <outputDirectory>/resources</outputDirectory>
+ <outputDirectory>./resources</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/scripts</directory>
- <outputDirectory>/bin</outputDirectory>
+ <outputDirectory>./bin</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
- <outputDirectory>/lib</outputDirectory>
+ <outputDirectory>./lib</outputDirectory>
<includes>
<include>${project.artifactId}-${project.version}.jar</include>
</includes>
diff --git a/aai-resources/src/main/docker/docker-entrypoint.sh b/aai-resources/src/main/docker/docker-entrypoint.sh
index 2f57a2a..d268888 100644
--- a/aai-resources/src/main/docker/docker-entrypoint.sh
+++ b/aai-resources/src/main/docker/docker-entrypoint.sh
@@ -31,12 +31,8 @@ export SERVER_PORT=${SERVER_PORT:-8447};
USER_ID=${LOCAL_USER_ID:-9001}
GROUP_ID=${LOCAL_GROUP_ID:-9001}
-ln -s bin scripts
-ln -s /opt/aai/logroot/AAI-RES logs
+if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then
-echo "Project Build Version: ${aai.build.version}";
-
-if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then
groupadd aaiadmin -g ${GROUP_ID} || {
echo "Unable to create the group id for ${GROUP_ID}";
exit 1;
@@ -51,6 +47,10 @@ chown -R aaiadmin:aaiadmin /opt/app /opt/aai/logroot /var/chef
find /opt/app/ -name "*.sh" -exec chmod +x {} +
if [ -f ${APP_HOME}/aai.sh ]; then
+
+ gosu aaiadmin ln -s bin scripts
+ gosu aaiadmin ln -s /opt/aai/logroot/AAI-RES logs
+
mv ${APP_HOME}/aai.sh /etc/profile.d/aai.sh
chmod 755 /etc/profile.d/aai.sh
@@ -105,6 +105,6 @@ JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom";
JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources";
JAVA_OPTS="${JAVA_OPTS} ${POST_JAVA_OPTS}";
-JAVA_MAIN_JAR=$(ls lib/aai-resources-*SNAPSHOT.jar);
+JAVA_MAIN_JAR=$(ls lib/aai-resources*.jar);
${JAVA_CMD} ${JVM_OPTS} ${JAVA_OPTS} -jar ${JAVA_MAIN_JAR};
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 aa1f9a6..d7271c9 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
@@ -39,8 +39,8 @@ import org.onap.aai.util.FormatDate;
import com.att.eelf.configuration.Configuration;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.util.TitanCleanup;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.util.JanusGraphCleanup;
public class DataSnapshot {
@@ -63,7 +63,7 @@ public class DataSnapshot {
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
Boolean dbClearFlag = false;
- TitanGraph graph = null;
+ JanusGraph graph = null;
String command = "JUST_TAKE_SNAPSHOT"; // This is the default
String oldSnapshotFileName = "";
if (args.length == 1) {
@@ -160,7 +160,7 @@ public class DataSnapshot {
System.out.println(" Begin clearing out old data. ");
graph.close();
- TitanCleanup.clear(graph);
+ JanusGraphCleanup.clear(graph);
System.out.println(" Done clearing data. ");
System.out.println(">>> IMPORTANT - NOTE >>> you need to run the SchemaGenerator (use GenTester) before ");
System.out.println(" reloading data or the data will be put in without indexes. ");
@@ -192,7 +192,7 @@ public class DataSnapshot {
}
System.out.println("We will load data IN from the file = " + oldSnapshotFullFname);
- System.out.println(" Begin reloading Titan 0.5 data. ");
+ System.out.println(" Begin reloading JanusGraph 0.5 data. ");
LegacyGraphSONReader lgr = LegacyGraphSONReader.build().create();
InputStream is = new FileInputStream(oldSnapshotFullFname);
@@ -200,7 +200,7 @@ public class DataSnapshot {
System.out.println("Completed the inputGraph command, now try to commit()... ");
graph.tx().commit();
- System.out.println("Completed reloading Titan 0.5 data.");
+ System.out.println("Completed reloading JanusGraph 0.5 data.");
long vCount = graph.traversal().V().count().next();
System.out.println("A little after repopulating from an old snapshot, we see: " + vCount + " vertices in the db.");
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 87d68c3..3b9c56e 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
@@ -56,8 +56,8 @@ import org.slf4j.MDC;
import com.att.eelf.configuration.Configuration;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
@@ -132,8 +132,8 @@ public class DupeTool {
logger.error("ERROR - Could not do the moxyMod.init() " + LogFormatTools.getStackTop(ex));
exit(1);
}
- TitanGraph graph1 = null;
- TitanGraph graph2 = null;
+ JanusGraph graph1 = null;
+ JanusGraph graph2 = null;
Graph gt1 = null;
Graph gt2 = null;
@@ -482,7 +482,7 @@ public class DupeTool {
gt1.tx().rollback();
}
catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed
logger.warn("WARNING from final gt1.rollback() " + LogFormatTools.getStackTop(ex));
}
}
@@ -493,7 +493,7 @@ public class DupeTool {
try {
gt2.tx().rollback();
} catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed
logger.warn("WARNING from final gt2.rollback() " + LogFormatTools.getStackTop(ex));
}
}
@@ -503,7 +503,7 @@ public class DupeTool {
closeGraph(graph1, logger);
}
} catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{
logger.warn("WARNING from final graph1.shutdown() " + LogFormatTools.getStackTop(ex));
}
@@ -512,7 +512,7 @@ public class DupeTool {
closeGraph(graph2, logger);
}
} catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{
logger.warn("WARNING from final graph2.shutdown() " + LogFormatTools.getStackTop(ex));
}
}
@@ -756,7 +756,7 @@ public class DupeTool {
}// End of getDupeSets4DependentNodes()
- private static Graph getGraphTransaction(TitanGraph graph, EELFLogger logger){
+ private static Graph getGraphTransaction(JanusGraph graph, EELFLogger logger){
Graph gt = null;
try {
@@ -829,7 +829,7 @@ public class DupeTool {
}
}// End of showNodeInfo()
-
+
public static ArrayList <String> collectEdgeInfoForNode( EELFLogger logger, Vertex tVert, boolean displayAllVidsFlag ){
ArrayList <String> retArr = new ArrayList <String> ();
Direction dir = Direction.OUT;
@@ -1035,7 +1035,7 @@ public class DupeTool {
}
if(tgQ == null){
- msg = "Bad TitanGraphQuery object. ";
+ msg = "Bad JanusGraphQuery object. ";
System.out.println(msg);
LoggingContext.statusCode(StatusCode.ERROR);
LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
@@ -1391,7 +1391,7 @@ public class DupeTool {
String nType, ArrayList<Vertex> passedVertList, Loader loader)
throws AAIException {
- // Given a list of Titan Vertices, group them together by dependent
+ // Given a list of JanusGraph Vertices, group them together by dependent
// nodes. Ie. if given a list of ip address nodes (assumed to all
// have the same key info) they might sit under several different
// parent vertices.
@@ -1755,7 +1755,7 @@ public class DupeTool {
// This is not the last entry, it is one of the dupes
delIdArr.add(dupeArr[i]);
continue;
- }
+ }
// This is the last entry which should tell us if we
// have a preferred keeper and how many dupes we had
@@ -1846,9 +1846,9 @@ public class DupeTool {
private static int graphIndex = 1;
- public static TitanGraph setupGraph(EELFLogger logger){
+ public static JanusGraph setupGraph(EELFLogger logger){
- TitanGraph titanGraph = null;
+ JanusGraph janusGraph = null;
try (InputStream inputStream = new FileInputStream(AAIConstants.REALTIME_DB_CONFIG);){
@@ -1857,20 +1857,20 @@ public class DupeTool {
properties.load(inputStream);
if(INMEMORY.equals(properties.get("storage.backend"))){
- titanGraph = AAIGraph.getInstance().getGraph();
+ janusGraph = AAIGraph.getInstance().getGraph();
graphType = INMEMORY;
} else {
- titanGraph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DupeTool.class.getSimpleName()).withGraphType("realtime" + graphIndex).buildConfiguration());
+ janusGraph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DupeTool.class.getSimpleName()).withGraphType("realtime" + graphIndex).buildConfiguration());
graphIndex++;
}
} catch (Exception e) {
logger.error("Unable to open the graph", LogFormatTools.getStackTop(e));
}
- return titanGraph;
+ return janusGraph;
}
- public static void closeGraph(TitanGraph graph, EELFLogger logger){
+ public static void closeGraph(JanusGraph graph, EELFLogger logger){
try {
if(INMEMORY.equals(graphType)) {
@@ -1881,7 +1881,7 @@ public class DupeTool {
graph.close();
}
} catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{
logger.warn("WARNING from final graph.shutdown()", ex);
}
}
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 060e659..96c5467 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
@@ -47,8 +47,8 @@ import org.slf4j.MDC;
import com.att.eelf.configuration.Configuration;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
@@ -235,7 +235,7 @@ public class ForceDeleteTool {
}
String msg = "";
- TitanGraph graph = null;
+ JanusGraph graph = null;
try {
AAIConfig.init();
System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n");
@@ -321,7 +321,7 @@ public class ForceDeleteTool {
}
}
else {
- msg = "Bad TitanGraphQuery object. ";
+ msg = "Bad JanusGraphQuery object. ";
System.out.println(msg);
LoggingContext.statusCode(StatusCode.ERROR);
LoggingContext.responseCode(LoggingContext.DATA_ERROR);
@@ -411,9 +411,9 @@ public class ForceDeleteTool {
public static class ForceDelete {
- private static final int MAXDESCENDENTDEPTH = 15;
- private final TitanGraph graph;
- public ForceDelete(TitanGraph graph) {
+ private final int MAXDESCENDENTDEPTH = 15;
+ private final JanusGraph graph;
+ public ForceDelete(JanusGraph graph) {
this.graph = graph;
}
public void showNodeInfo(EELFLogger logger, Vertex tVert, Boolean displayAllVidsFlag ){
@@ -814,9 +814,9 @@ public class ForceDeleteTool {
} // End of getNodeDelConfirmation()
}
- public static TitanGraph setupGraph(EELFLogger logger){
+ public static JanusGraph setupGraph(EELFLogger logger){
- TitanGraph titanGraph = null;
+ JanusGraph janusGraph = null;
try (InputStream inputStream = new FileInputStream(AAIConstants.REALTIME_DB_CONFIG);){
@@ -824,10 +824,10 @@ public class ForceDeleteTool {
properties.load(inputStream);
if(INMEMORY.equals(properties.get("storage.backend"))){
- titanGraph = AAIGraph.getInstance().getGraph();
+ janusGraph = AAIGraph.getInstance().getGraph();
graphType = INMEMORY;
} else {
- titanGraph = TitanFactory.open(
+ janusGraph = JanusGraphFactory.open(
new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG)
.forService(ForceDeleteTool.class.getSimpleName())
.withGraphType("realtime1")
@@ -838,10 +838,10 @@ public class ForceDeleteTool {
logger.error("Unable to open the graph", LogFormatTools.getStackTop(e));
}
- return titanGraph;
+ return janusGraph;
}
- public static void closeGraph(TitanGraph graph, EELFLogger logger){
+ public static void closeGraph(JanusGraph graph, EELFLogger logger){
try {
if(INMEMORY.equals(graphType)) {
@@ -852,7 +852,7 @@ public class ForceDeleteTool {
graph.close();
}
} catch (Exception ex) {
- // Don't throw anything because Titan sometimes is just saying that the graph is already closed
+ // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{
logger.warn("WARNING from final graph.shutdown()", ex);
}
}
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
new file mode 100644
index 0000000..146b729
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java
@@ -0,0 +1,182 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.dbgen;
+
+import java.util.Properties;
+
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.UniquePropertyCheck;
+import org.slf4j.MDC;
+
+import com.att.eelf.configuration.Configuration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class SchemaMod {
+
+
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+
+ SchemaMod.execute(args);
+ System.exit(0);
+
+ }// End of main()
+
+ /**
+ * Execute.
+ *
+ * @param args the args
+ */
+ public static void execute(String[] args) {
+
+ // Set the logging file properties to be used by EELFManager
+ Properties props = System.getProperties();
+ props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_SCHEMA_MOD_LOGBACK_PROPS);
+ props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
+
+ EELFLogger logger = EELFManager.getInstance().getLogger(UniquePropertyCheck.class.getSimpleName());
+ MDC.put("logFilenameAppender", SchemaMod.class.getSimpleName());
+
+ // NOTE -- We're just working with properties that are used for NODES
+ // for now.
+ String propName = "";
+ String targetDataType = "";
+ String targetIndexInfo = "";
+ String preserveDataFlag = "";
+
+ String usageString = "Usage: SchemaMod propertyName targetDataType targetIndexInfo preserveDataFlag \n";
+ if (args.length != 4) {
+ String emsg = "Four Parameters are required. \n" + usageString;
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ } else {
+ propName = args[0];
+ targetDataType = args[1];
+ targetIndexInfo = args[2];
+ preserveDataFlag = args[3];
+ }
+
+ if (propName.equals("")) {
+ String emsg = "Bad parameter - propertyName cannot be empty. \n" + usageString;
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ } else if (!targetDataType.equals("String") && !targetDataType.equals("Set<String>")
+ && !targetDataType.equals("Integer") && !targetDataType.equals("Long")
+ && !targetDataType.equals("Boolean")) {
+ String emsg = "Unsupported targetDataType. We only support String, Set<String>, Integer, Long or Boolean for now.\n"
+ + usageString;
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ } else if (!targetIndexInfo.equals("uniqueIndex") && !targetIndexInfo.equals("index")
+ && !targetIndexInfo.equals("noIndex")) {
+ String emsg = "Unsupported IndexInfo. We only support: 'uniqueIndex', 'index' or 'noIndex'.\n"
+ + usageString;
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ }
+
+ try {
+ AAIConfig.init();
+ ErrorLogHelper.loadProperties();
+ } catch (Exception ae) {
+ String emsg = "Problem with either AAIConfig.init() or ErrorLogHelper.LoadProperties(). ";
+ logAndPrint(logger, emsg + "[" + ae.getMessage() + "]");
+ System.exit(1);
+ }
+
+
+ // Give a big warning if the DbMaps.PropertyDataTypeMap value does not
+ // agree with what we're doing
+ String warningMsg = "";
+ /*if (!dbMaps.PropertyDataTypeMap.containsKey(propName)) {
+ String emsg = "Property Name = [" + propName + "] not found in PropertyDataTypeMap. ";
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ } else {
+ String currentDataType = dbMaps.PropertyDataTypeMap.get(propName);
+ if (!currentDataType.equals(targetDataType)) {
+ warningMsg = "TargetDataType [" + targetDataType + "] does not match what is in DbRules.java ("
+ + currentDataType + ").";
+ }
+ }*/
+
+ if (!warningMsg.equals("")) {
+ logAndPrint(logger, "\n>>> WARNING <<<< ");
+ logAndPrint(logger, ">>> " + warningMsg + " <<<");
+ }
+
+ logAndPrint(logger, ">>> Processing will begin in 5 seconds (unless interrupted). <<<");
+ try {
+ // Give them a chance to back out of this
+ Thread.sleep(5000);
+ } catch (java.lang.InterruptedException ie) {
+ logAndPrint(logger, " DB Schema Update has been aborted. ");
+ 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.
+ *
+ * @param logger the logger
+ * @param msg the msg
+ */
+ protected static void logAndPrint(EELFLogger logger, String msg) {
+ System.out.println(msg);
+ logger.info(msg);
+ }
+
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java
new file mode 100644
index 0000000..1aa33ee
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java
@@ -0,0 +1,309 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.dbgen;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.UUID;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.util.FormatDate;
+import org.onap.aai.util.UniquePropertyCheck;
+
+import com.att.eelf.configuration.EELFLogger;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.schema.JanusGraphManagement;
+
+public class SchemaModInternal {
+ private static final String FROMAPPID = "AAI-UTILS";
+ private final String TRANSID = UUID.randomUUID().toString();
+ private final TransactionalGraphEngine engine;
+ private final String propName;
+ private final Class<?> type;
+ private final String indexType;
+ private final boolean preserveData;
+ private final Cardinality cardinality;
+ private final EELFLogger logger;
+
+ public SchemaModInternal(TransactionalGraphEngine engine, EELFLogger logger, String propName, String type, String indexType, boolean preserveData) {
+ this.engine = engine;
+ this.propName = propName;
+ this.type = determineClass(type);
+ this.indexType = indexType;
+ this.preserveData = preserveData;
+ this.cardinality = determineCardinality(type);
+ this.logger = logger;
+ }
+
+
+ private Class<?> determineClass(String type) {
+ final Class<?> result;
+ if (type.equals("String")) {
+ result = String.class;
+ } else if (type.equals("Set<String>")) {
+ result = String.class;
+ } else if (type.equals("Integer")) {
+ result = Integer.class;
+ } else if (type.equals("Boolean")) {
+ result = Boolean.class;
+ } else if (type.equals("Character")) {
+ result = Character.class;
+ } else if (type.equals("Long")) {
+ result = Long.class;
+ } else if (type.equals("Float")) {
+ result = Float.class;
+ } else if (type.equals("Double")) {
+ result = Double.class;
+ } else {
+ String emsg = "Not able translate the targetDataType [" + type + "] to a Class variable.\n";
+ logAndPrint(logger, emsg);
+ throw new RuntimeException(emsg);
+ }
+
+ return result;
+ }
+ private Cardinality determineCardinality(String type) {
+ if (type.equals("Set<String>")) {
+ return Cardinality.SET;
+ } else {
+ return Cardinality.SINGLE;
+ }
+ }
+ public void execute() {
+ JanusGraphManagement graphMgt = null;
+ boolean success = false;
+ try {
+ // Make sure this property is in the DB.
+ graphMgt = engine.asAdmin().getManagementSystem();
+ if (graphMgt == null) {
+ String emsg = "Not able to get a graph Management object in SchemaMod.java\n";
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ }
+ PropertyKey origPropKey = graphMgt.getPropertyKey(propName);
+ if (origPropKey == null) {
+ String emsg = "The propName = [" + propName + "] is not defined in our graph. ";
+ logAndPrint(logger, emsg);
+ System.exit(1);
+ }
+
+ if (indexType.equals("uniqueIndex")) {
+ // Make sure the data in the property being changed can have a
+ // unique-index put on it.
+ // Ie. if there are duplicate values, we will not be able to
+ // migrate the data back into the property.
+ Boolean foundDupesFlag = UniquePropertyCheck.runTheCheckForUniqueness(TRANSID, FROMAPPID,
+ engine.tx(), propName, logger);
+ if (foundDupesFlag) {
+ logAndPrint(logger,
+ "\n\n!!!!!! >> Cannot add a uniqueIndex for the property: [" + propName
+ + "] because duplicate values were found. See the log for details on which"
+ + " nodes have this value. \nThey will need to be resolved (by updating those values to new"
+ + " values or deleting unneeded nodes) using the standard REST-API \n");
+ System.exit(1);
+ }
+ }
+
+ // -------------- If we made it to here - we must be OK with making
+ // this change ------------
+
+ // Rename this property to a backup name (old name with "retired_"
+ // appended plus a dateStr)
+
+ FormatDate fd = new FormatDate("MMddHHmm", "GMT");
+ String dteStr= fd.getDateTime();
+
+ String retiredName = propName + "-" + dteStr + "-RETIRED";
+ graphMgt.changeName(origPropKey, retiredName);
+
+ // Create a new property using the original property name and the
+ // targetDataType
+ PropertyKey freshPropKey = graphMgt.makePropertyKey(propName).dataType(type)
+ .cardinality(cardinality).make();
+
+ // Create the appropriate index (if any)
+ if (indexType.equals("uniqueIndex")) {
+ String freshIndexName = propName + dteStr;
+ graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).unique().buildCompositeIndex();
+ } else if (indexType.equals("index")) {
+ String freshIndexName = propName + dteStr;
+ graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).buildCompositeIndex();
+ }
+
+ logAndPrint(logger, "Committing schema changes with graphMgt.commit()");
+ graphMgt.commit();
+ engine.startTransaction();
+ // Get A new graph object
+ logAndPrint(logger, " ---- NOTE --- about to open a second graph object (takes a little while)\n");
+
+ // For each node that has this property, update the new from the old
+ // and then remove the
+ // old property from that node
+ Iterator<Vertex> verts = engine.asAdmin().getTraversalSource().V().has(retiredName);
+ int vtxCount = 0;
+ ArrayList<String> alreadySeenVals = new ArrayList<String>();
+ while (verts.hasNext()) {
+ vtxCount++;
+ Vertex tmpVtx = verts.next();
+ String tmpVid = tmpVtx.id().toString();
+
+ Object origVal = tmpVtx.<Object> property(retiredName).orElse(null);
+ if (preserveData) {
+ tmpVtx.property(propName, origVal);
+ if (indexType.equals("uniqueIndex")) {
+ // We're working on a property that is being used as a
+ // unique index
+ String origValStr = "";
+ if (origVal != null) {
+ origValStr = origVal.toString();
+ }
+ if (alreadySeenVals.contains(origValStr)) {
+ // This property is supposed to be unique, but we've
+ // already seen this value in this loop
+ // This should have been caught up in the first part
+ // of SchemaMod, but since it wasn't, we
+ // will just log the problem.
+ logAndPrint(logger,
+ "\n\n ---------- ERROR - could not migrate the old data [" + origValStr
+ + "] for propertyName [" + propName
+ + "] because this property is having a unique index put on it.");
+ showPropertiesAndEdges(TRANSID, FROMAPPID, tmpVtx, logger);
+ logAndPrint(logger, "-----------------------------------\n");
+ } else {
+ // Ok to add this prop in as a unique value
+ tmpVtx.property(propName, origVal);
+ logAndPrint(logger,
+ "INFO -- just did the add of the freshPropertyKey and updated it with the orig value ("
+ + origValStr + ")");
+ }
+ alreadySeenVals.add(origValStr);
+ } else {
+ // We are not working with a unique index
+ tmpVtx.property(propName, origVal);
+ logAndPrint(logger,
+ "INFO -- just did the add of the freshPropertyKey and updated it with the orig value ("
+ + origVal.toString() + ")");
+ }
+ } else {
+ // existing nodes just won't have that property anymore
+ // Not sure if we'd ever actually want to do this -- maybe
+ // we'd do this if the new
+ // data type was not compatible with the old?
+ }
+ tmpVtx.property(retiredName).remove();
+
+ logAndPrint(logger, "INFO -- just did the remove of the " + retiredName + " from this vertex. (vid="
+ + tmpVid + ")");
+ }
+
+ success = true;
+ } catch (Exception ex) {
+ logAndPrint(logger, "Threw a regular Exception: ");
+ logAndPrint(logger, ex.getMessage());
+ } finally {
+ if (graphMgt != null && graphMgt.isOpen()) {
+ // Any changes that worked correctly should have already done
+ // their commits.
+ graphMgt.rollback();
+ }
+ if (engine != null) {
+ if (success) {
+ engine.commit();
+ } else {
+ engine.rollback();
+ }
+ }
+ }
+ }
+
+ /**
+ * Show properties and edges.
+ *
+ * @param transId the trans id
+ * @param fromAppId the from app id
+ * @param tVert the t vert
+ * @param logger the logger
+ */
+ private static void showPropertiesAndEdges(String transId, String fromAppId, Vertex tVert, EELFLogger logger) {
+
+ if (tVert == null) {
+ logAndPrint(logger, "Null node passed to showPropertiesAndEdges.");
+ } else {
+ String nodeType = "";
+ Object ob = tVert.<String> property("aai-node-type");
+ if (ob == null) {
+ nodeType = "null";
+ } else {
+ nodeType = ob.toString();
+ }
+
+ logAndPrint(logger, " AAINodeType/VtxID for this Node = [" + nodeType + "/" + tVert.id() + "]");
+ logAndPrint(logger, " Property Detail: ");
+ Iterator<VertexProperty<Object>> pI = tVert.properties();
+ while (pI.hasNext()) {
+ VertexProperty<Object> tp = pI.next();
+ Object val = tp.value();
+ logAndPrint(logger, "Prop: [" + tp.key() + "], val = [" + val + "] ");
+ }
+
+ Iterator<Edge> eI = tVert.edges(Direction.BOTH);
+ if (!eI.hasNext()) {
+ logAndPrint(logger, "No edges were found for this vertex. ");
+ }
+ while (eI.hasNext()) {
+ Edge ed = eI.next();
+ String lab = ed.label();
+ Vertex vtx;
+ if (tVert.equals(ed.inVertex())) {
+ vtx = ed.outVertex();
+ } else {
+ vtx = ed.inVertex();
+ }
+ if (vtx == null) {
+ logAndPrint(logger,
+ " >>> COULD NOT FIND VERTEX on the other side of this edge edgeId = " + ed.id() + " <<< ");
+ } else {
+ String nType = vtx.<String> property("aai-node-type").orElse(null);
+ String vid = vtx.id().toString();
+ logAndPrint(logger, "Found an edge (" + lab + ") from this vertex to a [" + nType
+ + "] node with VtxId = " + vid);
+ }
+ }
+ }
+ } // End of showPropertiesAndEdges()
+
+ /**
+ * Log and print.
+ *
+ * @param logger the logger
+ * @param msg the msg
+ */
+ protected static void logAndPrint(EELFLogger logger, String msg) {
+ System.out.println(msg);
+ logger.info(msg);
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java b/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
index 8be40de..aebc456 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
@@ -19,23 +19,14 @@
*/
package org.onap.aai.dbgen;
-import com.google.common.collect.Multimap;
-import com.thinkaurelius.titan.core.TitanGraph;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.dbgen.tags.UpdateEdgeTagsCmd;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.LoggingContext.StatusCode;
-import org.onap.aai.serialization.db.EdgeRule;
-import org.onap.aai.serialization.db.EdgeRules;
-import org.onap.aai.util.AAIConfig;
-import org.onap.aai.util.AAISystemExitUtil;
import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.AAISystemExitUtil;
-import java.util.*;
+import java.util.UUID;
public class UpdateEdgeTags {
@@ -52,10 +43,10 @@ public class UpdateEdgeTags {
System.setProperty("aai.service.name", UpdateEdgeTags.class.getSimpleName());
- if( args == null || args.length != 1 ){
+ if( args == null || args.length != 1 ){
String msg = "usage: UpdateEdgeTags edgeRuleKey (edgeRuleKey can be either, all, or a rule key like 'nodeTypeA|nodeTypeB') \n";
System.out.println(msg);
- AAISystemExitUtil.systemExitCloseAAIGraph(1);
+ System.exit(1);
}
LoggingContext.init();
LoggingContext.partnerName(FROMAPPID);
@@ -66,257 +57,19 @@ public class UpdateEdgeTags {
LoggingContext.requestId(TRANSID);
LoggingContext.statusCode(StatusCode.COMPLETE);
LoggingContext.responseCode("0");
-
- String edgeRuleKeyVal = args[0];
-
- TitanGraph graph = null;
- EdgeRules edgeRulesInstance = EdgeRules.getInstance();
- Multimap<String, EdgeRule> edgeRuleMultimap = edgeRulesInstance.getAllRules();
-
- HashMap <String,Object> edgeRuleHash = new HashMap <String,Object>();
- HashMap <String,Object> edgeRulesFullHash = new HashMap <String,Object>();
- HashMap <String,Object> edgeRuleLabelToKeyHash = new HashMap <String,Object>();
- ArrayList <String> labelMapsToMultipleKeys = new <String> ArrayList ();
-
- // Loop through all the edge-rules make sure they look right and
- // collect info about which labels support duplicate ruleKeys.
- Iterator<String> edgeRulesIterator = edgeRuleMultimap.keySet().iterator();
-
- while( edgeRulesIterator.hasNext() ){
- String ruleKey = edgeRulesIterator.next();
- Collection <EdgeRule> edRuleColl = edgeRuleMultimap.get(ruleKey);
- Iterator <EdgeRule> ruleItr = edRuleColl.iterator();
- if( ruleItr.hasNext() ){
- // For now, we only look for one type of edge between two nodes.
- EdgeRule edgeRule = ruleItr.next();
- String edgeRuleString = String.format("%s,%s,%s,%s,%s,%s",
- edgeRule.getLabel(),
- edgeRule.getDirection(),
- edgeRule.getMultiplicityRule(),
- edgeRule.getContains(),
- edgeRule.getDeleteOtherV(),
- edgeRule.getServiceInfrastructure());
- edgeRulesFullHash.put(ruleKey,edgeRuleString);
- String edgeLabel = edgeRule.getLabel();
- if( edgeRuleLabelToKeyHash.containsKey(edgeLabel) ){
- // This label maps to more than one edge rule - we'll have to figure out
- // which rule applies when we look at each edge that uses this label.
- // So we take it out of mapping hash and add it to the list of ones that
- // we'll need to look up later.
- edgeRuleLabelToKeyHash.remove(edgeLabel);
- labelMapsToMultipleKeys.add(edgeLabel);
- }
- else {
- edgeRuleLabelToKeyHash.put(edgeLabel, ruleKey);
- }
- }
- }
-
- if( ! edgeRuleKeyVal.equals( "all" ) ){
- // If they passed in a (non-"all") argument, that is the single edgeRule that they want to update.
- // Note - the key looks like "nodeA|nodeB" as it appears in DbEdgeRules.EdgeRules
- Collection <EdgeRule> edRuleColl = edgeRuleMultimap.get(edgeRuleKeyVal);
- Iterator <EdgeRule> ruleItr = edRuleColl.iterator();
- if( ruleItr.hasNext() ){
- // For now, we only look for one type of edge between two nodes (Ie. for one key).
- EdgeRule edRule = ruleItr.next();
- edgeRuleHash.put(edgeRuleKeyVal, edRule);
- System.out.println("Adding this rule to list of rules to do: key = " + edgeRuleKeyVal + ", rule = [" + edRule + "]");
- }
- else {
- String msg = " Error - Unrecognized edgeRuleKey: [" + edgeRuleKeyVal + "]. ";
- System.out.println(msg);
- AAISystemExitUtil.systemExitCloseAAIGraph(0);
- }
- }
- else {
- // They didn't pass a target ruleKey in, so we'll work on all types of edges
- edgeRuleHash.putAll(edgeRulesFullHash);
- }
- try {
- AAIConfig.init();
- System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n");
- ErrorLogHelper.loadProperties();
-
- graph = AAIGraph.getInstance().getGraph();
-
- if( graph == null ){
- String emsg = "null graph object in updateEdgeTags() \n";
- System.out.println(emsg);
- AAISystemExitUtil.systemExitCloseAAIGraph(0);
- }
- }
- catch (AAIException e1) {
- String msg = e1.getErrorObject().toString();
- System.out.println(msg);
- AAISystemExitUtil.systemExitCloseAAIGraph(0);
- }
- catch (Exception e2) {
- String msg = e2.toString();
- System.out.println(msg);
- e2.printStackTrace();
- AAISystemExitUtil.systemExitCloseAAIGraph(0);
- }
-
- Graph g = graph.newTransaction();
- try {
- Iterator<Edge> edgeItr = graph.traversal().E();
-
- // Loop through all edges and update their tags if they are a type we are interested in.
- // Sorry about looping over everything, but for now, I can't find a way to just select one type of edge at a time...!?
- StringBuffer sb;
- boolean missingEdge = false;
- while( edgeItr != null && edgeItr.hasNext() ){
- Edge tmpEd = edgeItr.next();
- String edLab = tmpEd.label().toString();
-
- // Since we have edgeLabels that can be used for different pairs of node-types, we have to
- // look to see what nodeTypes this edge is connecting (if it is a label that could do this).
- String derivedEdgeKey = "";
- if( labelMapsToMultipleKeys.contains(edLab) ){
- // need to figure out which key is right for this edge
- derivedEdgeKey = deriveEdgeRuleKeyForThisEdge( TRANSID, FROMAPPID, g, tmpEd );
- }
- else {
- // This kind of label only maps to one key -- so we can just look it up.
- if ( edgeRuleLabelToKeyHash.get(edLab) == null ) {
- if ( !missingEdge ) {
- System.out.print("DEBUG - missing edge(s) in edgeRuleLabelToKeyHash " + edgeRuleLabelToKeyHash.toString());
- missingEdge = true;
- }
- sb = new StringBuffer();
- Vertex vIn = null;
- Vertex vOut = null;
- Object obj = null;
- vIn = tmpEd.inVertex();
- if ( vIn != null ){
- obj = vIn.<String>property("aai-node-type").orElse(null);
- if ( obj != null ) {
- sb.append("from node-type " + obj.toString());
-
- obj = vIn.id();
- sb.append(" id " + obj.toString());
- } else {
- sb.append(" missing from node-type ");
- }
- } else {
- sb.append(" missing inbound vertex ");
- }
- vOut = tmpEd.outVertex();
- if ( vOut != null ) {
- obj = vOut.<String>property("aai-node-type").orElse(null);
- if ( obj != null ) {
- sb.append(" to node-type " + obj.toString());
- obj = vOut.id();
- sb.append(" id " + obj.toString());
- } else {
- sb.append(" missing to node-type ");
- }
- } else {
- sb.append(" missing to vertex ");
- }
- System.out.println("DEBUG - null entry for [" + edLab + "] between " + sb.toString());
- continue;
- }
- derivedEdgeKey = edgeRuleLabelToKeyHash.get(edLab).toString();
- }
-
- if( edgeRuleHash.containsKey(derivedEdgeKey) ){
- // this is an edge that we want to update
- System.out.print("DEBUG - key = " + derivedEdgeKey + ", label = " + edLab
- + ", for id = " + tmpEd.id().toString() + ", set: ");
- Map<String,EdgeRule> edgeRules = getEdgeTagPropPutHash(TRANSID, FROMAPPID, derivedEdgeKey);
- for (String key : edgeRules.keySet()) {
- if (tmpEd.label().equals(key)) {
- EdgeRules.getInstance().addProperties(tmpEd, edgeRules.get(key));
- }
- }
- System.out.print("\n");
- }
- } // End of looping over all edges
- graph.tx().commit();
- System.out.println("DEBUG - committed updates for listed edges " );
- }
- catch (Exception e2) {
- String msg = e2.toString();
- System.out.println(msg);
- e2.printStackTrace();
- if( graph != null ){
- graph.tx().rollback();
- }
+ String edgeRuleKeyVal = args[0];
+
+ try {
+ UpdateEdgeTagsCmd edgeOp = new UpdateEdgeTagsCmd(edgeRuleKeyVal);
+ edgeOp.execute();
+ } catch (AAIException e) {
+ e.printStackTrace();
+ } finally {
AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
-
- AAISystemExitUtil.systemExitCloseAAIGraph(0);
}// end of main()
-
-
- /**
- * Derive edge rule key for this edge.
- *
- * @param transId the trans id
- * @param fromAppId the from app id
- * @param graph the graph
- * @param tEdge the t edge
- * @return String - key to look up edgeRule (fromNodeType|toNodeType)
- * @throws AAIException the AAI exception
- */
- public static String deriveEdgeRuleKeyForThisEdge( String transId, String fromAppId, Graph graph,
- Edge tEdge ) throws AAIException {
-
- Vertex fromVtx = tEdge.outVertex();
- Vertex toVtx = tEdge.inVertex();
- String startNodeType = fromVtx.<String>property("aai-node-type").orElse(null);
- String targetNodeType = toVtx.<String>property("aai-node-type").orElse(null);
- String key = startNodeType + "|" + targetNodeType;
- if( EdgeRules.getInstance().hasEdgeRule(startNodeType, targetNodeType) ){
- // We can use the node info in the order they were given
- return( key );
- }
- else {
- key = targetNodeType + "|" + startNodeType;
- if( EdgeRules.getInstance().hasEdgeRule(targetNodeType, startNodeType) ){
- return( key );
- }
- else {
- // Couldn't find a rule for this edge
- throw new AAIException("AAI_6120", "No EdgeRule found for passed nodeTypes: " + startNodeType + ", "
- + targetNodeType);
- }
- }
- }// end of deriveEdgeRuleKeyForThisEdge()
-
-
- /**
- * Gets the edge tag prop put hash.
- *
- * @param transId the trans id
- * @param fromAppId the from app id
- * @param edgeRuleKey the edge rule key
- * @return the edge tag prop put hash
- * @throws AAIException the AAI exception
- */
- public static Map<String, EdgeRule> getEdgeTagPropPutHash(String transId, String fromAppId, String edgeRuleKey )
- throws AAIException {
- // For a given edgeRuleKey (nodeTypeA|nodeTypeB), look up the rule that goes with it in
- // DbEdgeRules.EdgeRules and parse out the "tags" that need to be set on each edge.
- // These are the Boolean properties like, "isParent", "usesResource" etc.
- // Note - this code is also used by the updateEdgeTags.java code
-
- String[] edgeRuleKeys = edgeRuleKey.split("\\|");
-
- if (edgeRuleKeys.length < 2 || ! EdgeRules.getInstance().hasEdgeRule(edgeRuleKeys[0], edgeRuleKeys[1])) {
- throw new AAIException("AAI_6120", "Could not find an DbEdgeRule entry for passed edgeRuleKey (nodeTypeA|nodeTypeB): " + edgeRuleKey + ".");
- }
-
- Map<String, EdgeRule> edgeRules = EdgeRules.getInstance().getEdgeRules(edgeRuleKeys[0], edgeRuleKeys[1]);
-
- return edgeRules;
-
- } // End of getEdgeTagPropPutHash()
-
}
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/tags/Command.java b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/Command.java
new file mode 100644
index 0000000..bc18047
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/Command.java
@@ -0,0 +1,25 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.dbgen.tags;
+
+@FunctionalInterface
+interface Command {
+ public abstract void execute() throws Exception;
+}
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
new file mode 100644
index 0000000..d1ee6c4
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java
@@ -0,0 +1,212 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.dbgen.tags;
+
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.serialization.db.EdgeRule;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+
+public class UpdateEdgeTagsCmd implements Command {
+ private JanusGraph graph;
+ private String rulesFilename;
+ private EdgeRules edgeRulesInstance = null;
+ private String[] edgeRuleKeys = null;
+
+ private String filter = "all";
+ private static final String FROMAPPID = "AAI-DB";
+ private static final String TRANSID = UUID.randomUUID().toString();
+
+
+ static final Logger logger = LoggerFactory.getLogger(UpdateEdgeTagsCmd.class);
+
+ /**
+ * @param filter
+ */
+ public UpdateEdgeTagsCmd(String filter) throws AAIException {
+ super();
+ this.filter = filter;
+ createEdgeRuleSet();
+ }
+
+ /**
+ * @param filter
+ * @param rulesFilename
+ */
+ public UpdateEdgeTagsCmd(String filter, String rulesFilename) {
+ super();
+ this.rulesFilename = rulesFilename;
+ this.filter = filter;
+ this.createEdgeRuleSet();
+ }
+
+ @Override
+ public void execute() throws AAIException {
+ try {
+ ErrorLogHelper.loadProperties();
+ if(graph == null) {
+ AAIConfig.init();
+ logger.info(" ---- NOTE --- about to open graph (takes a little while)--------\n");
+ graph = AAIGraph.getInstance().getGraph();
+ }
+ if( graph == null ){
+ String emsg = "null graph object in updateEdgeTags() \n";
+ logger.info(emsg);
+ return;
+ }
+ }
+ catch (AAIException e1) {
+ String msg = e1.getErrorObject().toString();
+ System.out.println(msg);
+ return;
+ }
+ catch (Exception e2) {
+ String msg = e2.toString();
+ System.out.println(msg);
+ e2.printStackTrace();
+ return;
+ }
+
+ Graph g = graph.newTransaction();
+ try {
+ Iterator<Edge> edgeItr = graph.traversal().E();
+/*
+ if("all".equalsIgnoreCase(filter)) {
+ edgeItr = graph.traversal().E();
+ } else {
+ edgeItr = graph.traversal().E()..inV().property("aai-node-type",this.edgeRuleKeys[0]);
+ edgeItr = graph.traversal().E().inV().has("aai-node-type").values(this.edgeRuleKeys[0]).outV().has("aai-node-type").values(this.edgeRuleKeys[1]);
+ }
+*/
+ //Iterate over all the edges of the in memory graph
+ while( edgeItr != null && edgeItr.hasNext() ){
+
+ Edge thisEdge = edgeItr.next();
+ //The filter can limit the application of changes to edges between vertices of one pair of node-types
+ //Other node type pairs found in in-memory graph are skipped
+ if(! passesFilter(thisEdge) ) {
+ continue;
+ }
+
+ //Find the rules in the file between the node-type pair for the current in-memory edge
+ if( edgeRulesInstance.hasEdgeRule(thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.outVertex().<String>property("aai-node-type").orElse(null))) {
+ logger.info("key = " + thisEdge.inVertex().<String>property("aai-node-type").orElse(null)+"|"+ thisEdge.outVertex().<String>property("aai-node-type").orElse(null)+ ", label = " + thisEdge.label()
+ + ", for id = " + thisEdge.id().toString() + ", set: "+thisEdge.keys()+"\n");
+ //Get the rule map from the FILE for the node-type pair, filtered by label found on the in-memory Edge; expecting one rule
+ //Note: the filter label does not work -- adding equals/contains(thisEdge.label() tests below
+ Map<String, EdgeRule> edgeRules =edgeRulesInstance.getEdgeRules(thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.outVertex().<String>property("aai-node-type").orElse(null), thisEdge.label());
+// Collection<EdgeRule> edgeRules = edgeRuleMultimap.get(derivedEdgeKey);
+ //Apply the Edge properties from the FILE rule to the in-memory Edge
+ for(EdgeRule e : edgeRules.values()) {
+ if(e.getLabel().equals(thisEdge.label())) {
+ logger.info("EdgeRule e: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),e.getLabel()));
+ edgeRulesInstance.addProperties(thisEdge, e);
+ }
+ }
+ //The FILE ruleset is broken? -- run away; discard all changes!
+ if(! edgeRules.containsKey(thisEdge.label())) {
+ // Couldn't find a rule for this edge
+ logger.error("Broken EdgeSet in edgeRuleFile: " + thisEdge.bothVertices());
+ throw new AAIException("AAI_6120", "No EdgeRule found for nodeTypes: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.label()));
+ }
+ } else {
+ //The expected FILE ruleset could not be found -- run away; discard all changes!
+ logger.error("Missing EdgeSet in edgeRuleFile: " + thisEdge.bothVertices());
+ throw new AAIException("AAI_6120", "No EdgeRule found for nodeTypes: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.label()));
+ }
+
+ } // End of looping over all in-memory edges
+ graph.tx().commit();
+ logger.info("- committed updates for listed edges " );
+ }
+ catch (Exception e2) {
+ String msg = e2.toString();
+ logger.error(msg);
+ e2.printStackTrace();
+ if( g != null ){
+ graph.tx().rollback();
+ }
+ if(e2 instanceof AAIException) {
+ throw e2;
+ }
+ return;
+ }
+ }
+
+
+ /**
+ * @return the rulesFilename
+ */
+ public String getRulesFilename() {
+ return this.rulesFilename;
+ }
+
+ /**
+ * @return the graph
+ */
+ public JanusGraph getGraph() {
+ return this.graph;
+ }
+
+ /**
+ * @param graph the graph to set
+ */
+ public void setGraph(JanusGraph graph) {
+ this.graph = graph;
+ }
+
+ private void createEdgeRuleSet() {
+ if(this.filter != null) this.edgeRuleKeys = filter.split("\\|");
+ edgeRulesInstance = (this.rulesFilename == null) ? EdgeRules.getInstance() : EdgeRules.getInstance(rulesFilename);
+ return;
+ }
+
+ private boolean passesFilter(Edge tEdge) {
+ if("all".equalsIgnoreCase(filter) ) {
+ logger.debug("EdgeRule PROCESSALL: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label()));
+ return true;
+ }
+ Iterator<Vertex> vItr = tEdge.bothVertices();
+
+ ArrayList<String> l = new ArrayList<String>(Arrays.asList(edgeRuleKeys));
+ while( vItr != null && vItr.hasNext() ) {
+ Vertex v = vItr.next();
+ int i = l.indexOf(v.property("aai-node-type").value());
+ if (i >= 0) l.remove(i);
+ }
+ if(l.isEmpty()) {
+ logger.debug("EdgeRule filterPROCESS: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label()));
+ }
+ else {
+ logger.debug("EdgeRule filterSKIP: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label()));
+ }
+ return l.isEmpty();
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java
new file mode 100644
index 0000000..3ce5669
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java
@@ -0,0 +1,285 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.javatuples.Pair;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A migration template for "swinging" edges that terminate on an old-node to a new target node.
+ * That is, given an oldNode and a newNode we will swing edges that terminate on the
+ * oldNode and terminate them on the newNode (actually we drop the old edges and add new ones).
+ *
+ *
+ * We allow the passing of some parameters to restrict what edges get swung over:
+ * > otherEndNodeTypeRestriction: only swing edges that terminate on the oldNode if the
+ * node at the other end of the edge is of this nodeType.
+ * > edgeLabelRestriction: Only swing edges that have this edgeLabel
+ * > edgeDirectionRestriction: Only swing edges that go this direction (from the oldNode)
+ * this is a required parameter. valid values are: BOTH, IN, OUT
+ *
+ */
+@MigrationPriority(0)
+@MigrationDangerRating(1)
+public abstract class EdgeSwingMigrator extends Migrator {
+
+ private boolean success = true;
+ private String nodeTypeRestriction = null;
+ private String edgeLabelRestriction = null;
+ private String edgeDirRestriction = null;
+ private List<Pair<Vertex, Vertex>> nodePairList;
+
+
+ public EdgeSwingMigrator(TransactionalGraphEngine engine ) {
+ super(engine);
+ }
+
+
+ /**
+ * Do not override this method as an inheritor of this class
+ */
+ @Override
+ public void run() {
+ executeModifyOperation();
+ cleanupAsAppropriate(this.nodePairList);
+ }
+
+ /**
+ * This is where inheritors should add their logic
+ */
+ protected void executeModifyOperation() {
+
+ try {
+ this.nodeTypeRestriction = this.getNodeTypeRestriction();
+ this.edgeLabelRestriction = this.getEdgeLabelRestriction();
+ this.edgeDirRestriction = this.getEdgeDirRestriction();
+ nodePairList = this.getAffectedNodePairs();
+ for (Pair<Vertex, Vertex> nodePair : nodePairList) {
+ Vertex fromNode = nodePair.getValue0();
+ Vertex toNode = nodePair.getValue1();
+ this.swingEdges(fromNode, toNode,
+ this.nodeTypeRestriction,this.edgeLabelRestriction,this.edgeDirRestriction);
+ }
+ } catch (Exception e) {
+ logger.error("error encountered", e);
+ success = false;
+ }
+ }
+
+
+ protected void swingEdges(Vertex oldNode, Vertex newNode, String nodeTypeRestr, String edgeLabelRestr, String edgeDirRestr) {
+ try {
+ // If the old and new Vertices aren't populated, throw an exception
+ if( oldNode == null ){
+ logger.info ( "null oldNode passed to swingEdges() ");
+ success = false;
+ return;
+ }
+ else if( newNode == null ){
+ logger.info ( "null newNode passed to swingEdges() ");
+ success = false;
+ return;
+ }
+ else if( edgeDirRestr == null ||
+ (!edgeDirRestr.equals("BOTH")
+ && !edgeDirRestr.equals("IN")
+ && !edgeDirRestr.equals("OUT") )
+ ){
+ logger.info ( "invalid direction passed to swingEdges(). valid values are BOTH/IN/OUT ");
+ success = false;
+ return;
+ }
+ else if( edgeLabelRestr != null
+ && (edgeLabelRestr.trim().equals("none") || edgeLabelRestr.trim().equals("")) ){
+ edgeLabelRestr = null;
+ }
+ else if( nodeTypeRestr == null || nodeTypeRestr.trim().equals("") ){
+ nodeTypeRestr = "none";
+ }
+
+ String oldNodeType = oldNode.value(AAIProperties.NODE_TYPE);
+ String oldUri = oldNode.<String> property("aai-uri").isPresent() ? oldNode.<String> property("aai-uri").value() : "URI Not present";
+
+ String newNodeType = newNode.value(AAIProperties.NODE_TYPE);
+ String newUri = newNode.<String> property("aai-uri").isPresent() ? newNode.<String> property("aai-uri").value() : "URI Not present";
+
+ // If the nodeTypes don't match, throw an error
+ if( !oldNodeType.equals(newNodeType) ){
+ logger.info ( "Can not swing edge from a [" + oldNodeType + "] node to a [" +
+ newNodeType + "] node. ");
+ success = false;
+ return;
+ }
+
+ // Find and migrate any applicable OUT edges.
+ if( edgeDirRestr.equals("BOTH") || edgeDirRestr.equals("OUT") ){
+ Iterator <Edge> edgeOutIter = null;
+ if( edgeLabelRestr == null ) {
+ edgeOutIter = oldNode.edges(Direction.OUT);
+ }
+ else {
+ edgeOutIter = oldNode.edges(Direction.OUT, edgeLabelRestr);
+ }
+
+ while( edgeOutIter.hasNext() ){
+ Edge oldOutE = edgeOutIter.next();
+ String eLabel = oldOutE.label();
+ Vertex otherSideNode4ThisEdge = oldOutE.inVertex();
+ String otherSideNodeType = otherSideNode4ThisEdge.value(AAIProperties.NODE_TYPE);
+ if( nodeTypeRestr.equals("none") || nodeTypeRestr.toLowerCase().equals(otherSideNodeType) ){
+ Iterator <Property<Object>> propsIter = oldOutE.properties();
+ HashMap<String, String> propMap = new HashMap<String,String>();
+ while( propsIter.hasNext() ){
+ Property<Object> ep = propsIter.next();
+ propMap.put(ep.key(), ep.value().toString());
+ }
+
+ String otherSideUri = otherSideNode4ThisEdge.<String> property("aai-uri").isPresent() ? otherSideNode4ThisEdge.<String> property("aai-uri").value() : "URI Not present";
+ logger.info ( "\nSwinging [" + eLabel + "] OUT edge. \n >> Unchanged side is ["
+ + otherSideNodeType + "][" + otherSideUri + "] \n >> Edge used to go to [" + oldNodeType
+ + "][" + oldUri + "],\n >> now swung to [" + newNodeType + "][" + newUri + "]. ");
+ // remove the old edge
+ oldOutE.remove();
+
+ // add the new edge with properties that match the edge that was deleted. We don't want to
+ // change any edge properties - just swinging one end of the edge to a new node.
+ // NOTE - addEdge adds an OUT edge to the vertex passed as a parameter, so we are
+ // adding from the newNode side.
+ Edge newOutE = newNode.addEdge(eLabel, otherSideNode4ThisEdge);
+
+ Iterator it = propMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry pair = (Map.Entry)it.next();
+ newOutE.property(pair.getKey().toString(), pair.getValue().toString() );
+ }
+
+ }
+ }
+ }
+
+ // Find and migrate any applicable IN edges.
+ if( edgeDirRestr.equals("BOTH") || edgeDirRestr.equals("IN") ){
+ Iterator <Edge> edgeInIter = null;
+ if( edgeLabelRestr == null ) {
+ edgeInIter = oldNode.edges(Direction.IN);
+ }
+ else {
+ edgeInIter = oldNode.edges(Direction.IN, edgeLabelRestr);
+ }
+
+ while( edgeInIter.hasNext() ){
+ Edge oldInE = edgeInIter.next();
+ String eLabel = oldInE.label();
+ Vertex otherSideNode4ThisEdge = oldInE.outVertex();
+ String otherSideNodeType = otherSideNode4ThisEdge.value(AAIProperties.NODE_TYPE);
+ if( nodeTypeRestr.equals("none") || nodeTypeRestr.toLowerCase().equals(otherSideNodeType) ){
+ Iterator <Property<Object>> propsIter = oldInE.properties();
+ HashMap<String, String> propMap = new HashMap<String,String>();
+ while( propsIter.hasNext() ){
+ Property<Object> ep = propsIter.next();
+ propMap.put(ep.key(), ep.value().toString());
+ }
+
+ String otherSideUri = otherSideNode4ThisEdge.<String> property("aai-uri").isPresent() ? otherSideNode4ThisEdge.<String> property("aai-uri").value() : "URI Not present";
+ logger.info ( "\nSwinging [" + eLabel + "] IN edge. \n >> Unchanged side is ["
+ + otherSideNodeType + "][" + otherSideUri + "] \n >> Edge used to go to [" + oldNodeType
+ + "][" + oldUri + "],\n >> now swung to [" + newNodeType + "][" + newUri + "]. ");
+
+ // remove the old edge
+ oldInE.remove();
+
+ // add the new edge with properties that match the edge that was deleted. We don't want to
+ // change any edge properties - just swinging one end of the edge to a new node.
+ // NOTE - addEdge adds an OUT edge to the vertex passed as a parameter, so we are
+ // adding from the node on the other-end of the original edge so we'll get
+ // an IN-edge to the newNode.
+ Edge newInE = otherSideNode4ThisEdge.addEdge(eLabel, newNode);
+
+ Iterator it = propMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry pair = (Map.Entry)it.next();
+ newInE.property(pair.getKey().toString(), pair.getValue().toString() );
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ logger.error("error encountered", e);
+ success = false;
+ }
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+
+ /**
+ * Get the List of node pairs("from" and "to"), you would like EdgeSwingMigrator to migrate from json files
+ * @return
+ */
+ public abstract List<Pair<Vertex, Vertex>> getAffectedNodePairs() ;
+
+
+ /**
+ * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use
+ * @return
+ */
+ public abstract String getNodeTypeRestriction() ;
+
+
+ /**
+ * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use
+ * @return
+ */
+ public abstract String getEdgeLabelRestriction() ;
+
+ /**
+ * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use
+ * @return
+ */
+ public abstract String getEdgeDirRestriction() ;
+
+
+
+ /**
+ * Cleanup (remove) the nodes that edges were moved off of if appropriate
+ * @return
+ */
+ public abstract void cleanupAsAppropriate(List<Pair<Vertex, Vertex>> nodePairL);
+
+} \ No newline at end of file
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
index a2baa5a..62007c4 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
@@ -49,7 +49,7 @@ import org.onap.aai.introspection.Version;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConstants;
import org.onap.aai.util.FormatDate;
@@ -113,7 +113,7 @@ public class MigrationControllerInternal {
} catch (ConfigurationException e) {
LoggingContext.statusCode(StatusCode.ERROR);
LoggingContext.responseCode(LoggingContext.DATA_ERROR);
- logAndPrint("ERROR: Could not load titan configuration.\n" + ExceptionUtils.getFullStackTrace(e));
+ logAndPrint("ERROR: Could not load janusgraph configuration.\n" + ExceptionUtils.getFullStackTrace(e));
return;
}
}
@@ -126,7 +126,7 @@ public class MigrationControllerInternal {
QueryStyle queryStyle = QueryStyle.TRAVERSAL;
ModelType introspectorFactoryType = ModelType.MOXY;
Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- TransactionalGraphEngine engine = new TitanDBEngine(queryStyle, DBConnectionType.REALTIME, loader);
+ TransactionalGraphEngine engine = new JanusGraphDBEngine(queryStyle, DBConnectionType.REALTIME, loader);
if (cArgs.help) {
jCommander.usage();
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
index d5c3ca4..ed43724 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
@@ -27,9 +27,9 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.Cardinality;
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.schema.JanusGraphManagement;
/**
* A migration template for migrating a property from one name to another
@@ -42,7 +42,7 @@ public abstract class PropertyMigrator extends Migrator {
protected final String NEW_FIELD;
protected final Class<?> fieldType;
protected final Cardinality cardinality;
- protected final TitanManagement graphMgmt;
+ protected final JanusGraphManagement graphMgmt;
public PropertyMigrator(TransactionalGraphEngine engine, String oldName, String newName, Class<?> type, Cardinality cardinality) {
super(engine);
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java
new file mode 100644
index 0000000..eb562a2
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java
@@ -0,0 +1,100 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+import java.util.Map;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.janusgraph.core.schema.JanusGraphManagement;
+
+/**
+ * A migration template for filling in default values that are missing or are empty
+ */
+@MigrationPriority(0)
+@MigrationDangerRating(1)
+public abstract class ValueMigrator extends Migrator {
+
+ protected final Map<String, Map<String, ?>> propertyValuePairByNodeType;
+ protected final Boolean updateExistingValues;
+ protected final JanusGraphManagement graphMgmt;
+
+ /**
+ *
+ * @param engine
+ * @param propertyValuePairByNodeType - format {nodeType: { property: newValue}}
+ * @param updateExistingValues - if true, updates the value regardless if it already exists
+ */
+ public ValueMigrator(TransactionalGraphEngine engine, Map propertyValuePairByNodeType, Boolean updateExistingValues) {
+ super(engine);
+ this.propertyValuePairByNodeType = propertyValuePairByNodeType;
+ this.updateExistingValues = updateExistingValues;
+ this.graphMgmt = engine.asAdmin().getManagementSystem();
+ }
+
+ /**
+ * Do not override this method as an inheritor of this class
+ */
+ @Override
+ public void run() {
+ updateValues();
+ }
+
+ protected void updateValues() {
+ for (Map.Entry<String, Map<String, ?>> entry: propertyValuePairByNodeType.entrySet()) {
+ String nodeType = entry.getKey();
+ Map<String, ?> propertyValuePair = entry.getValue();
+ for (Map.Entry<String, ?> pair : propertyValuePair.entrySet()) {
+ String property = pair.getKey();
+ Object newValue = pair.getValue();
+ try {
+ GraphTraversal<Vertex, Vertex> g = this.engine.asAdmin().getTraversalSource().V()
+ .has(AAIProperties.NODE_TYPE, nodeType);
+ while (g.hasNext()) {
+ Vertex v = g.next();
+ if (v.property(property).isPresent() && !updateExistingValues) {
+ String propertyValue = v.property(property).value().toString();
+ if (propertyValue.isEmpty()) {
+ v.property(property, newValue);
+ logger.info(String.format("Node Type %s: Property %s is empty, adding value %s",
+ nodeType, property, newValue.toString()));
+ this.touchVertexProperties(v, false);
+ } else {
+ logger.info(String.format("Node Type %s: Property %s value already exists - skipping",
+ nodeType, property));
+ }
+ } else {
+ logger.info(String.format("Node Type %s: Property %s does not exist or " +
+ "updateExistingValues flag is set to True - adding the property with value %s",
+ nodeType, property, newValue.toString()));
+ v.property(property, newValue);
+ this.touchVertexProperties(v, false);
+ }
+ }
+ } catch (Exception e) {
+ logger.error(String.format("caught exception updating aai-node-type %s's property %s's value to " +
+ "%s: %s", nodeType, property, newValue.toString(), e.getMessage()));
+ logger.error(e.getMessage());
+ }
+ }
+ }
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java
index d3d0564..2ff916c 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java
@@ -18,26 +18,6 @@
* ============LICENSE_END=========================================================
*/
package org.onap.aai.migration.v12;
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java
new file mode 100644
index 0000000..57e3e5e
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java
@@ -0,0 +1,254 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.migration.*;
+import org.onap.aai.serialization.db.EdgeType;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.*;
+
+@MigrationPriority(1)
+@MigrationDangerRating(1)
+@Enabled
+public class SDWANSpeedChangeMigration extends Migrator {
+
+ private final String PARENT_NODE_TYPE = "alloted-resource";
+ private boolean success = true;
+
+ Vertex allottedRsrcVertex;
+
+ Map<String, String> bandwidthMap = new HashMap<>();
+ Set<String> bandWidthSet = new HashSet<>();
+
+ GraphTraversal<Vertex, Vertex> allottedRsrcTraversal;
+ GraphTraversal<Vertex, Vertex> tunnelXConnectTraversal;
+ GraphTraversal<Vertex, Vertex> pinterfaceTraversal;
+ GraphTraversal<Vertex, Vertex> plinkTraversal;
+
+ public SDWANSpeedChangeMigration(TransactionalGraphEngine engine) {
+ super(engine);
+ bandWidthSet.add("bandwidth-up-wan1");
+ bandWidthSet.add("bandwidth-down-wan1");
+ bandWidthSet.add("bandwidth-up-wan2");
+ bandWidthSet.add("bandwidth-down-wan2");
+ }
+
+
+ @Override
+ public void run() {
+
+ logger.info("Started the migration "+ getMigrationName());
+
+ try {
+
+ allottedRsrcTraversal = this.engine.asAdmin().getTraversalSource().V()
+ .has("aai-node-type", "service-subscription")
+ .has("service-type", "DHV")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-instance")
+ .out("org.onap.relationships.inventory.Uses")
+ .has("aai-node-type", "allotted-resource")
+ .where(
+ this.engine.getQueryBuilder()
+ .createEdgeTraversal(EdgeType.TREE, "allotted-resource", "service-instance")
+ .createEdgeTraversal(EdgeType.TREE, "service-instance", "service-subscription")
+ .<GraphTraversal<Vertex, Vertex>>getQuery()
+ .has("service-type", "VVIG")
+ );
+
+ if(!(allottedRsrcTraversal.hasNext())){
+
+ logger.info("unable to find allotted resource to DHV as cousin and child of VVIG");
+ }
+
+ while (allottedRsrcTraversal.hasNext()) {
+ bandwidthMap.clear();
+
+ allottedRsrcVertex = allottedRsrcTraversal.next();
+ String allottedResourceId = allottedRsrcVertex.property("id").value().toString();
+ logger.info("Found an allotted resource with id " + allottedResourceId);
+
+ tunnelXConnectTraversal = this.engine.asAdmin().getTraversalSource()
+ .V(allottedRsrcVertex)
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "tunnel-xconnect");
+
+ if (tunnelXConnectTraversal != null && tunnelXConnectTraversal.hasNext()) {
+ Vertex xConnect = tunnelXConnectTraversal.next();
+ String tunnelId = xConnect.property("id").value().toString();
+ logger.info("Found an tunnelxconnect object with id " + tunnelId);
+ extractBandwidthProps(xConnect);
+ modifyPlink(allottedRsrcVertex);
+ } else {
+ logger.info("Unable to find the tunnel connect for the current allotted resource traversal");
+ }
+
+ }
+ } catch (AAIException e) {
+ e.printStackTrace();
+ success = false;
+ }
+
+ logger.info("Successfully finished the " + getMigrationName());
+ }
+
+ public void extractBandwidthProps(Vertex vertex) {
+ logger.info("Trying to extract bandwith props");
+ bandWidthSet.stream().forEach((key) -> {
+ if (vertex.property(key).isPresent()) {
+ bandwidthMap.put(key, vertex.property(key).value().toString());
+ }
+ });
+ logger.info("Extracted bandwith props for tunnelXConnect " +vertex.value("id"));
+ }
+
+ public void modifyPlink(Vertex v) {
+
+ try {
+ pinterfaceTraversal = this.engine.asAdmin().getTraversalSource().V(v)
+ .in("org.onap.relationships.inventory.Uses").has("aai-node-type", "service-instance")
+ .where(
+ __.out("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "service-subscription")
+ .has("service-type", "DHV")
+ )
+ .out("org.onap.relationships.inventory.ComposedOf").has("aai-node-type", "generic-vnf")
+ .out("tosca.relationships.HostedOn").has("aai-node-type", "vserver")
+ .out("tosca.relationships.HostedOn").has("aai-node-type", "pserver")
+ .in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface");
+ } catch (Exception e) {
+ logger.info("error trying to find p interfaces");
+ }
+
+
+ while (pinterfaceTraversal.hasNext()) {
+
+ Vertex pInterfaceVertex = pinterfaceTraversal.next();
+
+ String pinterfaceName = pInterfaceVertex.property("interface-name").value().toString();
+ logger.info("p-interface "+ pinterfaceName + " found from traversal from allotted-resource " +v.value("id"));
+ String[] parts = pinterfaceName.split("/");
+
+ if (parts[parts.length - 1].equals("10")) {
+
+ logger.info("Found the pinterface with the interface name ending with /10");
+
+ try {
+ plinkTraversal = this.engine.asAdmin().getTraversalSource()
+ .V(pInterfaceVertex)
+ .out("tosca.relationships.network.LinksTo")
+ .has("aai-node-type", "physical-link");
+ } catch (Exception e) {
+ logger.info("error trying to find the p Link for /10");
+ }
+ if (plinkTraversal != null && plinkTraversal.hasNext()) {
+ Vertex pLink = plinkTraversal.next();
+
+
+ if ( bandwidthMap.containsKey("bandwidth-up-wan1")
+ && bandwidthMap.containsKey("bandwidth-down-wan1")
+ && !(("").equals(bandwidthMap.get("bandwidth-up-wan1").replaceAll("[^0-9]", "").trim()))
+ && !(("").equals(bandwidthMap.get("bandwidth-down-wan1").replaceAll("[^0-9]", "").trim())))
+ {
+
+ pLink.property("service-provider-bandwidth-up-value", Integer.valueOf(bandwidthMap.get("bandwidth-up-wan1").replaceAll("[^0-9]", "").trim()));
+ pLink.property("service-provider-bandwidth-up-units", "Mbps");
+ pLink.property("service-provider-bandwidth-down-value", Integer.valueOf(bandwidthMap.get("bandwidth-down-wan1").replaceAll("[^0-9]", "").trim()));
+ pLink.property("service-provider-bandwidth-down-units", "Mbps");
+ logger.info("Successfully modified the plink with link name ", pLink.property("link-name").value().toString());
+ this.touchVertexProperties(pLink, false);
+ } else {
+ logger.info("missing up and down vals for the plink with link name ", pLink.property("link-name").value().toString());
+ }
+
+
+ } else {
+ logger.info("missing plink for p interface" + pinterfaceName);
+ }
+
+ }
+
+ if (parts[parts.length - 1].equals("11")) {
+
+ logger.info("Found the pinterface with the interface name ending with /11");
+ try {
+ plinkTraversal = this.engine.asAdmin()
+ .getTraversalSource()
+ .V(pInterfaceVertex)
+ .out("tosca.relationships.network.LinksTo")
+ .has("aai-node-type", "physical-link");
+ } catch (Exception e) {
+ logger.info("error trying to find the p Link for /11");
+ }
+
+ if (plinkTraversal != null && plinkTraversal.hasNext()) {
+ Vertex pLink = plinkTraversal.next();
+
+
+ if ( bandwidthMap.containsKey("bandwidth-up-wan2")
+ && bandwidthMap.containsKey("bandwidth-down-wan2")
+ && !(("").equals(bandwidthMap.get("bandwidth-up-wan2").replaceAll("[^0-9]", "").trim()))
+ && !(("").equals(bandwidthMap.get("bandwidth-down-wan2").replaceAll("[^0-9]", "").trim())))
+ {
+ pLink.property("service-provider-bandwidth-up-value", Integer.valueOf(bandwidthMap.get("bandwidth-up-wan2").replaceAll("[^0-9]", "").trim()));
+ pLink.property("service-provider-bandwidth-up-units", "Mbps");
+ pLink.property("service-provider-bandwidth-down-value", Integer.valueOf(bandwidthMap.get("bandwidth-down-wan2").replaceAll("[^0-9]", "").trim()));
+ pLink.property("service-provider-bandwidth-down-units", "Mbps");
+ logger.info("Successfully modified the plink with link name ", pLink.property("link-name").value().toString());
+ this.touchVertexProperties(pLink, false);
+ } else {
+ logger.error("missing up and down vals for the plink with link name ", pLink.property("link-name").value().toString());
+ }
+
+ } else {
+ logger.info("missing plink for p interface" + pinterfaceName);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+
+ return Optional.of(new String[]{PARENT_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "SDWANSpeedChangeMigration";
+ }
+
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java
index a409710..91ca4d7 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java
@@ -18,26 +18,6 @@
* ============LICENSE_END=========================================================
*/
package org.onap.aai.migration.v12;
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
import java.util.*;
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java
new file mode 100644
index 0000000..feb8a6a
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java
@@ -0,0 +1,59 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+import java.util.Optional;
+
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.PropertyMigrator;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.Cardinality;
+
+@MigrationPriority(20)
+@MigrationDangerRating(2)
+@Enabled
+public class MigrateInstanceGroupSubType extends PropertyMigrator{
+
+ protected static final String SUB_TYPE_PROPERTY = "sub-type";
+ protected static final String INSTANCE_GROUP_ROLE_PROPERTY = "instance-group-role";
+ protected static final String INSTANCE_GROUP_NODE_TYPE = "instance-group";
+
+ public MigrateInstanceGroupSubType(TransactionalGraphEngine engine) {
+ super(engine,SUB_TYPE_PROPERTY , INSTANCE_GROUP_ROLE_PROPERTY, String.class,Cardinality.SINGLE);
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{INSTANCE_GROUP_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MigrateInstanceGroupSubType";
+ }
+
+ @Override
+ public boolean isIndexed() {
+ return true;
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java
new file mode 100644
index 0000000..dc55b40
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java
@@ -0,0 +1,59 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+import java.util.Optional;
+
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.PropertyMigrator;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.Cardinality;
+
+@MigrationPriority(20)
+@MigrationDangerRating(2)
+@Enabled
+public class MigrateInstanceGroupType extends PropertyMigrator{
+
+ protected static final String TYPE_PROPERTY = "type";
+ protected static final String INSTANCE_GROUP_TYPE_PROPERTY = "instance-group-type";
+ protected static final String INSTANCE_GROUP_NODE_TYPE = "instance-group";
+
+ public MigrateInstanceGroupType(TransactionalGraphEngine engine) {
+ super(engine,TYPE_PROPERTY , INSTANCE_GROUP_TYPE_PROPERTY, String.class,Cardinality.SINGLE);
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{INSTANCE_GROUP_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MigrateInstanceGroupType";
+ }
+
+ @Override
+ public boolean isIndexed() {
+ return true;
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
index 072a602..f423eba 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
@@ -115,7 +115,7 @@ public class URLFromVertexIdConsumer extends RESTAPI {
} catch (Exception e) {
AAIException ex = new AAIException("AAI_4000", e);
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
- } finally { //to close the titan transaction (I think)
+ } finally { //to close the janusgraph transaction (I think)
if (dbEngine != null) {
dbEngine.rollback();
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
index fc54bca..3d90b64 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
@@ -134,7 +134,7 @@ public class VertexIdConsumer extends RESTAPI {
} catch (Exception e) {
AAIException ex = new AAIException("AAI_4000", e);
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
- } finally { //to close the titan transaction (I think)
+ } finally { //to close the janusgraph transaction (I think)
if (dbEngine != null) {
dbEngine.rollback();
}
diff --git a/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml b/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml
index 9addfe3..274ea47 100644
--- a/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml
+++ b/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml
@@ -18,7 +18,7 @@ spec:
volumeMounts:
- name: myservice-properties-volume
mountPath: /etc/config/dynamic
- image: zlp11313.vci.att.com:5100/com.att.ajsc/ajsc6configdemo:latest
+ image: ajsc6configdemo:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
diff --git a/aai-resources/src/main/kubernetes/kubectl.conf b/aai-resources/src/main/kubernetes/kubectl.conf
index da4da58..09e7abb 100644
--- a/aai-resources/src/main/kubernetes/kubectl.conf
+++ b/aai-resources/src/main/kubernetes/kubectl.conf
@@ -3,20 +3,20 @@ apiVersion: v1
clusters:
- cluster:
api-version: v1
- server: https://hlxkvm022.vtil.att.com
+ server: https://aai.org
insecure-skip-tls-verify: true
name: baremetal-ajsc-01
contexts:
- context:
cluster: baremetal-ajsc-01
namespace: org-onap-aai
- user: m93659@ajsc.att.com
+ user: user@example.com
name: baremetal-ajsc-01
kind: Config
preferences:
colors: true
users:
-- name: m93659@ajsc.att.com
+- name: aai@example.com
user:
username: kube
- password: F75I2d9bb16s
+ password: asdjofja
diff --git a/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml b/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml
index 5fcdf9b..ef93d9c 100644
--- a/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml
@@ -91,7 +91,7 @@
<appender-ref ref="createDBSchemametric"/>
<appender-ref ref="STDOUT"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="createDBSchema"/>
<appender-ref ref="createDBSchemadebug"/>
<appender-ref ref="createDBSchemametric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml b/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml
index d899d90..73d72d4 100644
--- a/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml
@@ -88,7 +88,7 @@
<appender-ref ref="dataGroomingdebug"/>
<appender-ref ref="dataGroomingmetric"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="dataGrooming"/>
<appender-ref ref="dataGroomingdebug"/>
<appender-ref ref="dataGroomingmetric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml b/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml
index 9633971..0985f39 100644
--- a/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml
@@ -89,7 +89,7 @@
<appender-ref ref="dataSnapshotmetric"/>
<appender-ref ref="STDOUT"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="dataSnapshot"/>
<appender-ref ref="dataSnapshotdebug"/>
<appender-ref ref="dataSnapshotmetric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/default-logback.xml b/aai-resources/src/main/resources/etc/appprops/default-logback.xml
index 655157b..0b1178c 100644
--- a/aai-resources/src/main/resources/etc/appprops/default-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/default-logback.xml
@@ -33,7 +33,7 @@
<logger name="org.reflections" level="WARN"/>
<logger name="org.apache.zookeeper" level="WARN"/>
<logger name="org.apache.hadoop" level="WARN"/>
- <logger name="com.thinkaurelius" level="WARN"/>
+ <logger name="org.janusgraph" level="WARN"/>
<logger name="ch.qos.logback.classic" level="WARN" />
<logger name="ch.qos.logback.core" level="WARN" />
diff --git a/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml b/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml
index 8c3e977..ae2c7d3 100644
--- a/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml
@@ -39,7 +39,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="dupeToollog" />
</logger>
- <logger name="com.thinkaurelius" level="ERROR" additivity="false">
+ <logger name="org.janusgraph" level="ERROR" additivity="false">
<appender-ref ref="dupeToollog" />
</logger>
<logger name="ch.qos.logback.classic" level="ERROR" additivity="false">
diff --git a/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml b/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml
index 025b49b..3942af0 100644
--- a/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml
@@ -62,7 +62,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="dynamicPayloadGeneratorlog" />
</logger>
- <logger name="com.thinkaurelius" level="ERROR" additivity="false">
+ <logger name="org.janusgraph" level="ERROR" additivity="false">
<appender-ref ref="dynamicPayloadGeneratorlog" />
</logger>
<logger name="ch.qos.logback.classic" level="ERROR" additivity="false">
diff --git a/aai-resources/src/main/resources/etc/appprops/error.properties b/aai-resources/src/main/resources/etc/appprops/error.properties
index d3dbf9f..745f4fb 100644
--- a/aai-resources/src/main/resources/etc/appprops/error.properties
+++ b/aai-resources/src/main/resources/etc/appprops/error.properties
@@ -67,7 +67,7 @@ AAI_5107=5:2:WARN:5107:400:3000:Required information missing
AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored
#--- aaidbgen: 6101-6199
-AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed
+AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed
AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType
AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data
AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data
diff --git a/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml b/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml
index 16ea13c..41d33c1 100644
--- a/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml
@@ -62,7 +62,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="forceDeletelog" />
</logger>
- <logger name="com.thinkaurelius" level="ERROR" additivity="false">
+ <logger name="org.janusgraph" level="ERROR" additivity="false">
<appender-ref ref="forceDeletelog" />
</logger>
<logger name="ch.qos.logback.classic" level="ERROR" additivity="false">
diff --git a/aai-resources/src/main/resources/etc/appprops/getres-logback.xml b/aai-resources/src/main/resources/etc/appprops/getres-logback.xml
index 2a71a22..441f807 100644
--- a/aai-resources/src/main/resources/etc/appprops/getres-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/getres-logback.xml
@@ -88,7 +88,7 @@
<appender-ref ref="getTooldebug"/>
<appender-ref ref="getToolmetric"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="getTool"/>
<appender-ref ref="getTooldebug"/>
<appender-ref ref="getToolmetric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/titan-cached.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
index 3465453..ecd4dbf 100644
--- a/aai-resources/src/main/resources/etc/appprops/titan-cached.properties
+++ b/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
@@ -21,10 +21,12 @@
#
query.fast-property=true
+query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
+#graph.titan-version=1.0.0
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev1.dev
diff --git a/aai-resources/src/main/resources/etc/appprops/titan-realtime.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
index 869872c..cfe8312 100644
--- a/aai-resources/src/main/resources/etc/appprops/titan-realtime.properties
+++ b/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
@@ -21,10 +21,13 @@
#
query.fast-property=true
+query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
+#graph.titan-version=1.0.0
+
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev1.dev
diff --git a/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml b/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml
index cced385..e42128b 100644
--- a/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml
@@ -82,7 +82,7 @@
<appender-ref ref="loadDataForDHVdebug"/>
<appender-ref ref="loadDataForDHVmetric"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="loadDataForDHV"/>
<appender-ref ref="loadDataForDHVdebug"/>
<appender-ref ref="loadDataForDHVmetric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/migration-logback.xml b/aai-resources/src/main/resources/etc/appprops/migration-logback.xml
index 74d3d04..a6dbc1e 100644
--- a/aai-resources/src/main/resources/etc/appprops/migration-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/migration-logback.xml
@@ -62,7 +62,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="migrationlog" />
</logger>
- <logger name="com.thinkaurelius" level="ERROR" additivity="false">
+ <logger name="org.janusgraph" level="ERROR" additivity="false">
<appender-ref ref="migrationlog" />
</logger>
<logger name="ch.qos.logback.classic" level="ERROR" additivity="false">
diff --git a/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml b/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml
index 098e1e7..72c60b8 100644
--- a/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml
@@ -88,7 +88,7 @@
<appender-ref ref="pullInvDatadebug"/>
<appender-ref ref="pullInvDatametric"/>
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="pullInvData"/>
<appender-ref ref="pullInvDatadebug"/>
<appender-ref ref="pullInvDatametric"/>
diff --git a/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml b/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml
index 0762ee1..5a0316f 100644
--- a/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml
@@ -62,7 +62,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="schemaModlog" />
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="schemaModlog" />
</logger>
<logger name="ch.qos.logback.classic" level="WARN" additivity="false">
diff --git a/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml b/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml
index 5f44b1b..5b91003 100644
--- a/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml
+++ b/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml
@@ -62,7 +62,7 @@
<logger name="org.apache.hadoop" level="ERROR" additivity="false">
<appender-ref ref="uniquePropertyChecklog" />
</logger>
- <logger name="com.thinkaurelius" level="WARN" additivity="false">
+ <logger name="org.janusgraph" level="WARN" additivity="false">
<appender-ref ref="uniquePropertyChecklog" />
</logger>
<logger name="ch.qos.logback.classic" level="WARN" additivity="false">
diff --git a/aai-resources/src/main/resources/logback.xml b/aai-resources/src/main/resources/logback.xml
index ee7ee61..e727228 100644
--- a/aai-resources/src/main/resources/logback.xml
+++ b/aai-resources/src/main/resources/logback.xml
@@ -373,7 +373,7 @@
<logger name="org.apache" level="OFF" />
<logger name="org.zookeeper" level="OFF" />
- <logger name="com.thinkaurelius" level="WARN" />
+ <logger name="org.janusgraph" level="WARN" />
<logger name="com.att.aft.dme2" level="WARN" />
<!-- ============================================================================ -->
diff --git a/aai-resources/src/main/scripts/common_functions.sh b/aai-resources/src/main/scripts/common_functions.sh
index 2a908e2..4a34da8 100644
--- a/aai-resources/src/main/scripts/common_functions.sh
+++ b/aai-resources/src/main/scripts/common_functions.sh
@@ -54,3 +54,18 @@ end_date(){
echo
echo `date` " Done $0"
}
+
+# Inserts GEN_DB_WITH_NO_SCHEMA as a paranmter if it isn't there already
+force_GEN_DB_WITH_NO_SCHEMA () {
+ for p in "$@"
+ do
+ if [ "$p" == "GEN_DB_WITH_NO_SCHEMA" ]
+ then
+ echo "$@"
+ return
+ fi
+ done
+ echo "GEN_DB_WITH_NO_SCHEMA $@"
+ return
+}
+
diff --git a/aai-resources/src/main/scripts/createDBSchema.sh b/aai-resources/src/main/scripts/createDBSchema.sh
index 491a89c..00f49ca 100644
--- a/aai-resources/src/main/scripts/createDBSchema.sh
+++ b/aai-resources/src/main/scripts/createDBSchema.sh
@@ -30,7 +30,7 @@
# Ie. createDbSchema.sh GEN_DB_WITH_NO_SCHEMA
#
-COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
+COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
. ${COMMON_ENV_PATH}/common_functions.sh
start_date;
check_user;
diff --git a/aai-resources/src/main/scripts/run_Migrations.sh b/aai-resources/src/main/scripts/run_Migrations.sh
index 1309094..19dda2d 100644
--- a/aai-resources/src/main/scripts/run_Migrations.sh
+++ b/aai-resources/src/main/scripts/run_Migrations.sh
@@ -30,7 +30,7 @@ start_date;
check_user;
source_profile;
-ARGS="-c ${PROJECT_HOME}/resources/etc/appprops/titan-realtime.properties";
+ARGS="-c ${PROJECT_HOME}/resources/etc/appprops/janusgraph-realtime.properties";
if [ -f "$PROJECT_HOME/resources/application.properties" ]; then
# Get the application properties file and look for all lines
diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml
index 5a2712b..f7c46c8 100644
--- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml
+++ b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml
@@ -34,6 +34,15 @@ services:
- LOCAL_GROUP_ID=__LOCAL_GROUP_ID__
volumes:
- /opt/aai/logroot/AAI-RES:/opt/aai/logroot/AAI-RES
+ - /opt/app/aai-resources/appconfig/aai-client-cert.p12:/opt/app/aai-resources/resources/etc/auth/aai-client-cert.p12
+ - /opt/app/aai-resources/appconfig/aai_keystore:/opt/app/aai-resources/resources/etc/auth/aai_keystore
+ - /opt/app/aai-resources/appconfig/aaiconfig.properties:/opt/app/aai-resources/resources/etc/appprops/aaiconfig.properties
+ - /opt/app/aai-resources/appconfig/application.properties:/opt/app/aai-resources/resources/application.properties
+ - /opt/app/aai-resources/appconfig/dme2.properties:/opt/app/aai-resources/resources/dme2.properties
+ - /opt/app/aai-resources/appconfig/localhost-access-logback.xml:/opt/app/aai-resources/resources/localhost-access-logback.xml
+ - /opt/app/aai-resources/appconfig/logback.xml:/opt/app/aai-resources/resources/logback.xml
+ - /opt/app/aai-resources/appconfig/janusgraph-cached.properties:/opt/app/aai-resources/resources/etc/appprops/janusgraph-cached.properties
+ - /opt/app/aai-resources/appconfig/janusgraph-realtime.properties:/opt/app/aai-resources/resources/etc/appprops/janusgraph-realtime.properties
logging:
driver: "json-file"
options:
diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
index 1e3d256..e9e95eb 100644
--- a/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
@@ -21,7 +21,7 @@ package org.onap.aai.dbgen;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.thinkaurelius.titan.core.TitanTransaction;
+import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
@@ -48,7 +48,7 @@ public class DupeToolTest extends AAISetup {
}
private void createGraph() {
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
EdgeRules edgeRules = EdgeRules.getInstance();
@@ -121,7 +121,7 @@ public class DupeToolTest extends AAISetup {
@After
public void tearDown(){
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
boolean success = true;
try {
diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
index f001089..f5b1da4 100644
--- a/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java
@@ -21,7 +21,7 @@ package org.onap.aai.dbgen;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.thinkaurelius.titan.core.TitanTransaction;
+import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -52,7 +52,7 @@ public class ForceDeleteToolTest extends AAISetup {
public void setup(){
deleteTool = new ForceDeleteTool();
deleteTool.SHOULD_EXIT_VM = false;
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
EdgeRules edgeRules = EdgeRules.getInstance();
@@ -137,7 +137,7 @@ public class ForceDeleteToolTest extends AAISetup {
@Test
public void testCollectDataForEdge(){
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
GraphTraversalSource g = transaction.traversal();
List<Edge> edges = g.E().toList();
String cloudRegionToPserverId = edges.get(0).id().toString();
@@ -161,7 +161,7 @@ public class ForceDeleteToolTest extends AAISetup {
InputStream systemInputStream = System.in;
ByteArrayInputStream in = new ByteArrayInputStream("y".getBytes());
System.setIn(in);
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
GraphTraversalSource g = transaction.traversal();
List<Edge> edges = g.E().toList();
String cloudRegionToPserverId = edges.get(0).id().toString();
@@ -182,7 +182,7 @@ public class ForceDeleteToolTest extends AAISetup {
@After
public void tearDown(){
- TitanTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
boolean success = true;
try {
diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java
new file mode 100644
index 0000000..89c4955
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java
@@ -0,0 +1,228 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.dbgen.tags;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.AAIDirection;
+import org.onap.aai.serialization.db.EdgeProperty;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.exceptions.AAIException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Iterator;
+
+public class UpdateEdgeTagsTest extends AAISetup {
+
+ private final static Version version = Version.v12;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private JanusGraph passedGraph;
+ private UpdateEdgeTagsCmd edgeOp;
+ private GraphTraversalSource g;
+ private Graph tx;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ Vertex gvnf = g.addV().property(AAIProperties.NODE_TYPE, "generic-vnf")
+ .property("vnf-id", "test-vnf")
+ .next();
+
+ Vertex lInterface = g.addV().property(AAIProperties.NODE_TYPE, "l-interface")
+ .property("interface-name", "toscaMigration-test-lint")
+ .next();
+
+ Vertex logicalLink = g.addV().property(AAIProperties.NODE_TYPE, "logical-link")
+ .property("link-name", "toscaMigration-logical-link")
+ .next();
+
+
+
+ gvnf.addEdge("hasLInterface", lInterface, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(),
+ EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
+
+ lInterface.addEdge("usesLogicalLink", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(),
+ EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
+ lInterface.addEdge("sourceLInterface", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(),
+ EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
+
+ Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next();
+ Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next();
+ pserver.addEdge("tosca.relationships.HostedOn", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(),
+ EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
+ GraphTraversalSource traversal = g;
+
+ passedGraph = spy(graph);
+ when(passedGraph.traversal()).thenReturn(traversal);
+
+ Iterator<Edge> edgeItr = traversal.E();
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge tEdge = edgeItr.next();
+ String edLab = tEdge.label().toString();
+ System.out.println("key = " + tEdge.inVertex().<String>property("aai-node-type").orElse(null)+"|"+ tEdge.outVertex().<String>property("aai-node-type").orElse(null)+ ", label = " + tEdge.label()
+ + ", for id = " + tEdge.id().toString() + ", set: "+tEdge.keys()+":"+tEdge.values());
+ System.out.println("DEBUG - label = " + edLab);
+ }
+
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void verifyDirectionWasReversed_OriginalGraph() {
+
+ edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json");
+ edgeOp.setGraph(passedGraph);
+ try {
+ edgeOp.execute();
+ } catch (AAIException e) {
+ e.printStackTrace();
+ }
+ Iterator<Edge> edgeItr = g.E();
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge tmpEd = edgeItr.next();
+ System.out.println("Edge = " + tmpEd.inVertex().property("aai-node-type") + ", label = " + tmpEd.label()
+ + ", for id = " + tmpEd.id().toString() +","+tmpEd.keys()+tmpEd.value("contains-other-v"));
+ try {
+ System.out.println("Edge prevent-delete = " +tmpEd.value("prevent-delete"));
+ System.out.println("Edge description = " +tmpEd.value("description"));
+ } catch (Exception e) {;} finally {;}
+ }
+ assertEquals("Graph should have four(4) Edges with contains-other-v=OUT"
+ , Long.valueOf(4)
+ , g.E().has("contains-other-v",AAIDirection.IN.toString()).count().next());
+ assertEquals("Graph should have zero(0) Edges with contains-other-v=NONE"
+ , Long.valueOf(0)
+ , g.E().has("contains-other-v",AAIDirection.NONE.toString()).count().next());
+ }
+
+ @Test
+ public void verifyDirectionWasReversed_withFilter() {
+
+ edgeOp = new UpdateEdgeTagsCmd("vnfc|pserver", "/updateEdgeTestRules.json");
+ edgeOp.setGraph(passedGraph);
+ try {
+ edgeOp.execute();
+ } catch (AAIException e) {
+ e.printStackTrace();
+ }
+ Iterator<Edge> edgeItr = g.E();
+ while( edgeItr != null && edgeItr.hasNext() ){
+ Edge tmpEd = edgeItr.next();
+ System.out.println("Edge = " + tmpEd.inVertex().property("aai-node-type") + ", label = " + tmpEd.label()
+ + ", for id = " + tmpEd.id().toString() +","+tmpEd.keys()+tmpEd.value("contains-other-v"));
+ }
+ assertEquals("Graph should have one(1) Edges with contains-other-v=OUT"
+ , Long.valueOf(1)
+ , g.E().has("contains-other-v",AAIDirection.OUT.toString()).count().next());
+ assertEquals("Graph should have one(1) Edges with contains-other-v=IN"
+ , Long.valueOf(1)
+ , g.E().has("contains-other-v",AAIDirection.IN.toString()).count().next());
+ assertEquals("Graph should have two(2) Edges with contains-other-v=NONE"
+ , Long.valueOf(2)
+ , g.E().has("contains-other-v",AAIDirection.NONE.toString()).count().next());
+ }
+
+ @Test
+ public void verifyFaultyRuleFile_MissingEdgeSpec() throws AAIException {
+
+ thrown.expect(AAIException.class);
+ thrown.expectMessage("No EdgeRule found for nodeTypes: pserver|vnfc|blah");
+
+ Vertex pserver = g.V().has(AAIProperties.NODE_TYPE, "pserver").has("hostname", "a-name").next();
+ Vertex vnfc = g.V().has(AAIProperties.NODE_TYPE,"vnfc").has("vnfc-name","a-name").next();
+ pserver.addEdge("blah", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(),
+ EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
+ //Edge "blah" is not found in updateEdgeTestRules.json
+ edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json");
+ edgeOp.setGraph(passedGraph);
+ edgeOp.execute();
+ }
+
+ @Test
+ public void verifyNewPropertyWasNOTAdded() {
+ //Edge rules in updateEdgeTestRules.json have "description" and "newProperty"
+ // but they don't transfer
+ edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json");
+ edgeOp.setGraph(passedGraph);
+ try {
+ edgeOp.execute();
+ } catch (AAIException e) {
+ e.printStackTrace();
+ }
+ assertEquals("Graph could have zero(4) Edges with newProperty=newValue"
+ , Long.valueOf(0)
+ , g.E().has("newProperty","newValue").count().next());
+ assertEquals("Graph should have one(1) Edge with description=A l-interface/logical-link(1) edge description"
+ , Long.valueOf(0)
+ , g.E().has("description","A l-interface/logical-link(0) edge description").count().next());
+ }
+}
+
+ \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java
new file mode 100644
index 0000000..89da7fa
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java
@@ -0,0 +1,258 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.javatuples.Pair;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.janusgraph.core.schema.JanusGraphManagement;
+
+public class EdgeSwingMigratorTest extends AAISetup {
+
+ private final static Version version = Version.getLatest();
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ private MockEdgeSwingMigrator migration;
+ private EdgeRules rules;
+ private Vertex modelVer1 = null;
+ private Vertex modelVer3 = null;
+
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
+ tx = graph.newTransaction();
+ g = graph.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ rules = EdgeRules.getInstance();
+ createFirstVertexAndRelatedVertexes();
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
+
+
+ migration = new MockEdgeSwingMigrator(spy);
+ migration.run();
+ }
+
+ private void createFirstVertexAndRelatedVertexes() throws AAIException {
+ Vertex model1 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-1")
+ .property("model-type", "widget")
+ .next();
+ modelVer1 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "model-version-id-1")
+ .property("model-name", "connector")
+ .property("model-version", "v1.0")
+ .next();
+ rules.addTreeEdge(g, model1, modelVer1);
+
+ //Create the cousin vertex - modelElement2 which will point to modelVer1
+ Vertex model2 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-2")
+ .property("model-type", "resource")
+ .next();
+ Vertex modelVer2 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "model-version-id-2")
+ .property("model-name", "resourceModTestVer")
+ .property("model-version", "v1.0")
+ .next();
+ rules.addTreeEdge(g, model2, modelVer2);
+ Vertex modelElement2 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "model-element-uuid-2")
+ .property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded")
+ .next();
+ rules.addTreeEdge(g, modelVer2, modelElement2);
+ rules.addEdge(g, modelVer1, modelElement2);
+
+ Vertex model3 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-3")
+ .property("model-type", "widget")
+ .next();
+ modelVer3 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "model-version-id-3")
+ .property("model-name", "connector")
+ .property("model-version", "v1.0")
+ .next();
+ rules.addTreeEdge(g, model3, modelVer3);
+ }
+
+ class MockEdgeSwingMigrator extends EdgeSwingMigrator {
+
+ public MockEdgeSwingMigrator(TransactionalGraphEngine engine) {
+ super(engine);
+ }
+
+ @Override
+ public List<Pair<Vertex, Vertex>> getAffectedNodePairs() {
+ List<Pair<Vertex, Vertex>> fromToVertPairList = new ArrayList<Pair<Vertex, Vertex>>();
+ Vertex fromVert = modelVer1;
+ Vertex toVert = modelVer3;
+ fromToVertPairList.add(new Pair<>(fromVert, toVert));
+ return fromToVertPairList;
+ }
+
+ public String getNodeTypeRestriction(){
+ return "model-element";
+ }
+
+ public String getEdgeLabelRestriction(){
+ return "org.onap.relationships.inventory.IsA";
+ }
+
+ public String getEdgeDirRestriction(){
+ return "IN";
+ }
+
+ @Override
+ public void cleanupAsAppropriate(List<Pair<Vertex, Vertex>> nodePairL) {
+ // For the scenario we're testing, we would define this to remove the model-ver that
+ // we moved off of, and also remove its parent model since it was a widget model and
+ // these are currently one-to-one (model-ver to model).
+ //
+ // But what gets cleaned up (if anything) after a node's edges are migrated will vary depending
+ // on what the edgeSwingMigration is being used for.
+
+
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{"model", "model-element", "model-ver"});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MockEdgeSwingMigrator";
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+
+ @Test
+ public void testBelongsToEdgesStillThere() {
+ assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1")
+ .out("org.onap.relationships.inventory.BelongsTo").has("model-invariant-id", "model-invariant-id-1").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3")
+ .out("org.onap.relationships.inventory.BelongsTo").has("model-invariant-id", "model-invariant-id-3").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "model-element").has("model-element-uuid", "model-element-uuid-2")
+ .out("org.onap.relationships.inventory.BelongsTo").has("model-version-id", "model-version-id-2").hasNext());
+ }
+
+ @Test
+ public void testThatNewEdgeAdded() {
+ assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3")
+ .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2").hasNext());
+ }
+
+ @Test
+ public void testThatNewEdgeHasAaiUuidAndDelProperties() {
+ boolean haveUuidProp = false;
+ boolean haveDelOtherVProp = false;
+ GraphTraversal<Vertex, Vertex> modVerTrav = g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3");
+ while (modVerTrav.hasNext()) {
+ Vertex modVerVtx = modVerTrav.next();
+ Iterator <Edge> edgeIter = modVerVtx.edges(Direction.IN, "org.onap.relationships.inventory.IsA");
+ while( edgeIter.hasNext() ){
+ Edge oldOutE = edgeIter.next();
+
+ Iterator <Property<Object>> propsIter2 = oldOutE.properties();
+ HashMap<String, String> propMap2 = new HashMap<String,String>();
+ while( propsIter2.hasNext() ){
+ Property <Object> ep2 = propsIter2.next();
+ if( ep2.key().equals("aai-uuid") ){
+ haveUuidProp = true;
+ }
+ else if( ep2.key().equals("delete-other-v") ){
+ haveDelOtherVProp = true;
+ }
+ }
+ }
+ }
+
+ assertTrue("New IsA edge has aai-uuid property ", haveUuidProp );
+ assertTrue("New IsA edge has delete-other-v property ", haveDelOtherVProp );
+ }
+
+
+ @Test
+ public void testThatOldEdgeGone() {
+ assertEquals(false, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1")
+ .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2").hasNext());
+ }
+
+
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java b/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java
new file mode 100644
index 0000000..4ba200a
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java
@@ -0,0 +1,281 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.EdgeRules;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringContains.containsString;
+
+public class MigrationControllerInternalTest extends AAISetup {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(MigrationControllerInternalTest.class);
+
+ private MigrationControllerInternal migrationControllerInternal;
+
+ @Before
+ public void setup() throws AAIException {
+ migrationControllerInternal = new MigrationControllerInternal();
+ clearGraph();
+ createGraph();
+ }
+
+ private void createGraph(){
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = transaction.traversal();
+
+ Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servinst1 = g.addV().property( "aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex allotedRsrc1 = g.addV().property( "aai-node-type", "allotted-resource")
+ .property("id","rsrc1")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servinst2 = g.addV().property( "aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .property("source-of-truth", "JUNIT")
+ .next();
+
+ Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex vServer1 = g.addV().property("aai-node-type", "vserver")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex pServer1 = g.addV().property("aai-node-type", "pserver")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex pInterfaceWan1 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name","ge-0/0/10")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex tunnelXConnectAll_Wan1 = g.addV().property( "aai-node-type", "tunnel-xconnect")
+ .property("id", "tunnelXConnectWan1")
+ .property("bandwidth-up-wan1", "300")
+ .property("bandwidth-down-wan1", "400")
+ .property("bandwidth-up-wan2", "500")
+ .property("bandwidth-down-wan2", "600")
+ .property("source-of-truth", "JUNIT")
+ .next();
+
+ Vertex pLinkWan1 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan1")
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servSub3 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servinst3 = g.addV().property( "aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex allotedRsrc3 = g.addV().property( "aai-node-type", "allotted-resource")
+ .property("id","rsrc3")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servinst4 = g.addV().property( "aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex servSub4 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .property("source-of-truth", "JUNIT")
+ .next();
+
+ Vertex genericvnf3 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId3")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex vServer3 = g.addV().property("aai-node-type", "vserver")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex pServer3 = g.addV().property("aai-node-type", "pserver")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex pInterfaceWan3 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name","ge-0/0/11")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ Vertex tunnelXConnectAll_Wan3 = g.addV().property( "aai-node-type", "tunnel-xconnect")
+ .property("id", "tunnelXConnectWan3")
+ .property("bandwidth-up-wan1", "300")
+ .property("bandwidth-down-wan1", "400")
+ .property("bandwidth-up-wan2", "500")
+ .property("bandwidth-down-wan2", "600")
+ .property("source-of-truth", "JUNIT")
+ .next();
+
+ Vertex pLinkWan3 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan3")
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("source-of-truth", "JUNIT")
+ .next();
+
+ EdgeRules rules = EdgeRules.getInstance();
+
+ rules.addTreeEdge(g,servSub1,servinst1);
+ rules.addEdge(g,servinst1,allotedRsrc1);
+ rules.addTreeEdge(g,servinst2,servSub2);
+ rules.addTreeEdge(g,allotedRsrc1,servinst2);
+
+ rules.addTreeEdge(g,allotedRsrc1,tunnelXConnectAll_Wan1);
+
+
+ rules.addEdge(g,servinst1,genericvnf1);
+ rules.addEdge(g,genericvnf1,vServer1);
+ rules.addEdge(g,vServer1,pServer1);
+ rules.addTreeEdge(g,pServer1,pInterfaceWan1);
+ rules.addEdge(g,pInterfaceWan1,pLinkWan1);
+
+ rules.addTreeEdge(g,servSub3,servinst3);
+ rules.addEdge(g,servinst3,allotedRsrc3);
+ rules.addTreeEdge(g,servinst4,servSub4);
+ rules.addTreeEdge(g,allotedRsrc3,servinst4);
+
+ rules.addTreeEdge(g,allotedRsrc3,tunnelXConnectAll_Wan3);
+
+
+ rules.addEdge(g,servinst3,genericvnf3);
+ rules.addEdge(g,genericvnf3,vServer3);
+ rules.addEdge(g,vServer3,pServer3);
+ rules.addTreeEdge(g,pServer3,pInterfaceWan3);
+ rules.addEdge(g,pInterfaceWan3,pLinkWan3);
+
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to create the graph {}", ex);
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+
+ }
+ }
+
+ @Test
+ public void testListAllOfMigrations() throws Exception {
+ PrintStream oldOutputStream = System.out;
+ final ByteArrayOutputStream myOut = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(myOut));
+
+ String [] args = {
+ "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
+ "-l"
+ };
+
+ migrationControllerInternal.run(args);
+
+ String content = myOut.toString();
+ assertThat(content, containsString("List of all migrations"));
+ System.setOut(oldOutputStream);
+ }
+
+ @Test
+ public void testRunSpecificMigration() throws Exception {
+ String [] args = "-c ./bundleconfig-local/etc/appprops/janusgraph-realtime.properties -m SDWANSpeedChangeMigration".split(" ");
+ migrationControllerInternal.run(args);
+ }
+
+ @Test
+ public void testRunSpecificMigrationAndCommit() throws Exception {
+ String [] args = {
+ "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
+ "-m", "SDWANSpeedChangeMigration",
+ "--commit"
+ };
+ migrationControllerInternal.run(args);
+ }
+
+ @Test
+ public void testRunSpecificMigrationFromLoadingSnapshotAndCommit() throws Exception{
+ clearGraph();
+ String [] args = {
+ "-d", "./snapshots/sdwan_test_migration.graphson",
+ "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties",
+ "-m", "SDWANSpeedChangeMigration"
+ };
+ migrationControllerInternal.run(args);
+ }
+
+ @After
+ public void tearDown(){
+ clearGraph();
+ }
+
+ public void clearGraph(){
+
+ JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction();
+
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = janusgraphTransaction.traversal();
+
+ g.V().has("source-of-truth", "JUNIT")
+ .toList()
+ .forEach((v) -> v.remove());
+
+ } catch(Exception ex) {
+ success = false;
+ logger.error("Unable to remove all of the vertexes", ex);
+ } finally {
+ if(success){
+ janusgraphTransaction.commit();
+ } else {
+ janusgraphTransaction.rollback();
+ }
+ }
+
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java
new file mode 100644
index 0000000..2b7d58d
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java
@@ -0,0 +1,126 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class PropertyMigratorTest extends AAISetup {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(PropertyMigratorTest.class);
+
+ public static class PserverPropMigrator extends PropertyMigrator {
+
+ public PserverPropMigrator(TransactionalGraphEngine engine, String oldName, String newName, Class<?> type, Cardinality cardinality) {
+ super(engine, oldName, newName, type, cardinality);
+ }
+
+ @Override
+ public boolean isIndexed() {
+ return true;
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{ "pserver" });
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "PserverPropMigrator";
+ }
+ }
+
+ @Before
+ public void setup(){
+ AAIGraph.getInstance();
+ JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = janusgraphTransaction.traversal();
+ g.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "fake-hostname")
+ .property("inv-status", "some status")
+ .property("source-of-truth", "JUNIT")
+ .next();
+ } catch(Exception ex){
+ success = false;
+ logger.error("Unable to commit the transaction {}", ex);
+
+ } finally {
+ if(success){
+ janusgraphTransaction.commit();
+ } else {
+ janusgraphTransaction.rollback();
+ }
+
+ }
+ }
+
+ @Test
+ public void testAfterPropertyMigration(){
+
+ String oldPropName = "inv-status";
+ String newPropName = "inventory-status";
+
+ Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11);
+ JanusGraphDBEngine dbEngine = new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.REALTIME, loader);
+ dbEngine.startTransaction();
+
+ PropertyMigrator propertyMigrator = new PserverPropMigrator(dbEngine, oldPropName, newPropName, String.class, Cardinality.SINGLE);
+ propertyMigrator.run();
+ assertEquals("Expecting the property to be success", Status.SUCCESS, propertyMigrator.getStatus());
+ dbEngine.commit();
+
+ JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction();
+ GraphTraversalSource g = janusgraphTransaction.traversal();
+
+ List<Vertex> oldVList = g.V().has("aai-node-type", "pserver").has(oldPropName).toList();
+ List<Vertex> newVList = g.V().has("aai-node-type", "pserver").has(newPropName).toList();
+
+ assertEquals("Expecting the vertex list with old property to be zero", 0, oldVList.size());
+ assertEquals("Expecting the vertex list with new property to be 1", 1, newVList.size());
+ assertEquals("Expecting the equipment type to be some equipment", "some status", newVList.get(0).property(newPropName).value());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java
new file mode 100644
index 0000000..7850fd2
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java
@@ -0,0 +1,154 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+public class ValueMigratorTest extends AAISetup{
+
+ public static class SampleValueMigrator extends ValueMigrator {
+ public SampleValueMigrator(TransactionalGraphEngine engine, Map map, Boolean updateExistingValues){
+ super(engine, map, updateExistingValues);
+ }
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return null;
+ }
+ @Override
+ public String getMigrationName() {
+ return "SampleValueMigrator";
+ }
+ }
+
+ private final static Version version = Version.v10;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private SampleValueMigrator migration;
+ private EdgeRules rules;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ private SampleValueMigrator existingValuesMigration;
+
+ @Before
+ public void setup() throws Exception{
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ rules = EdgeRules.getInstance();
+ Map<String, Map> map = new HashMap<>();
+ Map<String, Boolean> pair = new HashMap<>();
+ pair.put("in-maint", true);
+ map.put("pserver", pair);
+ map.put("pnf", pair);
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver0")
+ .next();
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver2")
+ .property("in-maint", false)
+ .next();
+ g.addV().property("aai-node-type", "pnf")
+ .property("pnf-name","pnf1" )
+ .property("in-maint", false)
+ .next();
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new SampleValueMigrator(spy, map, false);
+ migration.run();
+
+ map = new HashMap<>();
+ pair = new HashMap<>();
+ pair.put("in-maint", true);
+ map.put("pnf", pair);
+ existingValuesMigration = new SampleValueMigrator(spy, map, true);
+ existingValuesMigration.run();
+ }
+
+ @Test
+ public void testMissingProperty(){
+ assertTrue("Value of pnf should be updated since the property doesn't exist",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver0").has("in-maint", true).hasNext());
+ }
+
+ @Test
+ public void testExistingValue() {
+ assertTrue("Value of pserver shouldn't be updated since it already exists",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver2").has("in-maint", false).hasNext());
+ }
+
+ @Test
+ public void testEmptyValue() {
+ assertTrue("Value of pserver should be updated since the value is an empty string",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver1").has("in-maint", true).hasNext());
+ }
+
+ @Test
+ public void testUpdateExistingValues() {
+ assertTrue("Value of pnf should be updated even though it already exists",
+ g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf1").has("in-maint", true).hasNext());
+ }
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java
index 18ceac1..90cd921 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java
@@ -19,10 +19,10 @@
*/
package org.onap.aai.migration;
-import com.thinkaurelius.titan.core.Cardinality;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.schema.JanusGraphManagement;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -37,7 +37,7 @@ import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import java.io.UnsupportedEncodingException;
@@ -59,24 +59,24 @@ public class VertexMergeTest extends AAISetup {
private final static DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
- private TitanGraph graph;
+ private JanusGraph graph;
private EdgeRules rules;
private GraphTraversalSource g;
private Graph tx;
@Before
public void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
rules = EdgeRules.getInstance();
- TitanManagement mgmt = graph.openManagement();
+ JanusGraphManagement mgmt = graph.openManagement();
mgmt.makePropertyKey("test-list").dataType(String.class).cardinality(Cardinality.SET).make();
mgmt.commit();
Vertex pserverSkeleton = g.addV().property("aai-node-type", "pserver").property("hostname", "TEST1")
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java
index 6ecc481..f80229c 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java
@@ -19,9 +19,9 @@
*/
package org.onap.aai.migration.v12;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.schema.JanusGraphManagement;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -39,7 +39,7 @@ import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.AAIDirection;
import org.onap.aai.serialization.db.EdgeProperty;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import static org.junit.Assert.assertEquals;
@@ -54,19 +54,19 @@ public class ContainmentDeleteOtherVPropertyMigrationTest extends AAISetup {
private final static DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
- private TitanGraph graph;
+ private JanusGraph graph;
private ContainmentDeleteOtherVPropertyMigration migration;
private GraphTraversalSource g;
private Graph tx;
@Before
public void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
- TitanManagement titanManagement = graph.openManagement();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
@@ -88,7 +88,7 @@ public class ContainmentDeleteOtherVPropertyMigrationTest extends AAISetup {
GraphTraversalSource traversal = g;
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
- Mockito.doReturn(titanManagement).when(adminSpy).getManagementSystem();
+ Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
migration = new ContainmentDeleteOtherVPropertyMigration(spy, "/edgeMigrationTestRules.json");
migration.run();
}
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java
index 0552dd9..4fbed4c 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java
@@ -19,9 +19,9 @@
*/
package org.onap.aai.migration.v12;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanTransaction;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
@@ -35,7 +35,7 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import static org.junit.Assert.assertEquals;
@@ -51,11 +51,11 @@ public class MigrateDataFromASDCToConfigurationTest extends AAISetup {
private final static DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
- private TitanGraph graph;
+ private JanusGraph graph;
private MigrateDataFromASDCToConfiguration migration;
private EdgeRules rules;
private GraphTraversalSource g;
- private TitanTransaction tx;
+ private JanusGraphTransaction tx;
Vertex configuration;
Vertex configuration2;
Vertex configuration3;
@@ -68,11 +68,11 @@ public class MigrateDataFromASDCToConfigurationTest extends AAISetup {
@Before
public void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java
index 33f5f2c..b07c728 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java
@@ -41,12 +41,12 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanTransaction;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
public class MigrateServiceInstanceToConfigurationTest extends AAISetup {
@@ -57,19 +57,19 @@ public class MigrateServiceInstanceToConfigurationTest extends AAISetup {
private static Loader loader;
private static TransactionalGraphEngine dbEngine;
- private static TitanGraph graph;
+ private static JanusGraph graph;
private static MigrateServiceInstanceToConfiguration migration;
- private static TitanTransaction tx;
+ private static JanusGraphTransaction tx;
private static GraphTraversalSource g;
private static EdgeRules rules;
@BeforeClass
public static void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java
index c3449ab..498fd0c 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java
@@ -41,12 +41,12 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanTransaction;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
public class MigrateServiceInstanceToConfigurationTestPreMigrationMock extends AAISetup {
@@ -57,19 +57,19 @@ public class MigrateServiceInstanceToConfigurationTestPreMigrationMock extends A
private static Loader loader;
private static TransactionalGraphEngine dbEngine;
- private static TitanGraph graph;
+ private static JanusGraph graph;
private static MigrateServiceInstanceToConfiguration migration;
- private static TitanTransaction tx;
+ private static JanusGraphTransaction tx;
private static GraphTraversalSource g;
private static EdgeRules rules;
@BeforeClass
public static void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java
new file mode 100644
index 0000000..677050a
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java
@@ -0,0 +1,379 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class SDWANSpeedChangeMigrationTest extends AAISetup {
+
+ private final static Version version = Version.v12;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private SDWANSpeedChangeMigration migration;
+ private EdgeRules rules;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex pLinkWan1;
+ Vertex pLinkWan3;
+ Vertex pLinkWan5;
+ Vertex pLinkWan7;
+
+
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ rules = EdgeRules.getInstance();
+
+ Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .next();
+ Vertex servinst1 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .next();
+ Vertex allotedRsrc1 = g.addV().property("aai-node-type", "allotted-resource")
+ .property("id", "rsrc1")
+ .next();
+ Vertex servinst2 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .next();
+ Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .next();
+
+ Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .next();
+ Vertex vServer1 = g.addV().property("aai-node-type", "vserver")
+ .next();
+ Vertex pServer1 = g.addV().property("aai-node-type", "pserver")
+ .next();
+ Vertex pInterfaceWan1 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "ge-0/0/10")
+ .next();
+ Vertex tunnelXConnectAll_Wan1 = g.addV().property("aai-node-type", "tunnel-xconnect")
+ .property("id", "txc1")
+ .property("bandwidth-up-wan1", "300 Mbps")
+ .property("bandwidth-down-wan1", "400 Mbps")
+ .property("bandwidth-up-wan2", "500 Mbps")
+ .property("bandwidth-down-wan2", "600 Mbps")
+ .next();
+
+ pLinkWan1 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan1")
+ .property("service-provider-bandwidth-up-value", "empty")
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", "empty")
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+ Vertex servSub3 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .next();
+ Vertex servinst3 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .next();
+ Vertex allotedRsrc3 = g.addV().property("aai-node-type", "allotted-resource")
+ .property("id", "rsrc1")
+ .next();
+ Vertex servinst4 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .next();
+ Vertex servSub4 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .next();
+
+ Vertex genericvnf3 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .next();
+ Vertex vServer3 = g.addV().property("aai-node-type", "vserver")
+ .next();
+ Vertex pServer3 = g.addV().property("aai-node-type", "pserver")
+ .next();
+ Vertex pInterfaceWan3 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "ge-0/0/11")
+ .next();
+ Vertex tunnelXConnectAll_Wan3 = g.addV().property("aai-node-type", "tunnel-xconnect")
+ .property("id", "txc3")
+ .property("bandwidth-up-wan1", "300 Mbps")
+ .property("bandwidth-down-wan1", "400 Mbps")
+ .property("bandwidth-up-wan2", "500 Mbps")
+ .property("bandwidth-down-wan2", "600 Mbps")
+ .next();
+
+ pLinkWan3 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan3")
+ .property("service-provider-bandwidth-up-value", "empty")
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", "empty")
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+
+
+ Vertex servSub5 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .next();
+ Vertex servinst5 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .next();
+ Vertex allotedRsrc5 = g.addV().property("aai-node-type", "allotted-resource")
+ .property("id", "rsrc1")
+ .next();
+ Vertex servinst6 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .next();
+ Vertex servSub6 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .next();
+
+ Vertex genericvnf5 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .next();
+ Vertex vServer5 = g.addV().property("aai-node-type", "vserver")
+ .next();
+ Vertex pServer5 = g.addV().property("aai-node-type", "pserver")
+ .next();
+ Vertex pInterfaceWan5 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "ge-0/0/10")
+ .next();
+ Vertex tunnelXConnectAll_Wan5 = g.addV().property("aai-node-type", "tunnel-xconnect")
+ .property("id", "txc5")
+ .property("bandwidth-up-wan1", "")
+ .property("bandwidth-down-wan1", "")
+ .property("bandwidth-up-wan2", "500 Mbps")
+ .property("bandwidth-down-wan2", "600 Mbps")
+ .next();
+
+ pLinkWan5 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan5")
+ .property("service-provider-bandwidth-up-value", "")
+ .property("service-provider-bandwidth-up-units", "")
+ .property("service-provider-bandwidth-down-value", "")
+ .property("service-provider-bandwidth-down-units", "")
+ .next();
+
+
+ Vertex servSub7 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "DHV")
+ .next();
+ Vertex servinst7 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "DHV")
+ .next();
+ Vertex allotedRsrc7 = g.addV().property("aai-node-type", "allotted-resource")
+ .property("id", "rsrc1")
+ .next();
+ Vertex servinst9 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-type", "VVIG")
+ .next();
+ Vertex servSub9 = g.addV().property("aai-node-type", "service-subscription")
+ .property("service-type", "VVIG")
+ .next();
+
+ Vertex genericvnf7 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .next();
+ Vertex vServer7 = g.addV().property("aai-node-type", "vserver")
+ .next();
+ Vertex pServer7 = g.addV().property("aai-node-type", "pserver")
+ .next();
+ Vertex pInterfaceWan7 = g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "ge-0/0/11")
+ .next();
+ Vertex tunnelXConnectAll_Wan7 = g.addV().property("aai-node-type", "tunnel-xconnect")
+ .property("id", "txc7")
+ .property("bandwidth-up-wan1", "300 Mbps")
+ .property("bandwidth-down-wan1", "400 Mbps")
+ .property("bandwidth-up-wan2", "")
+ .property("bandwidth-down-wan2", "")
+ .next();
+
+ pLinkWan7 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkWan5")
+ .property("service-provider-bandwidth-up-value", "")
+ .property("service-provider-bandwidth-up-units", "")
+ .property("service-provider-bandwidth-down-value", "")
+ .property("service-provider-bandwidth-down-units", "")
+ .next();
+
+
+
+ rules.addTreeEdge(g, servSub1, servinst1);
+ rules.addEdge(g, servinst1, allotedRsrc1);
+ rules.addTreeEdge(g, servinst2, servSub2);
+ rules.addTreeEdge(g, allotedRsrc1, servinst2);
+
+ rules.addTreeEdge(g, allotedRsrc1, tunnelXConnectAll_Wan1);
+
+
+ rules.addEdge(g, servinst1, genericvnf1);
+ rules.addEdge(g, genericvnf1, vServer1);
+ rules.addEdge(g, vServer1, pServer1);
+ rules.addTreeEdge(g, pServer1, pInterfaceWan1);
+ rules.addEdge(g, pInterfaceWan1, pLinkWan1);
+
+ rules.addTreeEdge(g, servSub3, servinst3);
+ rules.addEdge(g, servinst3, allotedRsrc3);
+ rules.addTreeEdge(g, servinst4, servSub4);
+ rules.addTreeEdge(g, allotedRsrc3, servinst4);
+
+ rules.addTreeEdge(g, allotedRsrc3, tunnelXConnectAll_Wan3);
+
+
+ rules.addEdge(g, servinst3, genericvnf3);
+ rules.addEdge(g, genericvnf3, vServer3);
+ rules.addEdge(g, vServer3, pServer3);
+ rules.addTreeEdge(g, pServer3, pInterfaceWan3);
+ rules.addEdge(g, pInterfaceWan3, pLinkWan3);
+
+
+ rules.addTreeEdge(g, servSub5, servinst5);
+ rules.addEdge(g, servinst5, allotedRsrc5);
+ rules.addTreeEdge(g, servinst6, servSub6);
+ rules.addTreeEdge(g, allotedRsrc5, servinst6);
+
+ rules.addTreeEdge(g, allotedRsrc5, tunnelXConnectAll_Wan5);
+
+
+ rules.addEdge(g, servinst5, genericvnf5);
+ rules.addEdge(g, genericvnf5, vServer5);
+ rules.addEdge(g, vServer5, pServer5);
+ rules.addTreeEdge(g, pServer5, pInterfaceWan5);
+ rules.addEdge(g, pInterfaceWan5, pLinkWan5);
+
+ rules.addTreeEdge(g, servSub7, servinst7);
+ rules.addEdge(g, servinst7, allotedRsrc7);
+ rules.addTreeEdge(g, servinst9, servSub9);
+ rules.addTreeEdge(g, allotedRsrc7, servinst9);
+
+ rules.addTreeEdge(g, allotedRsrc7, tunnelXConnectAll_Wan7);
+
+
+ rules.addEdge(g, servinst7, genericvnf7);
+ rules.addEdge(g, genericvnf7, vServer7);
+ rules.addEdge(g, vServer7, pServer7);
+ rules.addTreeEdge(g, pServer7, pInterfaceWan7);
+ rules.addEdge(g, pInterfaceWan7, pLinkWan7);
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new SDWANSpeedChangeMigration(spy);
+ migration.run();
+ }
+
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * Checks to see if the Wan1 properties were updated in the physical link
+ */
+
+ @Test
+ public void ConfirmWan1Changes() {
+
+ assertEquals("300", pLinkWan1.property("service-provider-bandwidth-up-value").value().toString());
+ assertEquals("Mbps", pLinkWan1.property("service-provider-bandwidth-up-units").value().toString());
+ assertEquals("400", pLinkWan1.property("service-provider-bandwidth-down-value").value().toString());
+ assertEquals("Mbps", pLinkWan1.property("service-provider-bandwidth-down-units").value().toString());
+
+ }
+
+ /***
+ * Checks to see if the Wan2 properties were updated in the physical link
+ */
+ @Test
+ public void ConfirmWan2Changes() {
+
+ assertEquals("500", pLinkWan3.property("service-provider-bandwidth-up-value").value().toString());
+ assertEquals("Mbps", pLinkWan3.property("service-provider-bandwidth-up-units").value().toString());
+ assertEquals("600", pLinkWan3.property("service-provider-bandwidth-down-value").value().toString());
+ assertEquals("Mbps", pLinkWan3.property("service-provider-bandwidth-down-units").value().toString());
+
+ }
+
+ /***
+ * if tunnel xconncets missing bandwidth up 1 value the plink should not be updated
+ */
+
+ @Test
+ public void Wan1EmptyNoChanges() {
+
+ assertEquals("", pLinkWan5.property("service-provider-bandwidth-up-value").value().toString());
+ assertEquals("", pLinkWan5.property("service-provider-bandwidth-up-units").value().toString());
+ assertEquals("", pLinkWan5.property("service-provider-bandwidth-down-value").value().toString());
+ assertEquals("", pLinkWan5.property("service-provider-bandwidth-down-units").value().toString());
+
+ }
+
+ /***
+ * if tunnel xconncets missing bandwidth up 2 value the plink should not be updated
+ */
+
+ @Test
+ public void Wan2EmptyNoChanges() {
+
+ assertEquals("", pLinkWan7.property("service-provider-bandwidth-up-value").value().toString());
+ assertEquals("", pLinkWan7.property("service-provider-bandwidth-up-units").value().toString());
+ assertEquals("", pLinkWan7.property("service-provider-bandwidth-down-value").value().toString());
+ assertEquals("", pLinkWan7.property("service-provider-bandwidth-down-units").value().toString());
+
+ }
+
+
+}
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java
index a690308..9e21947 100644
--- a/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java
@@ -19,9 +19,9 @@
*/
package org.onap.aai.migration.v12;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.schema.JanusGraphManagement;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -39,7 +39,7 @@ import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.AAIDirection;
import org.onap.aai.serialization.db.EdgeProperty;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TitanDBEngine;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import static org.junit.Assert.assertEquals;
@@ -55,19 +55,19 @@ public class ToscaMigrationTest extends AAISetup {
private final static DBConnectionType type = DBConnectionType.REALTIME;
private Loader loader;
private TransactionalGraphEngine dbEngine;
- private TitanGraph graph;
+ private JanusGraph graph;
private ToscaMigration migration;
private GraphTraversalSource g;
private Graph tx;
@Before
public void setUp() throws Exception {
- graph = TitanFactory.build().set("storage.backend","inmemory").open();
- TitanManagement titanManagement = graph.openManagement();
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
tx = graph.newTransaction();
g = tx.traversal();
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new TitanDBEngine(
+ dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
@@ -104,7 +104,7 @@ public class ToscaMigrationTest extends AAISetup {
GraphTraversalSource traversal = g;
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
- Mockito.doReturn(titanManagement).when(adminSpy).getManagementSystem();
+ Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
migration = new ToscaMigration(spy);
migration.run();
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java
new file mode 100644
index 0000000..a29fb6b
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+
+public class MigrateInstanceGroupSubTypeTest extends AAISetup{
+
+ private static final String SUB_TYPE_VALUE = "SubTypeValue";
+ private final static Version version = Version.v13;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateInstanceGroupSubType migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex instanceGroup;
+ Vertex instanceGroupWithoutTSubType;
+
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE)
+ .property( MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY, SUB_TYPE_VALUE)
+ .next();
+
+ instanceGroupWithoutTSubType = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE)
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateInstanceGroupSubType(spy);
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the type/subtype property were renamed
+ */
+
+ @Test
+ public void confirmTypeAndSubTypeWereRenamed() {
+ migration.run();
+
+ //instance group with sub-type
+ assertEquals(SUB_TYPE_VALUE, instanceGroup.property(MigrateInstanceGroupSubType.INSTANCE_GROUP_ROLE_PROPERTY).value());
+ assertFalse(instanceGroup.property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY).isPresent());
+
+ //instance group without subtype
+ assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.INSTANCE_GROUP_ROLE_PROPERTY).isPresent());
+ assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY).isPresent());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java
new file mode 100644
index 0000000..11e5157
--- /dev/null
+++ b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.Version;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+
+public class MigrateInstanceGroupTypeTest extends AAISetup{
+
+ private static final String TYPE_VALUE = "TypeValue";
+ private final static Version version = Version.v13;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateInstanceGroupType migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex instanceGroup;
+ Vertex instanceGroupWithoutType;
+
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE)
+ .property( MigrateInstanceGroupType.TYPE_PROPERTY, TYPE_VALUE)
+ .next();
+
+ instanceGroupWithoutType = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE)
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateInstanceGroupType(spy);
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the type/subtype property were renamed
+ */
+
+ @Test
+ public void confirmTypeAndSubTypeWereRenamed() {
+ migration.run();
+
+ //instance group with type
+ assertEquals(TYPE_VALUE, instanceGroup.property(MigrateInstanceGroupType.INSTANCE_GROUP_TYPE_PROPERTY).value());
+ assertFalse(instanceGroup.property(MigrateInstanceGroupType.TYPE_PROPERTY).isPresent());
+
+ //instance group without type
+ assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.INSTANCE_GROUP_TYPE_PROPERTY).isPresent());
+ assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.TYPE_PROPERTY).isPresent());
+ }
+} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java b/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java
index 5c2c2d7..de5eba1 100644
--- a/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java
@@ -19,18 +19,18 @@
*/
package org.onap.aai.schema.db;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.thinkaurelius.titan.core.TitanFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.db.schema.DBIndex;
-import org.onap.aai.db.schema.ManageTitanSchema;
+import org.onap.aai.db.schema.ManageJanusGraphSchema;
import java.io.IOException;
import java.util.Set;
@@ -38,24 +38,23 @@ import java.util.Set;
@Ignore("not ready yet")
public class ManageSchemaTest extends AAISetup {
- private TitanGraph graph = null;
+ private JanusGraph graph = null;
@Before
public void beforeTest() {
- //graph = TitanFactory.open("src/test/resources/inmemory_titan.properties");
- graph = TitanFactory.open("bundleconfig-local/etc/appprops/aaiconfig.properties");
+ graph = JanusGraphFactory.open("bundleconfig-local/etc/appprops/aaiconfig.properties");
}
/*
@Test
public void populateEmptyGraph() {
- ManageTitanSchema schema = new ManageTitanSchema(graph);
+ ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph);
schema.buildSchema();
}
@Test
public void modifyIndex() {
- ManageTitanSchema schema = new ManageTitanSchema(graph);
+ ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph);
schema.buildSchema();
Vertex v = graph.addVertex();
v.setProperty("aai-node-type", "pserver");
@@ -72,7 +71,7 @@ public class ManageSchemaTest extends AAISetup {
@Test
public void closeRunningInstances() {
- TitanManagement mgmt = graph.openManagement();
+ JanusGraphManagement mgmt = graph.openManagement();
Set<String> instances = mgmt.getOpenInstances();
for (String instance : instances) {
@@ -99,8 +98,8 @@ public class ManageSchemaTest extends AAISetup {
" } ]\r\n" +
" }";
DBIndex index = mapper.readValue(content, DBIndex.class);
- ManageTitanSchema schema = new ManageTitanSchema(graph);
- TitanManagement mgmt = graph.openManagement();
+ ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph);
+ JanusGraphManagement mgmt = graph.openManagement();
Set<String> instances = mgmt.getOpenInstances();
System.out.println(instances);
schema.updateIndex(index);
diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties
index 63df92b..82e7dcc 100644
--- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties
@@ -62,7 +62,7 @@ AAI_5107=5:2:WARN:5107:400:3000:Required information missing
AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored
#--- aaidbgen: 6101-6199
-AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed
+AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed
AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType
AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data
AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data
diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties
index bf0849d..5a52d19 100644
--- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties
+++ b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties
@@ -21,10 +21,14 @@
#
query.fast-property=true
+query.smart-limit=false
+
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
+#graph.titan-version=1.0.0
+
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev1.dev
@@ -36,4 +40,4 @@ cache.db-cache-time = 180000
cache.db-cache-size = 0.3
#load graphson file on startup
-load.snapshot.file=false \ No newline at end of file
+load.snapshot.file=false
diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties
index 7528235..72ced14 100644
--- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties
+++ b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties
@@ -21,10 +21,14 @@
#
query.fast-property=true
+query.smart-limit=false
+
# the following parameters are not reloaded automatically and require a manual bounce
storage.backend=inmemory
storage.hostname=localhost
+#graph.titan-version=1.0.0
+
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev1.dev
diff --git a/aai-resources/src/test/resources/logback.xml b/aai-resources/src/test/resources/logback.xml
index a6e4345..0258f1d 100644
--- a/aai-resources/src/test/resources/logback.xml
+++ b/aai-resources/src/test/resources/logback.xml
@@ -373,7 +373,7 @@
<logger name="org.apache" level="WARN" />
<logger name="org.zookeeper" level="WARN" />
- <logger name="com.thinkaurelius" level="WARN" />
+ <logger name="org.janusgraph" level="WARN" />
<logger name="com.att.aft.dme2" level="WARN" />
<!-- ============================================================================ -->
diff --git a/aai-resources/src/test/resources/updateEdgeTestRules.json b/aai-resources/src/test/resources/updateEdgeTestRules.json
new file mode 100644
index 0000000..4da2b59
--- /dev/null
+++ b/aai-resources/src/test/resources/updateEdgeTestRules.json
@@ -0,0 +1,60 @@
+{
+ "rules": [
+ {
+ "from": "generic-vnf",
+ "to": "l-interface",
+ "label": "hasLInterface",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "!${direction}",
+ "SVC-INFRA": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "An edge comment",
+ "default": "true",
+ "newProperty": "newValue"
+ },
+ {
+ "from": "pserver",
+ "to": "vnfc",
+ "label": "tosca.relationships.HostedOn",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "!${direction}",
+ "SVC-INFRA": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "A pserver/vnfc edge description",
+ "default": "true",
+ "newProperty": "newValue"
+ },
+ {
+ "from": "l-interface",
+ "to": "logical-link",
+ "label": "usesLogicalLink",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "!${direction}",
+ "SVC-INFRA": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "A l-interface/logical-link(1) edge description",
+ "default": "true",
+ "newProperty": "newValue"
+ },
+ {
+ "from": "l-interface",
+ "to": "logical-link",
+ "label": "sourceLInterface",
+ "direction": "OUT",
+ "multiplicity": "MANY2MANY",
+ "contains-other-v": "!${direction}",
+ "delete-other-v": "!${direction}",
+ "SVC-INFRA": "${direction}",
+ "prevent-delete": "NONE",
+ "description": "A l-interface/logical-link(2) edge description",
+ "default": "true",
+ "newProperty": "newValue"
+ }
+ ]
+} \ No newline at end of file