diff options
author | 2017-08-11 15:13:28 -0400 | |
---|---|---|
committer | 2017-08-11 20:09:31 +0000 | |
commit | fd16c2550e347e5f8d7be11c12dae479e7947ed8 (patch) | |
tree | 9d18ce007cb65c714290c628da18e0999b7fdfea /aai-resources/src/main/java/org/openecomp | |
parent | b840faea026675dd1aa065d2cb8e025dce8d9068 (diff) |
[AAI-154 Amsterdam] Check in titan refactor
Change-Id: I955ac630071680e690c523e005d289d8fc40ba6c
Signed-off-by: Muller, Andrew (am8383) <am8383@us.att.com>
Diffstat (limited to 'aai-resources/src/main/java/org/openecomp')
7 files changed, 32 insertions, 59 deletions
diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/DataSnapshot.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/DataSnapshot.java index 2f1ef33..faf56f3 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/DataSnapshot.java +++ b/aai-resources/src/main/java/org/openecomp/aai/dbgen/DataSnapshot.java @@ -25,7 +25,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Iterator; import java.util.Properties; import org.apache.tinkerpop.gremlin.structure.io.IoCore; @@ -41,7 +40,6 @@ 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.TitanVertex; import com.thinkaurelius.titan.core.util.TitanCleanup; public class DataSnapshot { @@ -199,12 +197,7 @@ public class DataSnapshot { graph.tx().commit(); System.out.println("Completed reloading Titan 0.5 data."); - int vCount = 0; - Iterator<TitanVertex> vIt = graph.query().vertices().iterator(); - while (vIt.hasNext()) { - vCount++; - vIt.next(); - } + long vCount = graph.traversal().V().count().next(); System.out.println("A little after repopulating from an old snapshot, we see: " + vCount + " vertices in the db."); } else if (command.equals("RELOAD_DATA")) { // ------------------------------------------------------------------- @@ -238,12 +231,8 @@ public class DataSnapshot { graph.tx().commit(); System.out.println("Completed reloading data."); - int vCount = 0; - Iterator<TitanVertex> vIt = graph.query().vertices().iterator(); - while (vIt.hasNext()) { - vCount++; - vIt.next(); - } + long vCount = graph.traversal().V().count().next(); + System.out.println("A little after repopulating from an old snapshot, we see: " + vCount + " vertices in the db."); } else { String emsg = "Bad command passed to DataSnapshot: [" + command + "]"; diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/ForceDeleteTool.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/ForceDeleteTool.java index bced2bc..1cab272 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/ForceDeleteTool.java +++ b/aai-resources/src/main/java/org/openecomp/aai/dbgen/ForceDeleteTool.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.Properties; import java.util.Scanner; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -39,10 +40,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.TitanEdge; import com.thinkaurelius.titan.core.TitanFactory; import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanGraphQuery; @@ -220,8 +219,8 @@ public class ForceDeleteTool { logger.error(msg); System.exit(0); } - TitanGraphQuery tgQ = graph.query(); - String qStringForMsg = " graph.query()"; + GraphTraversal<Vertex, Vertex> g = graph.traversal().V(); + String qStringForMsg = " graph.traversal().V()"; // Note - if they're only passing on parameter, there won't be any commas String [] paramArr = dataString.split(","); for( int i = 0; i < paramArr.length; i++ ){ @@ -235,13 +234,12 @@ public class ForceDeleteTool { else { String propName = paramArr[i].substring(0,pipeLoc); String propVal = paramArr[i].substring(pipeLoc + 1); - tgQ = tgQ.has(propName,propVal); + g = g.has(propName,propVal); qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")"; } } - if( (tgQ != null) && (tgQ instanceof TitanGraphQuery) ){ - Iterable <Vertex> verts = (Iterable<Vertex>) tgQ.vertices(); - Iterator <Vertex> vertItor = verts.iterator(); + if( (g != null)){ + Iterator<Vertex> vertItor = g; while( vertItor.hasNext() ){ resCount++; Vertex v = vertItor.next(); @@ -300,10 +298,10 @@ public class ForceDeleteTool { } } else if( actionVal.equals("DELETE_EDGE") ){ - TitanEdge thisEdge = null; + Edge thisEdge = null; Iterator <Edge> edItr = graph.edges( edgeIdStr ); if( edItr != null && edItr.hasNext() ) { - thisEdge = (TitanEdge)edItr.next(); + thisEdge = edItr.next(); } if( thisEdge == null ){ @@ -374,7 +372,7 @@ public class ForceDeleteTool { }// End of showNodeInfo() - public void showPropertiesForEdge( EELFLogger logger, TitanEdge tEd ){ + public void showPropertiesForEdge( EELFLogger logger, Edge tEd ){ String infMsg = ""; if( tEd == null ){ infMsg = "null Edge object passed to showPropertiesForEdge()"; @@ -556,7 +554,7 @@ public class ForceDeleteTool { }// end of countDescendants() - public boolean getEdgeDelConfirmation( EELFLogger logger, String uid, TitanEdge ed, + public boolean getEdgeDelConfirmation( EELFLogger logger, String uid, Edge ed, Boolean overRideProtection ) { showPropertiesForEdge( logger, ed ); diff --git a/aai-resources/src/main/java/org/openecomp/aai/dbgen/UpdateEdgeTags.java b/aai-resources/src/main/java/org/openecomp/aai/dbgen/UpdateEdgeTags.java index c2ebf6f..abe2a10 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/dbgen/UpdateEdgeTags.java +++ b/aai-resources/src/main/java/org/openecomp/aai/dbgen/UpdateEdgeTags.java @@ -27,9 +27,9 @@ import java.util.Iterator; import java.util.Map; import java.util.UUID; -import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.dbmap.AAIGraph; import org.openecomp.aai.dbmodel.DbEdgeRules; import org.openecomp.aai.exceptions.AAIException; @@ -37,10 +37,8 @@ import org.openecomp.aai.logging.ErrorLogHelper; import org.openecomp.aai.serialization.db.EdgeRule; import org.openecomp.aai.serialization.db.EdgeRules; import org.openecomp.aai.util.AAIConfig; -import com.thinkaurelius.titan.core.TitanEdge; + import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanTransaction; -import com.thinkaurelius.titan.core.TitanVertex; @@ -152,17 +150,15 @@ public class UpdateEdgeTags { System.exit(0); } - TitanTransaction g = graph.newTransaction(); try { - Iterable <?> edges = graph.query().edges(); - Iterator <?> edgeItr = edges.iterator(); + Iterator<Edge> edgeItr = graph.traversal().E(); // Loop through all edges and update their tags if they are a type we are interested in. // Sorry about looping over everything, but for now, I can't find a way to just select one type of edge at a time...!? StringBuffer sb; boolean missingEdge = false; while( edgeItr != null && edgeItr.hasNext() ){ - TitanEdge tmpEd = (TitanEdge) edgeItr.next(); + Edge tmpEd = edgeItr.next(); String edLab = tmpEd.label().toString(); // Since we have edgeLabels that can be used for different pairs of node-types, we have to @@ -170,7 +166,7 @@ public class UpdateEdgeTags { String derivedEdgeKey = ""; if( labelMapsToMultipleKeys.contains(edLab) ){ // need to figure out which key is right for this edge - derivedEdgeKey = deriveEdgeRuleKeyForThisEdge( TRANSID, FROMAPPID, g, tmpEd ); + derivedEdgeKey = deriveEdgeRuleKeyForThisEdge( TRANSID, FROMAPPID, graph, tmpEd ); } else { // This kind of label only maps to one key -- so we can just look it up. @@ -183,7 +179,7 @@ public class UpdateEdgeTags { Vertex vIn = null; Vertex vOut = null; Object obj = null; - vIn = tmpEd.vertex(Direction.IN); + vIn = tmpEd.inVertex(); if ( vIn != null ){ obj = vIn.<String>property("aai-node-type").orElse(null); if ( obj != null ) { @@ -197,7 +193,7 @@ public class UpdateEdgeTags { } else { sb.append(" missing inbound vertex "); } - vOut = tmpEd.vertex(Direction.OUT); + vOut = tmpEd.outVertex(); if ( vOut != null ) { obj = vOut.<String>property("aai-node-type").orElse(null); if ( obj != null ) { @@ -257,11 +253,11 @@ public class UpdateEdgeTags { * @return String - key to look up edgeRule (fromNodeType|toNodeType) * @throws AAIException the AAI exception */ - public static String deriveEdgeRuleKeyForThisEdge( String transId, String fromAppId, TitanTransaction graph, - TitanEdge tEdge ) throws AAIException{ + public static String deriveEdgeRuleKeyForThisEdge( String transId, String fromAppId, Graph graph, + Edge tEdge ) throws AAIException{ - TitanVertex fromVtx = tEdge.outVertex(); - TitanVertex toVtx = tEdge.inVertex(); + Vertex fromVtx = tEdge.outVertex(); + Vertex toVtx = tEdge.inVertex(); String startNodeType = fromVtx.<String>property("aai-node-type").orElse(null); String targetNodeType = toVtx.<String>property("aai-node-type").orElse(null); String key = startNodeType + "|" + targetNodeType; diff --git a/aai-resources/src/main/java/org/openecomp/aai/migration/MigrationControllerInternal.java b/aai-resources/src/main/java/org/openecomp/aai/migration/MigrationControllerInternal.java index a296c76..875d7cb 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/migration/MigrationControllerInternal.java +++ b/aai-resources/src/main/java/org/openecomp/aai/migration/MigrationControllerInternal.java @@ -37,6 +37,7 @@ import org.apache.activemq.broker.BrokerService; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.io.IoCore; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.dbmap.AAIGraph; @@ -59,7 +60,6 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; -import com.thinkaurelius.titan.core.TitanTransaction; /** * Runs a series of migrations from a defined directory based on the presence of @@ -301,7 +301,7 @@ public class MigrationControllerInternal { String dateStr= fd.getDateTime(); String fileName = snapshotLocation + File.separator + phase + "Migration." + dateStr + ".graphson"; logAndPrint("Saving snapshot of inmemory graph " + phase + " migration to " + fileName); - TitanTransaction transaction = null; + Graph transaction = null; try { Path pathToFile = Paths.get(fileName); diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java index 70b8c92..10a3b45 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java @@ -68,7 +68,6 @@ import org.openecomp.aai.workarounds.RemoveDME2QueryParams; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.base.Joiner; -import com.thinkaurelius.titan.core.TitanTransaction; /** @@ -128,7 +127,6 @@ public class LegacyMoxyConsumer extends RESTAPI { Response response = null; Loader loader = null; TransactionalGraphEngine dbEngine = null; - TitanTransaction g = null; boolean success = true; try { @@ -242,7 +240,6 @@ public class LegacyMoxyConsumer extends RESTAPI { String realTime = headers.getRequestHeaders().getFirst("Real-Time"); Response response = null; TransactionalGraphEngine dbEngine = null; - TitanTransaction g = null; Loader loader = null; try { @@ -331,7 +328,6 @@ public class LegacyMoxyConsumer extends RESTAPI { Response response = Response.status(404) .type(outputMediaType).build(); - TitanTransaction g = null; boolean success = true; try { @@ -408,7 +404,6 @@ public class LegacyMoxyConsumer extends RESTAPI { Response response = Response.status(404) .type(outputMediaType).build(); - TitanTransaction g = null; boolean success = true; try { @@ -523,7 +518,6 @@ public class LegacyMoxyConsumer extends RESTAPI { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - TitanTransaction g = null; Boolean success = true; try { diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java b/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java index 945a6f3..08cc813 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java @@ -39,9 +39,9 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang.StringUtils; +import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.javatuples.Pair; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.dbmap.DBConnectionType; import org.openecomp.aai.domain.responseMessage.AAIResponseMessage; @@ -66,6 +66,7 @@ import org.openecomp.aai.serialization.engines.QueryStyle; import org.openecomp.aai.serialization.engines.TitanDBEngine; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; import org.openecomp.aai.serialization.engines.query.QueryEngine; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; @@ -73,7 +74,6 @@ 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 com.thinkaurelius.titan.core.TitanTransaction; /** * The Class HttpEntry. @@ -268,7 +268,7 @@ public class HttpEntry { } break; - case PUT: + case PUT: if (isNewVertex) { v = serializer.createNewVertex(obj); } @@ -282,7 +282,7 @@ public class HttpEntry { relatedObjects = this.getRelatedObjects(serializer, queryEngine, v); } notification.createNotificationEvent(transactionId, sourceOfTruth, status, uri, obj, relatedObjects); - + break; case PUT_EDGE: serializer.touchStandardVertexProperties(v, false); @@ -313,7 +313,6 @@ public class HttpEntry { //if the caller didn't touch the relationship-list, we shouldn't either patchedObj.setValue("relationship-list", null); } - serializer.touchStandardVertexProperties(v, false); serializer.serializeToDb(patchedObj, v, query, uri.getRawPath(), requestContext); status = Status.OK; patchedObj = serializer.getLatestVersionView(v); @@ -471,7 +470,7 @@ public class HttpEntry { return obj; } - + /** * Creates the not found message. diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/tools/ModelVersionTransformer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/tools/ModelVersionTransformer.java index 956fb41..141d71a 100644 --- a/aai-resources/src/main/java/org/openecomp/aai/rest/tools/ModelVersionTransformer.java +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/tools/ModelVersionTransformer.java @@ -62,12 +62,10 @@ import org.openecomp.aai.serialization.db.EdgeType; import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; import org.openecomp.aai.serialization.engines.QueryStyle; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import org.radeox.util.logging.Logger; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.base.Joiner; -import com.thinkaurelius.titan.core.TitanTransaction; /** @@ -106,7 +104,6 @@ public class ModelVersionTransformer extends RESTAPI { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - TitanTransaction g = null; Boolean success = true; AAIException ex; |