X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fdbgen%2Fschemamod%2FSchemaModInternalBatch.java;h=e88c26196803f410ae3883817f454c0aa192c533;hb=refs%2Fchanges%2F72%2F119872%2F4;hp=e88e2bfb3f73597bae9b3cdd1c88945f1218f365;hpb=eab4c7ce3ebe4d202f94b22836c9e1b9af023d84;p=aai%2Fgraphadmin.git diff --git a/src/main/java/org/onap/aai/dbgen/schemamod/SchemaModInternalBatch.java b/src/main/java/org/onap/aai/dbgen/schemamod/SchemaModInternalBatch.java index e88e2bf..e88c261 100644 --- a/src/main/java/org/onap/aai/dbgen/schemamod/SchemaModInternalBatch.java +++ b/src/main/java/org/onap/aai/dbgen/schemamod/SchemaModInternalBatch.java @@ -32,6 +32,8 @@ 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.VertexProperty; +import org.janusgraph.core.schema.ConsistencyModifier; +import org.janusgraph.core.schema.JanusGraphIndex; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import org.onap.aai.util.FormatDate; @@ -48,17 +50,19 @@ public class SchemaModInternalBatch { private final Class type; private final String indexType; private final boolean preserveData; + private final boolean consistencyLock; private final Cardinality cardinality; private final long commitBlockSize; private final Logger logger; public SchemaModInternalBatch(TransactionalGraphEngine engine, Logger logger, String propName, - String type, String indexType, boolean preserveData, long commitBlockSize) { + String type, String indexType, boolean preserveData, boolean consistencyLock, long commitBlockSize) { this.engine = engine; this.propName = propName; this.type = determineClass(type); this.indexType = indexType; this.preserveData = preserveData; + this.consistencyLock = consistencyLock; this.cardinality = determineCardinality(type); this.commitBlockSize = commitBlockSize; this.logger = logger; @@ -226,14 +230,23 @@ public class SchemaModInternalBatch { // targetDataType PropertyKey freshPropKey = graphMgt.makePropertyKey(propName).dataType(type) .cardinality(cardinality).make(); - + if (consistencyLock) { + logAndPrint(logger, " -- Consistency Lock is being set on the property "); + graphMgt.setConsistency(freshPropKey, ConsistencyModifier.LOCK); + } // Create the appropriate index (if any) + JanusGraphIndex indexG = null; if (indexType.equals("uniqueIndex")) { String freshIndexName = propName + dteStr; - graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).unique().buildCompositeIndex(); + indexG = graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).unique().buildCompositeIndex(); } else if (indexType.equals("index")) { String freshIndexName = propName + dteStr; - graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).buildCompositeIndex(); + indexG = graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).buildCompositeIndex(); + } + + if(indexG != null && consistencyLock) { + logAndPrint(logger, " -- Consistency Lock is being set on the index "); + graphMgt.setConsistency(indexG, ConsistencyModifier.LOCK); } logAndPrint(logger, "Committing schema changes with graphMgt.commit()");