From 8824d311caf6023340e3663f4ff9f61dea8e4241 Mon Sep 17 00:00:00 2001 From: "Kajur, Harish (vk250x)" Date: Wed, 21 Mar 2018 18:26:20 -0400 Subject: Update from titan to using janusgraph Issue-ID: AAI-949 Change-Id: I70029806d3c96f7732778d27a8c7ff75dc5059de Signed-off-by: Kajur, Harish (vk250x) --- .../org/onap/aai/db/schema/AuditJanusGraph.java | 122 ++++++ .../main/java/org/onap/aai/db/schema/AuditOXM.java | 6 +- .../java/org/onap/aai/db/schema/AuditTitan.java | 122 ------ .../org/onap/aai/db/schema/AuditorFactory.java | 6 +- .../main/java/org/onap/aai/db/schema/DBIndex.java | 2 +- .../java/org/onap/aai/db/schema/DBProperty.java | 2 +- .../java/org/onap/aai/db/schema/EdgeProperty.java | 2 +- .../onap/aai/db/schema/ManageJanusGraphSchema.java | 330 +++++++++++++++ .../org/onap/aai/db/schema/ManageTitanSchema.java | 330 --------------- .../java/org/onap/aai/db/schema/ScriptDriver.java | 6 +- .../main/java/org/onap/aai/dbgen/DataGrooming.java | 24 +- .../main/java/org/onap/aai/dbgen/GenTester.java | 18 +- .../java/org/onap/aai/dbgen/SchemaGenerator.java | 26 +- .../src/main/java/org/onap/aai/dbmap/AAIGraph.java | 34 +- .../java/org/onap/aai/dbmap/AAIGraphConfig.java | 12 +- .../java/org/onap/aai/dbmap/InMemoryGraph.java | 20 +- .../org/onap/aai/extensions/AAIExtensionMap.java | 2 +- .../main/java/org/onap/aai/rest/db/HttpEntry.java | 17 +- .../onap/aai/serialization/db/DBSerializer.java | 2 +- .../onap/aai/serialization/db/GraphSingleton.java | 6 +- .../serialization/db/InMemoryGraphSingleton.java | 14 +- .../aai/serialization/db/JanusGraphSingleton.java | 37 ++ .../aai/serialization/db/TitanGraphSingleton.java | 37 -- .../serialization/engines/InMemoryDBEngine.java | 13 +- .../serialization/engines/JanusGraphDBEngine.java | 100 +++++ .../aai/serialization/engines/TitanDBEngine.java | 100 ----- .../engines/TransactionalGraphEngine.java | 14 +- .../aai/serialization/queryformats/GraphSON.java | 4 +- .../main/java/org/onap/aai/util/AAIConstants.java | 4 +- .../org/onap/aai/util/UniquePropertyCheck.java | 8 +- .../java/org/onap/aai/util/genxsd/YAMLfromOXM.java | 6 - aai-core/src/main/resources/logback.xml | 391 ++++++++++++++++++ .../test/java/org/onap/aai/dbmap/AAIGraphTest.java | 16 +- .../aai/introspection/sideeffect/DataCopyTest.java | 12 +- .../aai/introspection/sideeffect/DataLinkTest.java | 106 ++++- .../onap/aai/parsers/query/GraphTraversalTest.java | 6 +- .../query/GremlinPipelineTraversalTest.java | 447 +++++++++++++++++++++ .../onap/aai/parsers/query/LegacyQueryTest.java | 4 +- .../query/RelationshipGremlinQueryTest.java | 4 +- .../aai/parsers/query/RelationshipQueryTest.java | 4 +- .../parsers/query/UniqueRelationshipQueryTest.java | 4 +- .../onap/aai/parsers/query/UniqueURIQueryTest.java | 4 +- .../query/builder/QueryBuilderTestAbstraction.java | 4 +- .../org/onap/aai/serialization/db/DbAliasTest.java | 12 +- .../aai/serialization/db/DbSerializerTest.java | 10 +- .../queryformats/CountQuerySupportTest.java | 4 +- .../queryformats/MultiFormatTest.java | 4 +- .../serialization/queryformats/RawFormatTest.java | 4 +- .../queryformats/SimpleFormatTest.java | 4 +- .../etc/appprops/error.properties | 2 +- .../etc/appprops/janusgraph-cached.properties | 39 ++ .../etc/appprops/janusgraph-realtime.properties | 36 ++ .../etc/appprops/titan-cached.properties | 39 -- .../etc/appprops/titan-realtime.properties | 36 -- aai-core/src/test/resources/logback.xml | 389 +++++++++++------- 55 files changed, 2010 insertions(+), 997 deletions(-) create mode 100644 aai-core/src/main/java/org/onap/aai/db/schema/AuditJanusGraph.java delete mode 100644 aai-core/src/main/java/org/onap/aai/db/schema/AuditTitan.java create mode 100644 aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java delete mode 100644 aai-core/src/main/java/org/onap/aai/db/schema/ManageTitanSchema.java create mode 100644 aai-core/src/main/java/org/onap/aai/serialization/db/JanusGraphSingleton.java delete mode 100644 aai-core/src/main/java/org/onap/aai/serialization/db/TitanGraphSingleton.java create mode 100644 aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java delete mode 100644 aai-core/src/main/java/org/onap/aai/serialization/engines/TitanDBEngine.java create mode 100644 aai-core/src/main/resources/logback.xml create mode 100644 aai-core/src/test/java/org/onap/aai/parsers/query/GremlinPipelineTraversalTest.java create mode 100644 aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties create mode 100644 aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties delete mode 100644 aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties delete mode 100644 aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties (limited to 'aai-core/src') diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/AuditJanusGraph.java b/aai-core/src/main/java/org/onap/aai/db/schema/AuditJanusGraph.java new file mode 100644 index 00000000..e8ac6ae0 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/db/schema/AuditJanusGraph.java @@ -0,0 +1,122 @@ +/** + * ============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.db.schema; + + +import java.util.Iterator; +import java.util.LinkedHashSet; + +import org.apache.tinkerpop.gremlin.structure.Vertex; + +import org.janusgraph.core.EdgeLabel; +import org.janusgraph.core.PropertyKey; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.JanusGraphIndex; +import org.janusgraph.core.schema.JanusGraphManagement; + +public class AuditJanusGraph extends Auditor { + + private final JanusGraph graph; + + /** + * Instantiates a new audit JanusGraph. + * + * @param g the g + */ + public AuditJanusGraph (JanusGraph g) { + this.graph = g; + buildSchema(); + } + + /** + * Builds the schema. + */ + private void buildSchema() { + populateProperties(); + populateIndexes(); + populateEdgeLabels(); + } + + /** + * Populate properties. + */ + private void populateProperties() { + JanusGraphManagement mgmt = graph.openManagement(); + Iterable iterable = mgmt.getRelationTypes(PropertyKey.class); + Iterator JanusGraphProperties = iterable.iterator(); + PropertyKey propKey; + while (JanusGraphProperties.hasNext()) { + propKey = JanusGraphProperties.next(); + DBProperty prop = new DBProperty(); + + prop.setName(propKey.name()); + prop.setCardinality(propKey.cardinality()); + prop.setTypeClass(propKey.dataType()); + + this.properties.put(prop.getName(), prop); + } + } + + /** + * Populate indexes. + */ + private void populateIndexes() { + JanusGraphManagement mgmt = graph.openManagement(); + Iterable iterable = mgmt.getGraphIndexes(Vertex.class); + Iterator JanusGraphIndexes = iterable.iterator(); + JanusGraphIndex JanusGraphIndex; + while (JanusGraphIndexes.hasNext()) { + JanusGraphIndex = JanusGraphIndexes.next(); + if (JanusGraphIndex.isCompositeIndex()) { + DBIndex index = new DBIndex(); + LinkedHashSet dbProperties = new LinkedHashSet<>(); + index.setName(JanusGraphIndex.name()); + index.setUnique(JanusGraphIndex.isUnique()); + PropertyKey[] keys = JanusGraphIndex.getFieldKeys(); + for (PropertyKey key : keys) { + dbProperties.add(this.properties.get(key.name())); + } + index.setProperties(dbProperties); + index.setStatus(JanusGraphIndex.getIndexStatus(keys[0])); + this.indexes.put(index.getName(), index); + } + } + } + + /** + * Populate edge labels. + */ + private void populateEdgeLabels() { + JanusGraphManagement mgmt = graph.openManagement(); + Iterable iterable = mgmt.getRelationTypes(EdgeLabel.class); + Iterator JanusGraphEdgeLabels = iterable.iterator(); + EdgeLabel edgeLabel; + while (JanusGraphEdgeLabels.hasNext()) { + edgeLabel = JanusGraphEdgeLabels.next(); + EdgeProperty edgeProperty = new EdgeProperty(); + + edgeProperty.setName(edgeLabel.name()); + edgeProperty.setMultiplicity(edgeLabel.multiplicity()); + + this.edgeLabels.put(edgeProperty.getName(), edgeProperty); + } + } + +} diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/AuditOXM.java b/aai-core/src/main/java/org/onap/aai/db/schema/AuditOXM.java index ff7eee25..167b26d0 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/AuditOXM.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/AuditOXM.java @@ -51,9 +51,9 @@ import org.onap.aai.util.AAIConstants; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.collect.Multimap; -import com.thinkaurelius.titan.core.Cardinality; -import com.thinkaurelius.titan.core.Multiplicity; -import com.thinkaurelius.titan.core.schema.SchemaStatus; +import org.janusgraph.core.Cardinality; +import org.janusgraph.core.Multiplicity; +import org.janusgraph.core.schema.SchemaStatus; public class AuditOXM extends Auditor { diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/AuditTitan.java b/aai-core/src/main/java/org/onap/aai/db/schema/AuditTitan.java deleted file mode 100644 index 03c0f9ae..00000000 --- a/aai-core/src/main/java/org/onap/aai/db/schema/AuditTitan.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * ============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.db.schema; - - -import java.util.Iterator; -import java.util.LinkedHashSet; - -import org.apache.tinkerpop.gremlin.structure.Vertex; - -import com.thinkaurelius.titan.core.EdgeLabel; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanGraphIndex; -import com.thinkaurelius.titan.core.schema.TitanManagement; - -public class AuditTitan extends Auditor { - - private final TitanGraph graph; - - /** - * Instantiates a new audit titan. - * - * @param g the g - */ - public AuditTitan (TitanGraph g) { - this.graph = g; - buildSchema(); - } - - /** - * Builds the schema. - */ - private void buildSchema() { - populateProperties(); - populateIndexes(); - populateEdgeLabels(); - } - - /** - * Populate properties. - */ - private void populateProperties() { - TitanManagement mgmt = graph.openManagement(); - Iterable iterable = mgmt.getRelationTypes(PropertyKey.class); - Iterator titanProperties = iterable.iterator(); - PropertyKey propKey; - while (titanProperties.hasNext()) { - propKey = titanProperties.next(); - DBProperty prop = new DBProperty(); - - prop.setName(propKey.name()); - prop.setCardinality(propKey.cardinality()); - prop.setTypeClass(propKey.dataType()); - - this.properties.put(prop.getName(), prop); - } - } - - /** - * Populate indexes. - */ - private void populateIndexes() { - TitanManagement mgmt = graph.openManagement(); - Iterable iterable = mgmt.getGraphIndexes(Vertex.class); - Iterator titanIndexes = iterable.iterator(); - TitanGraphIndex titanIndex; - while (titanIndexes.hasNext()) { - titanIndex = titanIndexes.next(); - if (titanIndex.isCompositeIndex()) { - DBIndex index = new DBIndex(); - LinkedHashSet dbProperties = new LinkedHashSet<>(); - index.setName(titanIndex.name()); - index.setUnique(titanIndex.isUnique()); - PropertyKey[] keys = titanIndex.getFieldKeys(); - for (PropertyKey key : keys) { - dbProperties.add(this.properties.get(key.name())); - } - index.setProperties(dbProperties); - index.setStatus(titanIndex.getIndexStatus(keys[0])); - this.indexes.put(index.getName(), index); - } - } - } - - /** - * Populate edge labels. - */ - private void populateEdgeLabels() { - TitanManagement mgmt = graph.openManagement(); - Iterable iterable = mgmt.getRelationTypes(EdgeLabel.class); - Iterator titanEdgeLabels = iterable.iterator(); - EdgeLabel edgeLabel; - while (titanEdgeLabels.hasNext()) { - edgeLabel = titanEdgeLabels.next(); - EdgeProperty edgeProperty = new EdgeProperty(); - - edgeProperty.setName(edgeLabel.name()); - edgeProperty.setMultiplicity(edgeLabel.multiplicity()); - - this.edgeLabels.put(edgeProperty.getName(), edgeProperty); - } - } - -} diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/AuditorFactory.java b/aai-core/src/main/java/org/onap/aai/db/schema/AuditorFactory.java index f47807b2..67bc0398 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/AuditorFactory.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/AuditorFactory.java @@ -20,7 +20,7 @@ package org.onap.aai.db.schema; import org.onap.aai.introspection.Version; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraph; public class AuditorFactory { @@ -40,7 +40,7 @@ public class AuditorFactory { * @param g the g * @return the graph auditor */ - public static Auditor getGraphAuditor (TitanGraph g) { - return new AuditTitan(g); + public static Auditor getGraphAuditor (JanusGraph g) { + return new AuditJanusGraph(g); } } diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/DBIndex.java b/aai-core/src/main/java/org/onap/aai/db/schema/DBIndex.java index f0e3ee6d..9fd0eda0 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/DBIndex.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/DBIndex.java @@ -22,7 +22,7 @@ package org.onap.aai.db.schema; import java.util.LinkedHashSet; import java.util.Set; -import com.thinkaurelius.titan.core.schema.SchemaStatus; +import org.janusgraph.core.schema.SchemaStatus; public class DBIndex implements Named { diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/DBProperty.java b/aai-core/src/main/java/org/onap/aai/db/schema/DBProperty.java index 29aef8e8..fd19f72d 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/DBProperty.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/DBProperty.java @@ -20,7 +20,7 @@ package org.onap.aai.db.schema; import org.onap.aai.introspection.Introspector; -import com.thinkaurelius.titan.core.Cardinality; +import org.janusgraph.core.Cardinality; public class DBProperty implements Named { diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/EdgeProperty.java b/aai-core/src/main/java/org/onap/aai/db/schema/EdgeProperty.java index f0de7656..6d10232d 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/EdgeProperty.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/EdgeProperty.java @@ -19,7 +19,7 @@ */ package org.onap.aai.db.schema; -import com.thinkaurelius.titan.core.Multiplicity; +import org.janusgraph.core.Multiplicity; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonPropertyOrder; diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java b/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java new file mode 100644 index 00000000..bf2d4107 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java @@ -0,0 +1,330 @@ +/** + * ============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.db.schema; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.apache.tinkerpop.gremlin.structure.Vertex; + +import org.onap.aai.introspection.Version; +import org.janusgraph.core.PropertyKey; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.SchemaStatus; +import org.janusgraph.core.schema.JanusGraphIndex; +import org.janusgraph.core.schema.JanusGraphManagement; +import org.janusgraph.core.schema.JanusGraphManagement.IndexBuilder; + +public class ManageJanusGraphSchema { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(ManageJanusGraphSchema.class); + + private JanusGraphManagement graphMgmt; + private JanusGraph graph; + private List aaiProperties; + private List aaiIndexes; + private List aaiEdgeProperties; + private Auditor oxmInfo = null; + private Auditor graphInfo = null; + + /** + * Instantiates a new manage JanusGraph schema. + * + * @param graph the graph + */ + public ManageJanusGraphSchema(final JanusGraph graph) { + this.graph = graph; + oxmInfo = AuditorFactory.getOXMAuditor(Version.v8); + graphInfo = AuditorFactory.getGraphAuditor(graph); + } + + + /** + * Builds the schema. + */ + public void buildSchema() { + + this.graphMgmt = graph.openManagement(); + aaiProperties = new ArrayList<>(); + aaiEdgeProperties = new ArrayList<>(); + aaiIndexes = new ArrayList<>(); + aaiProperties.addAll(oxmInfo.getAuditDoc().getProperties()); + aaiIndexes.addAll(oxmInfo.getAuditDoc().getIndexes()); + aaiEdgeProperties.addAll(oxmInfo.getAuditDoc().getEdgeLabels()); + try { + createPropertyKeys(); + createIndexes(); + createEdgeLabels(); + } catch (Exception e) { + logger.error(e.getMessage(),e); + graphMgmt.rollback(); + } + graphMgmt.commit(); + } + + /** + * Creates the property keys. + */ + private void createPropertyKeys() { + + + for (DBProperty prop : aaiProperties) { + + if (graphMgmt.containsPropertyKey(prop.getName())) { + PropertyKey key = graphMgmt.getPropertyKey(prop.getName()); + boolean isChanged = false; + if (!prop.getCardinality().equals(key.cardinality())) { + isChanged = true; + } + if (!prop.getTypeClass().equals(key.dataType())) { + isChanged = true; + } + if (isChanged) { + //must modify! + this.replaceProperty(prop); + } + } else { + //create a new property key + System.out.println("Key: " + prop.getName() + " not found - adding"); + graphMgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); + } + } + + } + + /** + * Creates the indexes. + */ + private void createIndexes() { + + for (DBIndex index : aaiIndexes) { + Set props = index.getProperties(); + boolean isChanged = false; + boolean isNew = false; + List keyList = new ArrayList<>(); + for (DBProperty prop : props) { + keyList.add(graphMgmt.getPropertyKey(prop.getName())); + } + if (graphMgmt.containsGraphIndex(index.getName())) { + JanusGraphIndex JanusGraphIndex = graphMgmt.getGraphIndex(index.getName()); + PropertyKey[] dbKeys = JanusGraphIndex.getFieldKeys(); + if (dbKeys.length != keyList.size()) { + isChanged = true; + } else { + int i = 0; + for (PropertyKey key : keyList) { + if (!dbKeys[i].equals(key)) { + isChanged = true; + break; + } + i++; + } + } + } else { + isNew = true; + } + if (keyList.size() > 0) { + this.createIndex(graphMgmt, index.getName(), keyList, index.isUnique(), isNew, isChanged); + } + } + } + + // Use EdgeRules to make sure edgeLabels are defined in the db. NOTE: the multiplicty used here is + // always "MULTI". This is not the same as our internal "Many2Many", "One2One", "One2Many" or "Many2One" + // We use the same edge-label for edges between many different types of nodes and our internal + // multiplicty definitions depends on which two types of nodes are being connected. + /** + * Creates the edge labels. + */ + private void createEdgeLabels() { + + + for (EdgeProperty prop : aaiEdgeProperties) { + + if (graphMgmt.containsEdgeLabel(prop.getName())) { + // see what changed + } else { + graphMgmt.makeEdgeLabel(prop.getName()).multiplicity(prop.getMultiplicity()).make(); + } + + } + + + } + + /** + * Creates the property. + * + * @param mgmt the mgmt + * @param prop the prop + */ + private void createProperty(JanusGraphManagement mgmt, DBProperty prop) { + if (mgmt.containsPropertyKey(prop.getName())) { + PropertyKey key = mgmt.getPropertyKey(prop.getName()); + boolean isChanged = false; + if (!prop.getCardinality().equals(key.cardinality())) { + isChanged = true; + } + if (!prop.getTypeClass().equals(key.dataType())) { + isChanged = true; + } + if (isChanged) { + //must modify! + this.replaceProperty(prop); + } + } else { + //create a new property key + System.out.println("Key: " + prop.getName() + " not found - adding"); + mgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); + } + } + + /** + * Creates the index. + * + * @param mgmt the mgmt + * @param indexName the index name + * @param keys the keys + * @param isUnique the is unique + * @param isNew the is new + * @param isChanged the is changed + */ + private void createIndex(JanusGraphManagement mgmt, String indexName, List keys, boolean isUnique, boolean isNew, boolean isChanged) { + + /*if (isChanged) { + System.out.println("Changing index: " + indexName); + JanusGraphIndex oldIndex = mgmt.getGraphIndex(indexName); + mgmt.updateIndex(oldIndex, SchemaAction.DISABLE_INDEX); + mgmt.commit(); + //cannot remove indexes + //graphMgmt.updateIndex(oldIndex, SchemaAction.REMOVE_INDEX); + }*/ + if (isNew || isChanged) { + + if (isNew) { + IndexBuilder builder = mgmt.buildIndex(indexName,Vertex.class); + for (PropertyKey k : keys) { + builder.addKey(k); + } + if (isUnique) { + builder.unique(); + } + builder.buildCompositeIndex(); + System.out.println("Built index for " + indexName + " with keys: " + keys); + + //mgmt.commit(); + } + + //mgmt = graph.asAdmin().getManagementSystem(); + //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REGISTER_INDEX); + //mgmt.commit(); + + try { + //waitForCompletion(indexName); + //JanusGraphIndexRepair.hbaseRepair(AAIConstants.AAI_CONFIG_FILENAME, indexName, ""); + } catch (Exception e) { + graph.tx().rollback(); + graph.close(); + logger.error(e.getMessage(),e); + } + + //mgmt = graph.asAdmin().getManagementSystem(); + //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REINDEX); + + //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.ENABLE_INDEX); + + //mgmt.commit(); + + } + } + + /** + * Wait for completion. + * + * @param name the name + * @throws InterruptedException the interrupted exception + */ + private void waitForCompletion(String name) throws InterruptedException { + + boolean registered = false; + long before = System.currentTimeMillis(); + while (!registered) { + Thread.sleep(500L); + JanusGraphManagement mgmt = graph.openManagement(); + JanusGraphIndex idx = mgmt.getGraphIndex(name); + registered = true; + for (PropertyKey k : idx.getFieldKeys()) { + SchemaStatus s = idx.getIndexStatus(k); + registered &= s.equals(SchemaStatus.REGISTERED); + } + mgmt.rollback(); + } + System.out.println("Index REGISTERED in " + (System.currentTimeMillis() - before) + " ms"); + } + + /** + * Replace property. + * + * @param key the key + */ + private void replaceProperty(DBProperty key) { + + + + + } + + /** + * Update index. + * + * @param index the index + */ + public void updateIndex(DBIndex index) { + + JanusGraphManagement mgmt = graph.openManagement(); + List keys = new ArrayList<>(); + boolean isNew = false; + boolean isChanged = false; + for (DBProperty prop : index.getProperties()) { + createProperty(mgmt, prop); + keys.add(mgmt.getPropertyKey(prop.getName())); + } + if (mgmt.containsGraphIndex(index.getName())) { + System.out.println("index already exists"); + isNew = false; + isChanged = true; + } else { + isNew = true; + isChanged = false; + } + this.createIndex(mgmt, index.getName(), keys, index.isUnique(), isNew, isChanged); + + mgmt.commit(); + + } + + + + + +} diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/ManageTitanSchema.java b/aai-core/src/main/java/org/onap/aai/db/schema/ManageTitanSchema.java deleted file mode 100644 index c696d88d..00000000 --- a/aai-core/src/main/java/org/onap/aai/db/schema/ManageTitanSchema.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * ============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.db.schema; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.apache.tinkerpop.gremlin.structure.Vertex; - -import org.onap.aai.introspection.Version; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.SchemaStatus; -import com.thinkaurelius.titan.core.schema.TitanGraphIndex; -import com.thinkaurelius.titan.core.schema.TitanManagement; -import com.thinkaurelius.titan.core.schema.TitanManagement.IndexBuilder; - -public class ManageTitanSchema { - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(AuditOXM.class); - - private TitanManagement graphMgmt; - private TitanGraph graph; - private List aaiProperties; - private List aaiIndexes; - private List aaiEdgeProperties; - private Auditor oxmInfo = null; - private Auditor graphInfo = null; - - /** - * Instantiates a new manage titan schema. - * - * @param graph the graph - */ - public ManageTitanSchema(final TitanGraph graph) { - this.graph = graph; - oxmInfo = AuditorFactory.getOXMAuditor(Version.v8); - graphInfo = AuditorFactory.getGraphAuditor(graph); - } - - - /** - * Builds the schema. - */ - public void buildSchema() { - - this.graphMgmt = graph.openManagement(); - aaiProperties = new ArrayList<>(); - aaiEdgeProperties = new ArrayList<>(); - aaiIndexes = new ArrayList<>(); - aaiProperties.addAll(oxmInfo.getAuditDoc().getProperties()); - aaiIndexes.addAll(oxmInfo.getAuditDoc().getIndexes()); - aaiEdgeProperties.addAll(oxmInfo.getAuditDoc().getEdgeLabels()); - try { - createPropertyKeys(); - createIndexes(); - createEdgeLabels(); - } catch (Exception e) { - logger.error(e.getMessage(),e); - graphMgmt.rollback(); - } - graphMgmt.commit(); - } - - /** - * Creates the property keys. - */ - private void createPropertyKeys() { - - - for (DBProperty prop : aaiProperties) { - - if (graphMgmt.containsPropertyKey(prop.getName())) { - PropertyKey key = graphMgmt.getPropertyKey(prop.getName()); - boolean isChanged = false; - if (!prop.getCardinality().equals(key.cardinality())) { - isChanged = true; - } - if (!prop.getTypeClass().equals(key.dataType())) { - isChanged = true; - } - if (isChanged) { - //must modify! - this.replaceProperty(prop); - } - } else { - //create a new property key - System.out.println("Key: " + prop.getName() + " not found - adding"); - graphMgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); - } - } - - } - - /** - * Creates the indexes. - */ - private void createIndexes() { - - for (DBIndex index : aaiIndexes) { - Set props = index.getProperties(); - boolean isChanged = false; - boolean isNew = false; - List keyList = new ArrayList<>(); - for (DBProperty prop : props) { - keyList.add(graphMgmt.getPropertyKey(prop.getName())); - } - if (graphMgmt.containsGraphIndex(index.getName())) { - TitanGraphIndex titanIndex = graphMgmt.getGraphIndex(index.getName()); - PropertyKey[] dbKeys = titanIndex.getFieldKeys(); - if (dbKeys.length != keyList.size()) { - isChanged = true; - } else { - int i = 0; - for (PropertyKey key : keyList) { - if (!dbKeys[i].equals(key)) { - isChanged = true; - break; - } - i++; - } - } - } else { - isNew = true; - } - if (keyList.size() > 0) { - this.createIndex(graphMgmt, index.getName(), keyList, index.isUnique(), isNew, isChanged); - } - } - } - - // Use EdgeRules to make sure edgeLabels are defined in the db. NOTE: the multiplicty used here is - // always "MULTI". This is not the same as our internal "Many2Many", "One2One", "One2Many" or "Many2One" - // We use the same edge-label for edges between many different types of nodes and our internal - // multiplicty definitions depends on which two types of nodes are being connected. - /** - * Creates the edge labels. - */ - private void createEdgeLabels() { - - - for (EdgeProperty prop : aaiEdgeProperties) { - - if (graphMgmt.containsEdgeLabel(prop.getName())) { - // see what changed - } else { - graphMgmt.makeEdgeLabel(prop.getName()).multiplicity(prop.getMultiplicity()).make(); - } - - } - - - } - - /** - * Creates the property. - * - * @param mgmt the mgmt - * @param prop the prop - */ - private void createProperty(TitanManagement mgmt, DBProperty prop) { - if (mgmt.containsPropertyKey(prop.getName())) { - PropertyKey key = mgmt.getPropertyKey(prop.getName()); - boolean isChanged = false; - if (!prop.getCardinality().equals(key.cardinality())) { - isChanged = true; - } - if (!prop.getTypeClass().equals(key.dataType())) { - isChanged = true; - } - if (isChanged) { - //must modify! - this.replaceProperty(prop); - } - } else { - //create a new property key - System.out.println("Key: " + prop.getName() + " not found - adding"); - mgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); - } - } - - /** - * Creates the index. - * - * @param mgmt the mgmt - * @param indexName the index name - * @param keys the keys - * @param isUnique the is unique - * @param isNew the is new - * @param isChanged the is changed - */ - private void createIndex(TitanManagement mgmt, String indexName, List keys, boolean isUnique, boolean isNew, boolean isChanged) { - - /*if (isChanged) { - System.out.println("Changing index: " + indexName); - TitanGraphIndex oldIndex = mgmt.getGraphIndex(indexName); - mgmt.updateIndex(oldIndex, SchemaAction.DISABLE_INDEX); - mgmt.commit(); - //cannot remove indexes - //graphMgmt.updateIndex(oldIndex, SchemaAction.REMOVE_INDEX); - }*/ - if (isNew || isChanged) { - - if (isNew) { - IndexBuilder builder = mgmt.buildIndex(indexName,Vertex.class); - for (PropertyKey k : keys) { - builder.addKey(k); - } - if (isUnique) { - builder.unique(); - } - builder.buildCompositeIndex(); - System.out.println("Built index for " + indexName + " with keys: " + keys); - - //mgmt.commit(); - } - - //mgmt = graph.asAdmin().getManagementSystem(); - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REGISTER_INDEX); - //mgmt.commit(); - - try { - //waitForCompletion(indexName); - //TitanIndexRepair.hbaseRepair(AAIConstants.AAI_CONFIG_FILENAME, indexName, ""); - } catch (Exception e) { - graph.tx().rollback(); - graph.close(); - logger.error(e.getMessage(),e); - } - - //mgmt = graph.asAdmin().getManagementSystem(); - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REINDEX); - - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.ENABLE_INDEX); - - //mgmt.commit(); - - } - } - - /** - * Wait for completion. - * - * @param name the name - * @throws InterruptedException the interrupted exception - */ - private void waitForCompletion(String name) throws InterruptedException { - - boolean registered = false; - long before = System.currentTimeMillis(); - while (!registered) { - Thread.sleep(500L); - TitanManagement mgmt = graph.openManagement(); - TitanGraphIndex idx = mgmt.getGraphIndex(name); - registered = true; - for (PropertyKey k : idx.getFieldKeys()) { - SchemaStatus s = idx.getIndexStatus(k); - registered &= s.equals(SchemaStatus.REGISTERED); - } - mgmt.rollback(); - } - System.out.println("Index REGISTERED in " + (System.currentTimeMillis() - before) + " ms"); - } - - /** - * Replace property. - * - * @param key the key - */ - private void replaceProperty(DBProperty key) { - - - - - } - - /** - * Update index. - * - * @param index the index - */ - public void updateIndex(DBIndex index) { - - TitanManagement mgmt = graph.openManagement(); - List keys = new ArrayList<>(); - boolean isNew = false; - boolean isChanged = false; - for (DBProperty prop : index.getProperties()) { - createProperty(mgmt, prop); - keys.add(mgmt.getPropertyKey(prop.getName())); - } - if (mgmt.containsGraphIndex(index.getName())) { - System.out.println("index already exists"); - isNew = false; - isChanged = true; - } else { - isNew = true; - isChanged = false; - } - this.createIndex(mgmt, index.getName(), keys, index.isUnique(), isNew, isChanged); - - mgmt.commit(); - - } - - - - - -} diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/ScriptDriver.java b/aai-core/src/main/java/org/onap/aai/db/schema/ScriptDriver.java index 7385ea5f..d6e32d2d 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/ScriptDriver.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/ScriptDriver.java @@ -34,8 +34,8 @@ import org.onap.aai.logging.LoggingContext.StatusCode; import org.onap.aai.util.AAIConfig; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; public class ScriptDriver { @@ -69,7 +69,7 @@ public class ScriptDriver { } String config = cArgs.config; AAIConfig.init(); - try (TitanGraph graph = TitanFactory.open(new AAIGraphConfig.Builder(config).forService(ScriptDriver.class.getSimpleName()).withGraphType("NA").buildConfiguration())) { + try (JanusGraph graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(config).forService(ScriptDriver.class.getSimpleName()).withGraphType("NA").buildConfiguration())) { if (!("oxm".equals(cArgs.type) || "graph".equals(cArgs.type))) { System.out.println("type: " + cArgs.type + " not recognized."); System.exit(1); diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/DataGrooming.java b/aai-core/src/main/java/org/onap/aai/dbgen/DataGrooming.java index f201a57e..c5de1d61 100644 --- a/aai-core/src/main/java/org/onap/aai/dbgen/DataGrooming.java +++ b/aai-core/src/main/java/org/onap/aai/dbgen/DataGrooming.java @@ -66,8 +66,8 @@ import org.onap.aai.logging.LoggingContext.StatusCode; 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; public class DataGrooming { @@ -379,8 +379,8 @@ public class DataGrooming { int cleanupCandidateCount = 0; long windowStartTime = 0; // Translation of the window into a starting timestamp BufferedWriter bw = null; - TitanGraph graph = null; - TitanGraph graph2 = null; + JanusGraph graph = null; + JanusGraph graph2 = null; int deleteCount = 0; boolean executeFinalCommit = false; Set deleteCandidateList = new LinkedHashSet<>(); @@ -440,10 +440,10 @@ public class DataGrooming { if( cacheDbOkFlag ){ // Since we're just reading (not deleting/fixing anything), we can use // a cached connection to the DB - graph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.CACHED_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("cached").buildConfiguration()); + graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.CACHED_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("cached").buildConfiguration()); } else { - graph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("realtime1").buildConfiguration()); + graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("realtime1").buildConfiguration()); } if (graph == null) { String emsg = "null graph object in DataGrooming\n"; @@ -771,7 +771,7 @@ public class DataGrooming { logger.debug(" ---- DEBUG --- about to open a SECOND graph (takes a little while)--------\n"); // Note - graph2 just reads - but we want it to use a fresh connection to // the database, so we are NOT using the CACHED DB CONFIG here. - graph2 = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("realtime2").buildConfiguration()); + graph2 = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DataGrooming.class.getSimpleName()).withGraphType("realtime2").buildConfiguration()); if (graph2 == null) { String emsg = "null graph2 object in DataGrooming\n"; throw new AAIException("AAI_6101", emsg); @@ -1425,7 +1425,7 @@ public class DataGrooming { } g.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 LoggingContext.statusCode(StatusCode.ERROR); LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); logger.warn("WARNING from final graphTransaction.rollback()", ex); @@ -1438,7 +1438,7 @@ public class DataGrooming { try { g2.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 LoggingContext.statusCode(StatusCode.ERROR); LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); logger.warn("WARNING from final graphTransaction2.rollback()", ex); @@ -1452,7 +1452,7 @@ public class DataGrooming { 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{ LoggingContext.statusCode(StatusCode.ERROR); LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); logger.warn("WARNING from final graph.shutdown()", ex); @@ -1464,7 +1464,7 @@ public class DataGrooming { graph2.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{ LoggingContext.statusCode(StatusCode.ERROR); LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); logger.warn("WARNING from final graph2.shutdown()", ex); @@ -2085,7 +2085,7 @@ public class DataGrooming { String transId, String fromAppId, GraphTraversalSource g, String version, String nType, ArrayList passedVertList, Loader loader) throws AAIException { - // Given a list of Titan Vertices of one nodeType (see AAI-8956), group + // Given a list of JanusGraph Vertices of one nodeType (see AAI-8956), group // them together by the parent node they depend on. // 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. diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GenTester.java b/aai-core/src/main/java/org/onap/aai/dbgen/GenTester.java index 174b157e..9a726ec5 100644 --- a/aai-core/src/main/java/org/onap/aai/dbgen/GenTester.java +++ b/aai-core/src/main/java/org/onap/aai/dbgen/GenTester.java @@ -22,8 +22,8 @@ package org.onap.aai.dbgen; 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.schema.TitanManagement; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.JanusGraphManagement; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.logging.ErrorLogHelper; import org.onap.aai.logging.LoggingContext; @@ -46,7 +46,7 @@ public class GenTester { */ public static void main(String[] args) { - TitanGraph graph = null; + JanusGraph graph = null; System.setProperty("aai.service.name", GenTester.class.getSimpleName()); // Set the logging file properties to be used by EELFManager Properties props = System.getProperties(); @@ -81,11 +81,11 @@ public class GenTester { graph = AAIGraph.getInstance().getGraph(); if( graph == null ){ - ErrorLogHelper.logError("AAI_5102", "Error creating Titan graph."); + ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph."); return; } else { - String amsg = "Successfully loaded a Titan graph without doing any schema work. "; + String amsg = "Successfully loaded a JanusGraph graph without doing any schema work. "; System.out.println(amsg); LOGGER.auditEvent(amsg); return; @@ -118,17 +118,17 @@ public class GenTester { graph = AAIGraph.getInstance().getGraph(); if( graph == null ){ - ErrorLogHelper.logError("AAI_5102", "Error creating Titan graph. "); + ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph. "); return; } // Load the propertyKeys, indexes and edge-Labels into the DB - TitanManagement graphMgt = graph.openManagement(); + JanusGraphManagement graphMgt = graph.openManagement(); - imsg = "-- Loading new schema elements into Titan --"; + imsg = "-- Loading new schema elements into JanusGraph --"; System.out.println(imsg); LOGGER.info(imsg); - SchemaGenerator.loadSchemaIntoTitan( graph, graphMgt, addDefaultCR ); + SchemaGenerator.loadSchemaIntoJanusGraph( graph, graphMgt, addDefaultCR ); } catch(Exception ex) { ErrorLogHelper.logError("AAI_4000", ex.getMessage()); diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java index c8b3df50..6336edd3 100644 --- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java +++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java @@ -41,11 +41,11 @@ import org.onap.aai.util.AAIConfig; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.collect.Multimap; -import com.thinkaurelius.titan.core.Cardinality; -import com.thinkaurelius.titan.core.Multiplicity; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import org.janusgraph.core.Cardinality; +import org.janusgraph.core.Multiplicity; +import org.janusgraph.core.PropertyKey; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.JanusGraphManagement; @@ -56,24 +56,24 @@ public class SchemaGenerator{ /** - * Load schema into titan. + * Load schema into JanusGraph. * * @param graph the graph * @param graphMgmt the graph mgmt * @param addDefaultCloudRegion the add default cloud region */ - public static void loadSchemaIntoTitan(final TitanGraph graph, final TitanManagement graphMgmt, boolean addDefaultCloudRegion) { + public static void loadSchemaIntoJanusGraph(final JanusGraph graph, final JanusGraphManagement graphMgmt, boolean addDefaultCloudRegion) { addDefaultCR = addDefaultCloudRegion; - loadSchemaIntoTitan(graph, graphMgmt); + loadSchemaIntoJanusGraph(graph, graphMgmt); } /** - * Load schema into titan. + * Load schema into JanusGraph. * * @param graph the graph * @param graphMgmt the graph mgmt */ - public static void loadSchemaIntoTitan(final TitanGraph graph, final TitanManagement graphMgmt) { + public static void loadSchemaIntoJanusGraph(final JanusGraph graph, final JanusGraphManagement graphMgmt) { try { AAIConfig.init(); @@ -84,8 +84,8 @@ public class SchemaGenerator{ System.exit(1); } - // NOTE - Titan 0.5.3 doesn't keep a list of legal node Labels. - // They are only used when a vertex is actually being created. Titan 1.1 will keep track (we think). + // NOTE - JanusGraph 0.5.3 doesn't keep a list of legal node Labels. + // They are only used when a vertex is actually being created. JanusGraph 1.1 will keep track (we think). // Use EdgeRules to make sure edgeLabels are defined in the db. NOTE: the multiplicty used here is @@ -186,7 +186,7 @@ public class SchemaGenerator{ LOGGER.info(imsg); graphMgmt.commit(); - }// End of loadSchemaIntoTitan() + }// End of loadSchemaIntoJanusGraph() } diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java index 46fc2c6e..0a287516 100644 --- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java +++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java @@ -37,15 +37,15 @@ import org.onap.aai.util.AAIConstants; 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 com.thinkaurelius.titan.core.schema.TitanManagement; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.JanusGraphManagement; /** * Database Mapping class which acts as the middle man between the REST - * interface objects and Titan DB objects. This class provides methods to commit - * the objects received on the REST interface into the Titan graph database as - * vertices and edges. Transactions are also managed here by using a TitanGraph + * interface objects and JanusGraph DB objects. This class provides methods to commit + * the objects received on the REST interface into the JanusGraph graph database as + * vertices and edges. Transactions are also managed here by using a JanusGraph * object to load, commit/rollback and shutdown for each request. The data model * rules such as keys/required properties are handled by calling DBMeth methods * which are driven by a specification file in json. @@ -56,7 +56,7 @@ public class AAIGraph { private static final EELFLogger logger = EELFManager.getInstance().getLogger(AAIGraph.class); protected static final String COMPONENT = "aaidbmap"; - protected Map graphs = new HashMap<>(); + protected Map graphs = new HashMap<>(); private static final String REALTIME_DB = "realtime"; private static final String CACHED_DB = "cached"; private static boolean isInit = false; @@ -103,11 +103,11 @@ public class AAIGraph { } private void loadGraph(String name, String configPath, String serviceName) throws Exception { - // Graph being opened by TitanFactory is being placed in hashmap to be used later + // Graph being opened by JanusGraphFactory is being placed in hashmap to be used later // These graphs shouldn't be closed until the application shutdown try { PropertiesConfiguration propertiesConfiguration = new AAIGraphConfig.Builder(configPath).forService(serviceName).withGraphType(name).buildConfiguration(); - TitanGraph graph = TitanFactory.open(propertiesConfiguration); + JanusGraph graph = JanusGraphFactory.open(propertiesConfiguration); Properties graphProps = new Properties(); propertiesConfiguration.getKeys().forEachRemaining(k -> graphProps.setProperty(k, propertiesConfiguration.getString(k))); @@ -130,7 +130,7 @@ public class AAIGraph { } } - private void loadSnapShotToInMemoryGraph(TitanGraph graph, Properties graphProps) { + private void loadSnapShotToInMemoryGraph(JanusGraph graph, Properties graphProps) { if (logger.isDebugEnabled()) { logger.debug("Load Snapshot to InMemory Graph"); } @@ -153,19 +153,19 @@ public class AAIGraph { } } - private void loadSchema(TitanGraph graph) { + private void loadSchema(JanusGraph graph) { // Load the propertyKeys, indexes and edge-Labels into the DB - TitanManagement graphMgt = graph.openManagement(); + JanusGraphManagement graphMgt = graph.openManagement(); - System.out.println("-- loading schema into Titan"); - SchemaGenerator.loadSchemaIntoTitan( graph, graphMgt ); + System.out.println("-- loading schema into JanusGraph"); + SchemaGenerator.loadSchemaIntoJanusGraph( graph, graphMgt ); } /** * Close all of the graph connections made in the instance. */ public void graphShutdown() { - graphs.values().stream().filter(TitanGraph::isOpen).forEach(TitanGraph::close); + graphs.values().stream().filter(JanusGraph::isOpen).forEach(JanusGraph::close); } /** @@ -173,7 +173,7 @@ public class AAIGraph { * * @return the graph */ - public TitanGraph getGraph() { + public JanusGraph getGraph() { return graphs.get(REALTIME_DB); } @@ -182,7 +182,7 @@ public class AAIGraph { graphs.get(this.getGraphName(connectionType)).close(); } - public TitanGraph getGraph(DBConnectionType connectionType) { + public JanusGraph getGraph(DBConnectionType connectionType) { return graphs.get(this.getGraphName(connectionType)); } diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java index 59a1453d..eff7f0ec 100644 --- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java +++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java @@ -24,8 +24,8 @@ import com.att.eelf.configuration.EELFManager; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; -import com.thinkaurelius.titan.diskstorage.configuration.ConfigElement; -import com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration; +import org.janusgraph.diskstorage.configuration.ConfigElement; +import org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.lang.StringUtils; @@ -37,10 +37,10 @@ import java.util.Iterator; import java.util.Objects; import java.util.regex.Pattern; -import static com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.*; +import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.*; /** - * For building a config that TitanFactory.open can use with an identifiable graph.unique-instance-id + * For building a config that JanusGraphFactory.open can use with an identifiable graph.unique-instance-id */ public class AAIGraphConfig { @@ -50,7 +50,7 @@ public class AAIGraphConfig { public PropertiesConfiguration getCc(String configPath, String graphType, String service) throws ConfigurationException, FileNotFoundException { - PropertiesConfiguration cc = this.loadTitanPropFile(configPath); + PropertiesConfiguration cc = this.loadJanusGraphPropFile(configPath); String uid = ManagementFactory.getRuntimeMXBean().getName() + "_" + service + "_" + graphType + "_" + System.currentTimeMillis(); for (char c : ConfigElement.ILLEGAL_CHARS) { @@ -63,7 +63,7 @@ public class AAIGraphConfig { } - private PropertiesConfiguration loadTitanPropFile(String shortcutOrFile) throws ConfigurationException, FileNotFoundException { + private PropertiesConfiguration loadJanusGraphPropFile(String shortcutOrFile) throws ConfigurationException, FileNotFoundException { File file = new File(shortcutOrFile); if (file.exists()) { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java index e5d4c2e0..45d0bbe4 100644 --- a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java +++ b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java @@ -30,10 +30,10 @@ import org.apache.tinkerpop.gremlin.structure.io.IoCore; import org.onap.aai.dbgen.SchemaGenerator; import org.onap.aai.logging.LogFormatTools; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanTransaction; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphTransaction; +import org.janusgraph.core.schema.JanusGraphManagement; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -41,7 +41,7 @@ import com.att.eelf.configuration.EELFManager; public class InMemoryGraph { private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(InMemoryGraph.class); - private TitanGraph graph = null; + private JanusGraph graph = null; public InMemoryGraph(Builder builder) throws IOException { @@ -50,16 +50,16 @@ public class InMemoryGraph { */ InputStream is = new FileInputStream(builder.propertyFile); try { - graph = TitanFactory.open(builder.propertyFile); + graph = JanusGraphFactory.open(builder.propertyFile); Properties graphProps = new Properties(); graphProps.load(is); - TitanManagement graphMgt = graph.openManagement(); + JanusGraphManagement graphMgt = graph.openManagement(); if(builder.isSchemaEnabled){ LOGGER.info("Schema Enabled"); - SchemaGenerator.loadSchemaIntoTitan(graph, graphMgt); + SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt); } - TitanTransaction transaction = graph.newTransaction(); + JanusGraphTransaction transaction = graph.newTransaction(); LOGGER.info("Loading snapshot"); transaction.io(IoCore.graphson()).readGraph(builder.graphsonLocation); transaction.commit(); @@ -97,7 +97,7 @@ public class InMemoryGraph { } } - public TitanGraph getGraph() { + public JanusGraph getGraph() { return graph; } diff --git a/aai-core/src/main/java/org/onap/aai/extensions/AAIExtensionMap.java b/aai-core/src/main/java/org/onap/aai/extensions/AAIExtensionMap.java index eff781c3..7b125496 100644 --- a/aai-core/src/main/java/org/onap/aai/extensions/AAIExtensionMap.java +++ b/aai-core/src/main/java/org/onap/aai/extensions/AAIExtensionMap.java @@ -67,7 +67,7 @@ public class AAIExtensionMap { // ----------------------------------------------------------------------- // postExtSkipErrorCallback | java.lang.Boolean (RW) // ----------------------------------------------------------------------- - // graph | com.thinkaurelius.titan.core.TitanGraph (RW) + // graph | org.janusgraph.core.JanusGraph (RW) // ----------------------------------------------------------------------- // objectFromResponse | Object // ----------------------------------------------------------------------- diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java index 67b46bfb..28af6a55 100644 --- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java +++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java @@ -68,7 +68,7 @@ import org.onap.aai.restcore.HttpMethod; import org.onap.aai.schema.enums.ObjectMetadata; import org.onap.aai.serialization.db.DBSerializer; 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.serialization.engines.query.QueryEngine; @@ -78,7 +78,10 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.fge.jsonpatch.JsonPatchException; import com.github.fge.jsonpatch.mergepatch.JsonMergePatch; -import com.thinkaurelius.titan.core.TitanException; +import org.janusgraph.core.JanusGraphException; +import org.onap.aai.serialization.queryformats.Format; +import org.onap.aai.serialization.queryformats.FormatFactory; +import org.onap.aai.serialization.queryformats.Formatter; /** * The Class HttpEntry. @@ -113,7 +116,7 @@ public class HttpEntry { this.queryStyle = queryStyle; this.version = version; this.loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - this.dbEngine = new TitanDBEngine( + this.dbEngine = new JanusGraphDBEngine( queryStyle, connectionType, loader); @@ -281,7 +284,7 @@ public class HttpEntry { status = Status.OK; MarshallerProperties properties; if (!request.getMarshallerProperties().isPresent()) { - properties = + properties = new MarshallerProperties.Builder(org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build(); } else { properties = request.getMarshallerProperties().get(); @@ -450,7 +453,7 @@ public class HttpEntry { responses.add(pairedResp); //break out of retry loop break; - } catch (TitanException e) { + } catch (JanusGraphException e) { this.dbEngine.rollback(); LOGGER.info ("Caught exception: " + e.getMessage()); @@ -586,9 +589,9 @@ public class HttpEntry { depth = AAIProperties.MAXIMUM_DEPTH; } } else { - if (depthParam.length() > 0 && !depthParam.equals("all")){ + if (!depthParam.isEmpty() && !"all".equals(depthParam)){ try { - depth = Integer.valueOf(depthParam); + depth = Integer.parseInt(depthParam); } catch (Exception e) { throw new AAIException("AAI_4016"); } diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java index 9b57e48e..67a5edb3 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java @@ -23,7 +23,7 @@ package org.onap.aai.serialization.db; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.base.CaseFormat; -import com.thinkaurelius.titan.core.SchemaViolationException; +import org.janusgraph.core.SchemaViolationException; import org.apache.commons.collections.IteratorUtils; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java index c90e1eee..d70a7ee7 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java @@ -19,7 +19,7 @@ */ package org.onap.aai.serialization.db; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraph; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.dbmap.DBConnectionType; @@ -58,11 +58,11 @@ public class GraphSingleton { * * @return the tx graph */ - public TitanGraph getTxGraph() { + public JanusGraph getTxGraph() { return AAIGraph.getInstance().getGraph(); } - public TitanGraph getTxGraph(DBConnectionType connectionType) { + public JanusGraph getTxGraph(DBConnectionType connectionType) { return AAIGraph.getInstance().getGraph(connectionType); } } diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/InMemoryGraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/InMemoryGraphSingleton.java index 369161ac..0f4c3e7d 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/InMemoryGraphSingleton.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/InMemoryGraphSingleton.java @@ -21,22 +21,22 @@ package org.onap.aai.serialization.db; import org.onap.aai.dbmap.DBConnectionType; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraph; public class InMemoryGraphSingleton extends GraphSingleton { - private static TitanGraph inMemgraph; + private static JanusGraph inMemgraph; private static class Helper { private static final InMemoryGraphSingleton INSTANCE = new InMemoryGraphSingleton(); } /** - * Gets the single instance of TitanGraphSingleton. + * Gets the single instance of JanusGraphSingleton. * - * @return single instance of TitanGraphSingleton + * @return single instance of JanusGraphSingleton */ - public static InMemoryGraphSingleton getInstance(TitanGraph graph) { + public static InMemoryGraphSingleton getInstance(JanusGraph graph) { inMemgraph = graph; return Helper.INSTANCE; } @@ -47,12 +47,12 @@ public class InMemoryGraphSingleton extends GraphSingleton { * @return the tx graph */ @Override - public TitanGraph getTxGraph() { + public JanusGraph getTxGraph() { return inMemgraph; } @Override - public TitanGraph getTxGraph(DBConnectionType connectionType) { + public JanusGraph getTxGraph(DBConnectionType connectionType) { return inMemgraph; } } diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/JanusGraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/JanusGraphSingleton.java new file mode 100644 index 00000000..4513d107 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/JanusGraphSingleton.java @@ -0,0 +1,37 @@ +/** + * ============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.serialization.db; + +/* This is class is just a wrapper of its parent */ +public class JanusGraphSingleton extends GraphSingleton { + + private static class Helper { + private static final JanusGraphSingleton INSTANCE = new JanusGraphSingleton(); + } + + /** + * Gets the single instance of JanusGraphSingleton. + * + * @return single instance of JanusGraphSingleton + */ + public static JanusGraphSingleton getInstance() { + return Helper.INSTANCE; + } +} diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/TitanGraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/TitanGraphSingleton.java deleted file mode 100644 index 4c1f3181..00000000 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/TitanGraphSingleton.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * ============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.serialization.db; - -/* This is class is just a wrapper of its parent */ -public class TitanGraphSingleton extends GraphSingleton { - - private static class Helper { - private static final TitanGraphSingleton INSTANCE = new TitanGraphSingleton(); - } - - /** - * Gets the single instance of TitanGraphSingleton. - * - * @return single instance of TitanGraphSingleton - */ - public static TitanGraphSingleton getInstance() { - return Helper.INSTANCE; - } -} diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java index a7aef9da..ec52a002 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java @@ -22,6 +22,7 @@ package org.onap.aai.serialization.engines; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -39,29 +40,29 @@ import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine; import org.onap.aai.serialization.engines.query.QueryEngine; import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraph; public class InMemoryDBEngine extends TransactionalGraphEngine { /** - * Instantiates a new titan DB engine. + * Instantiates a new JanusGraph DB engine. * * @param style * the style * @param loader * the loader */ - private TitanGraph graph = null; + private JanusGraph graph = null; private static final TransactionalGraphEngine.Admin admin = null; - public InMemoryDBEngine(QueryStyle style, DBConnectionType connectionType, Loader loader, TitanGraph graph) { + public InMemoryDBEngine(QueryStyle style, DBConnectionType connectionType, Loader loader, JanusGraph graph) { super(style, loader, connectionType, InMemoryGraphSingleton.getInstance(graph)); this.graph = graph; } /** - * Instantiates a new titan DB engine. + * Instantiates a new JanusGraph DB engine. * * @param style * the style @@ -70,7 +71,7 @@ public class InMemoryDBEngine extends TransactionalGraphEngine { * @param connect * the connect */ - public InMemoryDBEngine(QueryStyle style, Loader loader, boolean connect, TitanGraph graph) { + public InMemoryDBEngine(QueryStyle style, Loader loader, boolean connect, JanusGraph graph) { super(style, loader); if (connect) { this.singleton = InMemoryGraphSingleton.getInstance(graph); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java new file mode 100644 index 00000000..c12aa603 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.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.serialization.engines; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.onap.aai.dbmap.DBConnectionType; +import org.onap.aai.introspection.Loader; +import org.onap.aai.serialization.db.JanusGraphSingleton; + +public class JanusGraphDBEngine extends TransactionalGraphEngine { + + /** + * Instantiates a new JanusGraph DB engine. + * + * @param style the style + * @param loader the loader + */ + public JanusGraphDBEngine(QueryStyle style, DBConnectionType connectionType, Loader loader) { + super(style, loader, connectionType, JanusGraphSingleton.getInstance()); + } + + /** + * Instantiates a new JanusGraph DB engine. + * + * @param style the style + * @param loader the loader + * @param connect the connect + */ + public JanusGraphDBEngine(QueryStyle style, Loader loader, boolean connect) { + super(style, loader); + if (connect) { + this.singleton = JanusGraphSingleton.getInstance(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean setListProperty(Vertex v, String name, List objs) { + + //clear out list full replace style + + Iterator> iterator = v.properties(name); + while (iterator.hasNext()) { + iterator.next().remove(); + } + if (objs != null) { + for (Object obj : objs) { + v.property(name, obj); + } + } + return true; + } + + /** + * {@inheritDoc} + */ + @Override + public List getListProperty(Vertex v, String name) { + + List result = new ArrayList(); + + Iterator> iterator = v.properties(name); + + while (iterator.hasNext()) { + result.add(iterator.next().value()); + } + + if (result.size() == 0) { + result = null; + } + + return result; + + } + +} diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/TitanDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/TitanDBEngine.java deleted file mode 100644 index 4c6cb675..00000000 --- a/aai-core/src/main/java/org/onap/aai/serialization/engines/TitanDBEngine.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * ============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.serialization.engines; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.onap.aai.dbmap.DBConnectionType; -import org.onap.aai.introspection.Loader; -import org.onap.aai.serialization.db.TitanGraphSingleton; - -public class TitanDBEngine extends TransactionalGraphEngine { - - /** - * Instantiates a new titan DB engine. - * - * @param style the style - * @param loader the loader - */ - public TitanDBEngine(QueryStyle style, DBConnectionType connectionType, Loader loader) { - super(style, loader, connectionType, TitanGraphSingleton.getInstance()); - } - - /** - * Instantiates a new titan DB engine. - * - * @param style the style - * @param loader the loader - * @param connect the connect - */ - public TitanDBEngine(QueryStyle style, Loader loader, boolean connect) { - super(style, loader); - if (connect) { - this.singleton = TitanGraphSingleton.getInstance(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean setListProperty(Vertex v, String name, List objs) { - - //clear out list full replace style - - Iterator> iterator = v.properties(name); - while (iterator.hasNext()) { - iterator.next().remove(); - } - if (objs != null) { - for (Object obj : objs) { - v.property(name, obj); - } - } - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public List getListProperty(Vertex v, String name) { - - List result = new ArrayList(); - - Iterator> iterator = v.properties(name); - - while (iterator.hasNext()) { - result.add(iterator.next().value()); - } - - if (result.size() == 0) { - result = null; - } - - return result; - - } - -} diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java index f300bd26..8eedf00d 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java @@ -19,9 +19,6 @@ */ package org.onap.aai.serialization.engines; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -36,8 +33,11 @@ import org.onap.aai.serialization.db.GraphSingleton; import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine; import org.onap.aai.serialization.engines.query.QueryEngine; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.schema.JanusGraphManagement; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; public abstract class TransactionalGraphEngine { @@ -97,7 +97,7 @@ public abstract class TransactionalGraphEngine { * * @return the graph */ - private TitanGraph getGraph() { + private JanusGraph getGraph() { return singleton.getTxGraph(this.connectionType); } @@ -237,7 +237,7 @@ public abstract class TransactionalGraphEngine { return readOnlyTraversal; } - public TitanManagement getManagementSystem() { + public JanusGraphManagement getManagementSystem() { return getGraph().openManagement(); } } diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java index 3b803b49..4e69c9c2 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java @@ -21,7 +21,7 @@ package org.onap.aai.serialization.queryformats; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.thinkaurelius.titan.graphdb.tinkerpop.TitanIoRegistry; +import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper; @@ -33,7 +33,7 @@ import java.io.OutputStream; public class GraphSON implements FormatMapper { - private final GraphSONMapper mapper = GraphSONMapper.build().addRegistry(TitanIoRegistry.INSTANCE).create(); + private final GraphSONMapper mapper = GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create(); private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create(); protected JsonParser parser = new JsonParser(); diff --git a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java index 181b499d..f438d16b 100644 --- a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java +++ b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java @@ -41,8 +41,8 @@ public final class AAIConstants { public static final String AAI_AUTH_CONFIG_FILENAME = AAI_HOME_ETC_AUTH + "aai_policy.json"; public static final String AAI_MECHID_CONFIG_FILENAME = AAI_HOME_ETC_APP_PROPERTIES + "mechIds.json"; public static final String AAI_HOME_ETC_QUERY = AAI_HOME_ETC + "query" + AAI_FILESEP + "stored-queries.properties"; - public static final String REALTIME_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "titan-realtime.properties"; - public static final String CACHED_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "titan-cached.properties"; + public static final String REALTIME_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-realtime.properties"; + public static final String CACHED_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-cached.properties"; public static final String AAI_HOME_ETC_OXM = AAI_HOME_ETC + "oxm" + AAI_FILESEP; public static final String AAI_EVENT_DMAAP_PROPS = AAI_HOME_ETC_APP_PROPERTIES + "aaiEventDMaaPPublisher.properties"; public static final String AAI_HOME_ETC_SCRIPT = AAI_HOME_ETC + AAI_FILESEP + "scriptdata" + AAI_FILESEP; diff --git a/aai-core/src/main/java/org/onap/aai/util/UniquePropertyCheck.java b/aai-core/src/main/java/org/onap/aai/util/UniquePropertyCheck.java index 512ac755..bfa0f3a1 100644 --- a/aai-core/src/main/java/org/onap/aai/util/UniquePropertyCheck.java +++ b/aai-core/src/main/java/org/onap/aai/util/UniquePropertyCheck.java @@ -37,8 +37,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; import org.onap.aai.dbmap.AAIGraphConfig; public class UniquePropertyCheck { @@ -87,12 +87,12 @@ public class UniquePropertyCheck { try { AAIConfig.init(); System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n"); - TitanGraph tGraph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(UniquePropertyCheck.class.getSimpleName()).withGraphType("realtime").buildConfiguration()); + JanusGraph tGraph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(UniquePropertyCheck.class.getSimpleName()).withGraphType("realtime").buildConfiguration()); if( tGraph == null ) { LoggingContext.statusCode(StatusCode.ERROR); LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logAndPrint(logger, " Error: Could not get TitanGraph "); + logAndPrint(logger, " Error: Could not get JanusGraph "); System.exit(1); } diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/YAMLfromOXM.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/YAMLfromOXM.java index ff7d44b6..ce5406a6 100644 --- a/aai-core/src/main/java/org/onap/aai/util/genxsd/YAMLfromOXM.java +++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/YAMLfromOXM.java @@ -287,12 +287,6 @@ public class YAMLfromOXM extends OxmFileProcessor { for ( int k = 0; addTypeV != null && k < addTypeV.size(); ++k ) { String addType = addTypeV.elementAt(k); logger.debug("addType: "+ addType); - if(addType == "overloaded-model" || addType.equals("OverloadedModel") || addType == "owning-entity") { - logger.debug("Description check: "+ addType+"opId="+opId+" itemName=none"); -// Log.info("Element name="+xmlElementElement.getAttribute("name")); - } - - if ( opId == null || !opId.contains(addType)) { processJavaTypeElementSwagger( addType, getJavaTypeElementSwagger(addType), pathSb, definitionsSb, path, tag == null ? useTag : tag, useOpId, null, diff --git a/aai-core/src/main/resources/logback.xml b/aai-core/src/main/resources/logback.xml new file mode 100644 index 00000000..2bf42b76 --- /dev/null +++ b/aai-core/src/main/resources/logback.xml @@ -0,0 +1,391 @@ + + + + + + + + + + + + + + + + + + + + + + + + + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx} + + + + + + ${logDirectory}/rest/sane.log + + ${logDirectory}/rest/sane.log.%d{yyyy-MM-dd} + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + 1000 + true + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/rest/metrics.log + + ${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd} + + + + ${eelfMetricLogPattern} + + + + 1000 + true + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/debug.log + + ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + 1000 + true + + + + + + WARN + + ${logDirectory}/rest/error.log + + ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + + + + ${eelfErrorLogPattern} + + + + + 1000 + true + + + + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/audit.log.%d{yyyy-MM-dd} + + + + ${eelfAuditLogPattern} + + + + + 1000 + true + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/translog.log + + ${logDirectory}/rest/translog.log.%d{yyyy-MM-dd} + + + + ${eelfTransLogPattern} + + + + + 1000 + true + + + + + + WARN + + ${logDirectory}/dmaapAAIEventConsumer/error.log + + ${logDirectory}/dmaapAAIEventConsumer/error.log.%d{yyyy-MM-dd} + + + + ${eelfErrorLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/debug.log + + ${logDirectory}/dmaapAAIEventConsumer/debug.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log.%d{yyyy-MM-dd} + + + + ${eelfMetricLogPattern} + + + + + WARN + + ${logDirectory}/external/external.log + + ${logDirectory}/external/external.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.log + + + ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.log + + + ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java b/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java index 4c472ccc..fbff5d06 100644 --- a/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java +++ b/aai-core/src/test/java/org/onap/aai/dbmap/AAIGraphTest.java @@ -19,9 +19,9 @@ */ package org.onap.aai.dbmap; -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.hamcrest.CoreMatchers; import org.junit.*; import org.onap.aai.AAISetup; @@ -44,7 +44,7 @@ public class AAIGraphTest extends AAISetup{ @Test public void getRealtimeInstanceConnectionName() throws Exception { - TitanManagement graphMgt = AAIGraph.getInstance().getGraph().openManagement(); + JanusGraphManagement graphMgt = AAIGraph.getInstance().getGraph().openManagement(); String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get(); assertThat(connectionInstanceName, containsString(SERVICE_NAME)); assertThat(connectionInstanceName, containsString("realtime")); @@ -55,7 +55,7 @@ public class AAIGraphTest extends AAISetup{ @Test public void getCachedInstanceConnectionName() throws Exception { - TitanManagement graphMgt = AAIGraph.getInstance().getGraph(DBConnectionType.CACHED).openManagement(); + JanusGraphManagement graphMgt = AAIGraph.getInstance().getGraph(DBConnectionType.CACHED).openManagement(); String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get(); assertThat(connectionInstanceName, containsString(SERVICE_NAME)); assertThat(connectionInstanceName, containsString("cached")); @@ -64,9 +64,9 @@ public class AAIGraphTest extends AAISetup{ } @Test - public void titanGraphOpenNameTest() throws Exception{ - TitanGraph graph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(SERVICE_NAME).withGraphType("graphType").buildConfiguration()); - TitanManagement graphMgt = graph.openManagement(); + public void JanusGraphOpenNameTest() throws Exception{ + JanusGraph graph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(SERVICE_NAME).withGraphType("graphType").buildConfiguration()); + JanusGraphManagement graphMgt = graph.openManagement(); String connectionInstanceName = graphMgt.getOpenInstances().stream().filter(c -> c.contains("current")).findFirst().get(); assertThat(connectionInstanceName,matchesPattern("^\\d+_[\\w\\-\\d]+_" + SERVICE_NAME + "_graphType_\\d+\\(current\\)$")); graphMgt.rollback(); diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java index 27efbdb2..621f24d8 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataCopyTest.java @@ -19,8 +19,8 @@ */ package org.onap.aai.introspection.sideeffect; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; import org.apache.commons.io.IOUtils; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -41,7 +41,7 @@ import org.onap.aai.parsers.query.QueryParser; import org.onap.aai.serialization.db.DBSerializer; 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 java.io.FileInputStream; @@ -60,7 +60,7 @@ import static org.mockito.Mockito.when; @RunWith(value = Parameterized.class) public class DataCopyTest { - private static TitanGraph graph; + private static JanusGraph graph; private final static Version version = Version.getLatest(); private final static ModelType introspectorFactoryType = ModelType.MOXY; private final static DBConnectionType type = DBConnectionType.REALTIME; @@ -84,7 +84,7 @@ public class DataCopyTest { @BeforeClass public static void setup() throws NoSuchFieldException, SecurityException, Exception { - graph = TitanFactory.build().set("storage.backend","inmemory").open(); + graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); System.setProperty("AJSC_HOME", "."); System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); @@ -107,7 +107,7 @@ public class DataCopyTest { @Before public void initMock() { MockitoAnnotations.initMocks(this); - dbEngine = new TitanDBEngine( + dbEngine = new JanusGraphDBEngine( queryStyle, type, loader); diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java index 59fe8b86..d44c6cc3 100644 --- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java +++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/DataLinkTest.java @@ -19,12 +19,17 @@ */ package org.onap.aai.introspection.sideeffect; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.schema.JanusGraphManagement; +import org.janusgraph.core.JanusGraph; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import org.junit.*; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; @@ -37,10 +42,11 @@ import org.onap.aai.dbmap.DBConnectionType; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; import org.onap.aai.parsers.query.QueryParser; +import org.onap.aai.serialization.db.AAIDirection; import org.onap.aai.serialization.db.DBSerializer; 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 java.io.UnsupportedEncodingException; @@ -49,16 +55,17 @@ import java.net.MalformedURLException; import java.net.URISyntaxException; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @RunWith(value = Parameterized.class) public class DataLinkTest extends AAISetup { - private static TitanGraph graph; + private static JanusGraph graph; private final static Version version = Version.getLatest(); private final static ModelType introspectorFactoryType = ModelType.MOXY; private final static DBConnectionType type = DBConnectionType.REALTIME; @@ -82,7 +89,7 @@ public class DataLinkTest extends AAISetup { @BeforeClass public static void setup() throws NoSuchFieldException, SecurityException, Exception { - graph = TitanFactory.build().set("storage.backend","inmemory").open(); + graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); graph.traversal().addV("aai-node-type", "vpn-binding", "vpn-id", "addKey", AAIProperties.AAI_URI, "/network/vpn-bindings/vpn-binding/addKey").as("v1") @@ -113,7 +120,7 @@ public class DataLinkTest extends AAISetup { @Before public void initMock() { MockitoAnnotations.initMocks(this); - dbEngine = new TitanDBEngine( + dbEngine = new JanusGraphDBEngine( queryStyle, type, loader); @@ -131,6 +138,24 @@ public class DataLinkTest extends AAISetup { TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); Graph g = graph.newTransaction(); GraphTraversalSource traversal = g.traversal(); +// Graph g = graph.newTransaction(); +// GraphTraversalSource traversal = g; + System.out.println("Begin method inventory:"); + Iterator vertexItr = traversal.V(); + while( vertexItr != null && vertexItr.hasNext() ){ + Vertex v = vertexItr.next(); + System.out.println("\nnodeType="+v.property("aai-node-type")); + for(String key: v.keys()) { + System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+";id= "+v.id()); + } + Direction d = null; + Iterator edgeItr = v.edges(Direction.BOTH); + while( edgeItr != null && edgeItr.hasNext() ){ + Edge e = edgeItr.next(); + System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id()); + } + } + System.out.println("End method inventory:"); when(spy.asAdmin()).thenReturn(adminSpy); when(adminSpy.getTraversalSource()).thenReturn(traversal); when(spy.tx()).thenReturn(g); @@ -158,23 +183,80 @@ public class DataLinkTest extends AAISetup { obj.setValue("route-target-role", "modifyRoleKey2"); TransactionalGraphEngine spy = spy(dbEngine); TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); +// Graph g = graph.newTransaction(); +// GraphTraversalSource traversal = g; Graph g = graph.newTransaction(); GraphTraversalSource traversal = g.traversal(); + System.out.println("Begin method inventory:"); + Iterator vertexItr = traversal.V(); + while( vertexItr != null && vertexItr.hasNext() ){ + Vertex v = vertexItr.next(); + System.out.println("\nnodeType="+v.property("aai-node-type")); + for(String key: v.keys()) { + System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id()); + } + Direction d = null; + Iterator edgeItr = v.edges(Direction.BOTH); + while( edgeItr != null && edgeItr.hasNext() ){ + Edge e = edgeItr.next(); + System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id()); + } + } + System.out.println("End method inventory:"); + when(spy.asAdmin()).thenReturn(adminSpy); when(adminSpy.getTraversalSource()).thenReturn(traversal); +// when(spy.tx()).thenReturn(graph); when(spy.tx()).thenReturn(g); when(self.property(AAIProperties.AAI_URI)).thenReturn(prop); when(prop.orElse(null)).thenReturn(obj.getURI()); DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "AAI_TEST"); SideEffectRunner runner = new SideEffectRunner .Builder(spy, serializer).addSideEffect(DataLinkWriter.class).build(); - + System.out.println("Traversal Source: "+traversal.toString()); + vertexItr = traversal.V(); + System.out.println("Begin method inventory:"); + while( vertexItr != null && vertexItr.hasNext() ){ + Vertex v = vertexItr.next(); + System.out.println("\nnodeType="+v.property("aai-node-type")); + for(String key: v.keys()) { + System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id()); + } + Iterator edgeItr = v.edges(Direction.BOTH); + while( edgeItr != null && edgeItr.hasNext() ){ + Edge e = edgeItr.next(); + System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id()); + } + } + System.out.println("End method inventory:"); + try { runner.execute(obj, self); + } catch(Exception e) { - assertEquals("route-target vertex found", true, traversal.V() - .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").has("linked", true).hasNext()); - assertEquals("previous link removed", true, traversal.V() - .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").hasNot("linked").hasNext()); + } +// runner.execute(obj, self); + System.out.println("=================\n"); + vertexItr = traversal.V(); + while( vertexItr != null && vertexItr.hasNext() ){ + Vertex v = vertexItr.next(); + System.out.println("\nnodeType="+v.property("aai-node-type")); + for(String key: v.keys()) { + System.out.println("label="+v.label()+";key= "+key+";value= "+v.value(key)+"/"+v.id()); + } + Iterator edgeItr = v.edges(Direction.BOTH); + while( edgeItr != null && edgeItr.hasNext() ){ + Edge e = edgeItr.next(); + System.out.println("outV="+e.outVertex().property(AAIProperties.NODE_TYPE)+"/"+e.outVertex().id()+";inV= "+e.inVertex().property(AAIProperties.NODE_TYPE)+"/"+e.inVertex().id()); + } + } + assertThat("new route-target vertex found with/or without link", traversal.V() + .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").hasNext(),is(true)); + assertThat("new route-target vertex found", traversal.V() + .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey2").has("route-target-role", "modifyRoleKey2").has("linked", true).hasNext(),is(true)); + assertThat("previous link removed", traversal.V() + .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").has("linked").hasNext(),is(not(true))); + assertThat("previous vertex still exists", traversal.V() + .has(AAIProperties.NODE_TYPE, "route-target").has("global-route-target", "modifyTargetKey").has("route-target-role", "modifyRoleKey").hasNext(),is(true)); g.tx().rollback(); } diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java index 02e9efa1..e901c65f 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/GraphTraversalTest.java @@ -37,7 +37,7 @@ import org.onap.aai.introspection.ModelType; import org.onap.aai.introspection.Version; import org.onap.aai.rest.RestTokens; 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 javax.ws.rs.core.MultivaluedHashMap; @@ -82,12 +82,12 @@ public class GraphTraversalTest extends AAISetup { @Before public void configure() throws Exception { dbEngine = - new TitanDBEngine(queryStyle, + new JanusGraphDBEngine(queryStyle, LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST), false); dbEnginev9 = - new TitanDBEngine(queryStyle, + new JanusGraphDBEngine(queryStyle, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v9), false); } diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/GremlinPipelineTraversalTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/GremlinPipelineTraversalTest.java new file mode 100644 index 00000000..f56d6f62 --- /dev/null +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/GremlinPipelineTraversalTest.java @@ -0,0 +1,447 @@ +/*- + * ============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========================================================= + */ + +/*package org.onap.aai.parsers.query; + +import static org.hamcrest.CoreMatchers.startsWith; +import static org.junit.Assert.assertEquals; + +import java.io.UnsupportedEncodingException; +import java.net.URI; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import org.onap.aai.db.AAIProperties; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.Version; +import org.onap.aai.logging.LogLineBuilder; +import org.onap.aai.serialization.engines.QueryStyle; +import org.onap.aai.serialization.engines.JanusGraphDBEngine; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; + +import com.tinkerpop.gremlin.java.GremlinPipeline; +import com.tinkerpop.pipes.IdentityPipe; + +public class GremlinPipelineTraversalTest { + + private TransactionalGraphEngine dbEngine = + new JanusGraphDBEngine(QueryStyle.GREMLINPIPELINE_TRAVERSAL, + LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v7, new LogLineBuilder("TEST", "TEST")), + false); + + private TransactionalGraphEngine dbEnginev6 = + new JanusGraphDBEngine(QueryStyle.GREMLINPIPELINE_TRAVERSAL, + LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v6, new LogLineBuilder("TEST", "TEST")), + false); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @BeforeClass + public static void configure() { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + } + + @Test + public void parentQuery() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build(); + + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V().has("physical-location-id", "key1").has("aai-node-type", "complex"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal to normal query", + expected.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be complex", + "complex", + query.getResultType()); + assertEquals( + "result type should be empty", + "", + query.getParentResultType()); + assertEquals("dependent",false, query.isDependent()); + + + } + + @Test + public void childQuery() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3").build(); + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("physical-location-id", "key1").has("aai-node-type", "complex") + .in("org.onap.relationships.inventory.BelongsTo") + .has("target-pe", "key2").has("availability-zone-name", "key3"); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("physical-location-id", "key1").has("aai-node-type", "complex"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for complex", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be complex", + "complex", + query.getParentResultType()); + assertEquals( + "result type should be ctag-pool", + "ctag-pool", + query.getResultType()); + assertEquals("dependent",true, query.isDependent()); + + + } + + @Test + public void namingExceptions() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build(); + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2").in("org.onap.relationships.inventory.BelongsTo") + .has("cvlan-tag", 655); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for port group", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be cvlan-tag", + "cvlan-tag", + query.getResultType()); + assertEquals( + "result type should be port-group", + "port-group", + query.getParentResultType()); + assertEquals( + "contaner type should be empty", + "", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + + } + + @Test + public void getAll() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags").build(); + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2").in("org.onap.relationships.inventory.BelongsTo") + .has("aai-node-type", "cvlan-tag"); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for port group", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be port-group", + "port-group", + query.getParentResultType()); + assertEquals( + "result type should be cvlan-tag", + "cvlan-tag", + query.getResultType()); + assertEquals( + "container type should be cvlan-tags", + "cvlan-tags", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + + } + + @Test + public void getItemAffectedByDefaultCloudRegion() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interfaces/l-interface/key3").build(); + QueryParser query = dbEnginev6.getQueryBuilder().createQueryFromURI(uri); + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("cloud-owner", "att-aic").has("aai-node-type", "cloud-region") + .has("cloud-region-id", "AAIAIC25") + .in("org.onap.relationships.inventory.BelongsTo") + .has("tenant-id", "key1") + .in("org.onap.relationships.inventory.BelongsTo") + .has("vserver-id", "key2") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-name", "key3"); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("cloud-owner", "att-aic").has("aai-node-type", "cloud-region") + .has("cloud-region-id", "AAIAIC25") + .in("org.onap.relationships.inventory.BelongsTo") + .has("tenant-id", "key1") + .in("org.onap.relationships.inventory.BelongsTo") + .has("vserver-id", "key2"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for vserver", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be vserver", + "vserver", + query.getParentResultType()); + assertEquals( + "result type should be l-interface", + "l-interface", + query.getResultType()); + assertEquals( + "container type should be empty", + "", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + } + + @Test + public void getViaQueryParam() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/tenants/tenant").build(); + MultivaluedMap map = new MultivaluedHashMap<>(); + + .has("tenant-name", "Tenant1"); + + .has("tenant-name", "Tenant2"); + + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("cloud-owner", "att-aic").has("aai-node-type", "cloud-region") + .has("cloud-region-id", "AAIAIC25"); + + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for cloud-region", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be cloud-region", + "cloud-region", + query.getParentResultType()); + assertEquals( + "result type should be tenant", + "tenant", + query.getResultType()); + assertEquals( + "container type should be empty", + "", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + } + + @Test + public void getPluralViaQueryParam() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("network/vnfcs").build(); + MultivaluedMap map = new MultivaluedHashMap<>(); + map.putSingle("prov-status", "up"); + QueryParser query = dbEnginev6.getQueryBuilder().createQueryFromURI(uri, map); + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("aai-node-type", "vnfc") + .has("prov-status", "up"); + + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("aai-node-type", "vnfc"); + + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "parent result type should be empty", + "", + query.getParentResultType()); + assertEquals( + "result type should be vnfc", + "vnfc", + query.getResultType()); + assertEquals( + "container type should be empty", + "vnfcs", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + } + + @Test + public void getAllQueryParamNamingException() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags").build(); + MultivaluedMap map = new MultivaluedHashMap<>(); + map.putSingle("cvlan-tag", "333"); + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri, map); + + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2").in("org.onap.relationships.inventory.BelongsTo") + .has("aai-node-type", "cvlan-tag") + .has("cvlan-tag", 333); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").has("aai-node-type", "vce") + .in("org.onap.relationships.inventory.BelongsTo") + .has("interface-id", "key2"); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for port group", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be port-group", + "port-group", + query.getParentResultType()); + assertEquals( + "result type should be cvlan-tag", + "cvlan-tag", + query.getResultType()); + assertEquals( + "container type should be cvlan-tags", + "cvlan-tags", + query.getContainerType()); + assertEquals("dependent",true, query.isDependent()); + + + } + + @Test + public void abstractType() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("vnf/key1").build(); + + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").or( + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "vce"), + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "generic-vnf")); + + GremlinPipeline expectedParent = expected; + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for port group", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be empty", + "", + query.getParentResultType()); + assertEquals( + "result type should be vnf", + "vnf", + query.getResultType()); + + assertEquals("dependent",false, query.isDependent()); + + + } + + @Test + public void nonParentAbstractType() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("cloud-infrastructure/pservers/pserver/key2/vnf/key1").build(); + thrown.expect(AAIException.class); + thrown.expectMessage(startsWith("AAI_3001")); + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + + + + } + + @Test + public void parentAbstractTypeWithNesting() throws UnsupportedEncodingException, AAIException { + URI uri = UriBuilder.fromPath("vnf/key1/vf-modules/vf-module/key2").build(); + + QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri); + + GremlinPipeline expected = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").or( + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "vce"), + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "generic-vnf")) + .outE().has("isParent", true).inV().has("vf-module-id", "key2"); + GremlinPipeline expectedParent = new GremlinPipeline(new IdentityPipe()).V() + .has("vnf-id", "key1").or( + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "vce"), + new GremlinPipeline(new IdentityPipe()).has(AAIProperties.NODE_TYPE, "generic-vnf")); + assertEquals( + "gremlin query should be " + expected.toString(), + expected.toString(), + query.getQueryBuilder().getQuery().toString()); + assertEquals( + "parent gremlin query should be equal the query for ", + expectedParent.toString(), + query.getQueryBuilder().getParentQuery().toString()); + assertEquals( + "result type should be vnf", + "vnf", + query.getParentResultType()); + assertEquals( + "result type should be vf-module", + "vf-module", + query.getResultType()); + + assertEquals("dependent",true, query.isDependent()); + + } +} +*/ diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java index 1a4a2fbd..a2bcf6d0 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/LegacyQueryTest.java @@ -29,7 +29,7 @@ import org.onap.aai.introspection.ModelInjestor; 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.TitanDBEngine; +import org.onap.aai.serialization.engines.JanusGraphDBEngine; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import javax.ws.rs.core.UriBuilder; @@ -46,7 +46,7 @@ public class LegacyQueryTest extends AAISetup { private ModelInjestor injestor = ModelInjestor.getInstance(); private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL, + new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java index 9c853e23..19c48801 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipGremlinQueryTest.java @@ -30,7 +30,7 @@ import org.onap.aai.AAISetup; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; 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 javax.xml.bind.JAXBException; @@ -47,7 +47,7 @@ public class RelationshipGremlinQueryTest extends AAISetup { private ModelInjestor injestor = ModelInjestor.getInstance(); private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL, + new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java index 597c6675..c92cab27 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/RelationshipQueryTest.java @@ -28,7 +28,7 @@ import org.onap.aai.AAISetup; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; 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 javax.xml.bind.JAXBException; @@ -45,7 +45,7 @@ public class RelationshipQueryTest extends AAISetup { private ModelInjestor injestor = ModelInjestor.getInstance(); private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_TRAVERSAL, + new JanusGraphDBEngine(QueryStyle.GREMLIN_TRAVERSAL, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java index 8a0c727f..1430b87d 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueRelationshipQueryTest.java @@ -32,7 +32,7 @@ import org.onap.aai.AAISetup; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; 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 javax.xml.bind.JAXBException; @@ -48,7 +48,7 @@ public class UniqueRelationshipQueryTest extends AAISetup { private ModelInjestor injestor = ModelInjestor.getInstance(); private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE, + new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java index 735785b7..edb80bfb 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/query/UniqueURIQueryTest.java @@ -32,7 +32,7 @@ import org.onap.aai.introspection.ModelInjestor; 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.TitanDBEngine; +import org.onap.aai.serialization.engines.JanusGraphDBEngine; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import javax.ws.rs.core.UriBuilder; @@ -46,7 +46,7 @@ public class UniqueURIQueryTest extends AAISetup { private ModelInjestor injestor = ModelInjestor.getInstance(); private TransactionalGraphEngine dbEngine = - new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE, + new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE, LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8), false); private final Version version = Version.v8; diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java index 9cdab403..6d45d947 100644 --- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java +++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java @@ -19,7 +19,7 @@ */ package org.onap.aai.query.builder; -import com.thinkaurelius.titan.core.TitanFactory; +import org.janusgraph.core.JanusGraphFactory; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet; import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; @@ -56,7 +56,7 @@ public abstract class QueryBuilderTestAbstraction extends AAISetup { @BeforeClass public static void setup() throws Exception { loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); - graph = TitanFactory.build().set("storage.backend", "inmemory").open(); + graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); } @Before diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java index 27d14c94..a2bf5876 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbAliasTest.java @@ -19,8 +19,8 @@ */ package org.onap.aai.serialization.db; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; +import org.janusgraph.core.JanusGraphFactory; +import org.janusgraph.core.JanusGraph; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -36,7 +36,7 @@ import org.onap.aai.introspection.*; import org.onap.aai.parsers.query.QueryParser; import org.onap.aai.schema.enums.PropertyMetadata; 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; @@ -56,7 +56,7 @@ import static org.mockito.Mockito.when; @RunWith(value = Parameterized.class) public class DbAliasTest extends AAISetup { - private TitanGraph graph; + private JanusGraph graph; private final Version version = Version.v9; private final ModelType introspectorFactoryType = ModelType.MOXY; @@ -76,9 +76,9 @@ public class DbAliasTest extends AAISetup { @Before public void setup() throws Exception { - graph = TitanFactory.build().set("storage.backend","inmemory").open(); + graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new TitanDBEngine( + dbEngine = new JanusGraphDBEngine( queryStyle, type, loader); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java index 3cf43b4a..77513aa3 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializerTest.java @@ -19,7 +19,7 @@ */ package org.onap.aai.serialization.db; -import com.thinkaurelius.titan.core.TitanFactory; +import org.janusgraph.core.JanusGraphFactory; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.*; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; @@ -34,7 +34,7 @@ import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.*; import org.onap.aai.parsers.query.QueryParser; 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; @@ -80,7 +80,7 @@ public class DbSerializerTest extends AAISetup { @BeforeClass public static void init() throws Exception { - graph = TitanFactory.build().set("storage.backend", "inmemory").open(); + graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); } @@ -88,12 +88,12 @@ public class DbSerializerTest extends AAISetup { public void setup() throws Exception { //createGraph(); loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new TitanDBEngine(queryStyle, type, loader); + dbEngine = new JanusGraphDBEngine(queryStyle, type, loader); spy = spy(dbEngine); adminSpy = spy(dbEngine.asAdmin()); - engine = new TitanDBEngine(queryStyle, type, loader); + engine = new JanusGraphDBEngine(queryStyle, type, loader); dbser = new DBSerializer(version, engine, introspectorFactoryType, "AAI-TEST"); } diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java index 606b6f69..0bdfa150 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/CountQuerySupportTest.java @@ -47,7 +47,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 org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported; import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; @@ -142,7 +142,7 @@ public class CountQuerySupportTest extends AAISetup { if (loader == null) { loader = LoaderFactory.createLoaderForVersion(factoryType, version); - dbEngine = spy(new TitanDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); + dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); serializer = new DBSerializer(version, dbEngine, factoryType, "Junit"); ff = new FormatFactory(loader, serializer); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java index c6aedf9e..27fd78ad 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java @@ -49,7 +49,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 org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported; import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; @@ -155,7 +155,7 @@ public class MultiFormatTest extends AAISetup { if (loader == null) { loader = LoaderFactory.createLoaderForVersion(factoryType, version); - dbEngine = spy(new TitanDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); + dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin()); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java index 5633e4cb..8f4fd359 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/RawFormatTest.java @@ -43,7 +43,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 org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported; import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; @@ -112,7 +112,7 @@ public class RawFormatTest extends AAISetup { if (loader == null) { loader = LoaderFactory.createLoaderForVersion(factoryType, version); - dbEngine = spy(new TitanDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); + dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); serializer = new DBSerializer(version, dbEngine, factoryType, "Junit"); rawFormat = new RawFormat.Builder(loader, serializer, urlBuilder).build(); diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java index 23c8abf2..7636b8d7 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java @@ -41,7 +41,7 @@ import org.onap.aai.introspection.Version; import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; import org.onap.aai.serialization.db.DBSerializer; 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.serialization.queryformats.exceptions.AAIFormatVertexException; import org.onap.aai.serialization.queryformats.utils.UrlBuilder; @@ -149,7 +149,7 @@ public class SimpleFormatTest extends AAISetup { if(loader == null){ loader = LoaderFactory.createLoaderForVersion(factoryType, Version.v10); - dbEngine = spy(new TitanDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); + dbEngine = spy(new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.CACHED, loader)); TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin()); diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties index da9f5e5b..3a5671c2 100644 --- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties +++ b/aai-core/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-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties new file mode 100644 index 00000000..9306199d --- /dev/null +++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties @@ -0,0 +1,39 @@ +# +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# Copyright © 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========================================================= +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# + +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=localhost + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +#caching on +cache.db-cache = true +cache.db-cache-clean-wait = 20 +cache.db-cache-time = 180000 +cache.db-cache-size = 0.3 + +#load graphson file on startup +load.snapshot.file=false diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties new file mode 100644 index 00000000..6e1863b7 --- /dev/null +++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties @@ -0,0 +1,36 @@ +# +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# Copyright © 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========================================================= +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# + +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=localhost + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +# Setting db-cache to false ensure the fastest propagation of changes across servers +cache.db-cache = false + +#load graphson file on startup +load.snapshot.file=false diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties deleted file mode 100644 index 9306199d..00000000 --- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-cached.properties +++ /dev/null @@ -1,39 +0,0 @@ -# -# ============LICENSE_START======================================================= -# org.onap.aai -# ================================================================================ -# Copyright © 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========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -# - -query.fast-property=true -# the following parameters are not reloaded automatically and require a manual bounce -storage.backend=inmemory -storage.hostname=localhost - -#schema.default=none -storage.lock.wait-time=300 -storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure -#caching on -cache.db-cache = true -cache.db-cache-clean-wait = 20 -cache.db-cache-time = 180000 -cache.db-cache-size = 0.3 - -#load graphson file on startup -load.snapshot.file=false diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties deleted file mode 100644 index 6e1863b7..00000000 --- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/titan-realtime.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -# ============LICENSE_START======================================================= -# org.onap.aai -# ================================================================================ -# Copyright © 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========================================================= -# -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -# - -query.fast-property=true -# the following parameters are not reloaded automatically and require a manual bounce -storage.backend=inmemory -storage.hostname=localhost - -#schema.default=none -storage.lock.wait-time=300 -storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure -# Setting db-cache to false ensure the fastest propagation of changes across servers -cache.db-cache = false - -#load graphson file on startup -load.snapshot.file=false diff --git a/aai-core/src/test/resources/logback.xml b/aai-core/src/test/resources/logback.xml index 37425b97..0258f1de 100644 --- a/aai-core/src/test/resources/logback.xml +++ b/aai-core/src/test/resources/logback.xml @@ -22,24 +22,50 @@ --> - ${module.ajsc.namespace.name} + + + + + + + - - + + + + + + + + + + - - - ERROR - ACCEPT - DENY - + + + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx} + + + + + + ${logDirectory}/rest/sane.log + + ${logDirectory}/rest/sane.log.%d{yyyy-MM-dd} + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + 1000 + true + + + @@ -47,124 +73,180 @@ ACCEPT DENY - ${logDirectory}/rest/metric.log + ${logDirectory}/rest/metrics.log - ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + ${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd} + - - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + ${eelfMetricLogPattern} + + 1000 + true + + - + DEBUG ACCEPT DENY ${logDirectory}/rest/debug.log - ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + - - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + ${eelfLogPattern} + + 1000 + true + + + WARN - ACCEPT - DENY ${logDirectory}/rest/error.log - ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + - - - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + ${eelfErrorLogPattern} - - + 1000 + true + + + + - - - - audit - - co\=aairest - - level == INFO && audit.matches(formattedMessage) - - ACCEPT - DENY - ${logDirectory}/rest/audit.log - ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + ${logDirectory}/rest/audit.log.%d{yyyy-MM-dd} + - - %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + ${eelfAuditLogPattern} + + + + + 1000 + true + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/translog.log + + ${logDirectory}/rest/translog.log.%d{yyyy-MM-dd} + + + + ${eelfTransLogPattern} - + 1000 + true + + + + + WARN - ${logDirectory}/rest/audit.log + ${logDirectory}/dmaapAAIEventConsumer/error.log - ${logDirectory}/rest/audit-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip + ${logDirectory}/dmaapAAIEventConsumer/error.log.%d{yyyy-MM-dd} - - 5MB - - - "%d [%thread] %-5level %logger{1024} - %msg%n" + + ${eelfLogPattern} - - + + DEBUG + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/debug.log + + ${logDirectory}/dmaapAAIEventConsumer/debug.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log.%d{yyyy-MM-dd} + + + + ${eelfMetricLogPattern} + + + + WARN - ${logDirectory}/rest/perform.log + ${logDirectory}/external/external.log - ${logDirectory}/rest/perform-${lrmRVer}-${lrmRO}-${Pid}.%d{yyyy-MM-dd}.log.zip + ${logDirectory}/external/external.log.%d{yyyy-MM-dd} - - - "%d [%thread] %-5level %logger{1024} - %msg%n" + + ${eelfLogPattern} + + + + + + + @@ -175,9 +257,11 @@ - + + + @@ -187,6 +271,9 @@ + + + @@ -205,93 +292,101 @@ + + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - ${JMS_LOGGER_AUDIT_QUEUE_BINDING} - - - - - - - - ${JMS_LOGGER_PERF_QUEUE_BINDING} - - - - - - - 1000 - 0 - + + + + ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.log + + + ${logDirectory}/perf-audit/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + - - - 1000 - 0 - + + + ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.log + + + ${logDirectory}/perf-audit/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + + - - - - - - + + + + + + + + + + + + -- cgit 1.2.3-korg