aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-12-06 15:20:04 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-12-06 15:20:04 +0100
commit8d9d314a22895014dc3ac8c0b43f9db9159a6ac2 (patch)
tree6597777ace145507eca28bb9be64da0af0295130
parentce5268daeb97731a7723ce6019e7c6fb7b34b5c9 (diff)
Remove reindexing logic from graphadmin schema-creation script1.15.3
- reindexing is not performantly working Issue-ID: AAI-4082 Change-Id: I8066857577cda7ed884506fb5012e3d0a77402bc Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
-rw-r--r--src/main/java/org/onap/aai/schema/GenTester.java61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/main/java/org/onap/aai/schema/GenTester.java b/src/main/java/org/onap/aai/schema/GenTester.java
index ea18288..69e55a1 100644
--- a/src/main/java/org/onap/aai/schema/GenTester.java
+++ b/src/main/java/org/onap/aai/schema/GenTester.java
@@ -46,7 +46,7 @@ public class GenTester {
private static Logger LOGGER;
private static boolean historyEnabled;
private static boolean isSchemaInitialized;
- private static final String SCHEMA_INITIALIZED = "schema-initialized";
+ private static final String SCHEMA_INITIALIZED = "schema-initialized";
private static final String bySchemaInitialized = "bySchemaInitialized";
/**
@@ -143,42 +143,19 @@ public class GenTester {
// Setting property schema-initialized to false as vertex is already there
LOGGER.debug("-- Vertex with property 'schema-initialized' present in db. Updating it to false");
graph.traversal().V().has(SCHEMA_INITIALIZED).property(SCHEMA_INITIALIZED, false).next();
-
- // Reindexing the existing index
- LOGGER.debug("-- Reindexing existing schema-initialized index");
+ } else {
+ LOGGER.debug("-- Adding a new vertex with property schema-initialized as false");
JanusGraphManagement mgmt = graph.openManagement();
- try {
- if (mgmt.getGraphIndex(bySchemaInitialized) != null) {
- LOGGER.info("Reindexing 'bySchemaInitialized' to include existing vertices.");
- mgmt.updateIndex(mgmt.getGraphIndex(bySchemaInitialized), SchemaAction.REINDEX).get();
+ try {
+ createSchemaInitializedIndex(graph, mgmt);
+ } catch (Exception e) {
+ mgmt.rollback();
+ LOGGER.error("Problems creating an index for schema-initialized vertex " + e.getMessage());
+ throw e;
}
- mgmt.commit();
- } catch (Exception e) {
- mgmt.rollback();
- LOGGER.error("Error during reindexing: " + e.getMessage());
- throw e;
- }
- } else {
- LOGGER.debug("-- Adding a new vertex with property schema-initialized as false");
- JanusGraphManagement mgmt = graph.openManagement();
- try{
- //creating a composite index
- PropertyKey schemaInitialized = mgmt.makePropertyKey(SCHEMA_INITIALIZED).dataType(Boolean.class).make();
- mgmt.buildIndex(bySchemaInitialized, Vertex.class)
- .addKey(schemaInitialized)
- .buildCompositeIndex();
- mgmt.commit();
-
- //Wait for the index to become available
- ManagementSystem.awaitGraphIndexStatus(graph, bySchemaInitialized).call();
- }catch(Exception e) {
- mgmt.rollback();
- LOGGER.error("Problems creating an index for schema-initialized vertex " + e.getMessage());
- throw e;
+ // Adding a new vertex
+ graph.addVertex(SCHEMA_INITIALIZED, false);
}
- //Adding a new vertex
- graph.addVertex(SCHEMA_INITIALIZED, false);
- }
GraphAdminDBUtils.logConfigs(graph.configuration());
@@ -206,7 +183,7 @@ public class GenTester {
graph.traversal().V().has(SCHEMA_INITIALIZED).property(SCHEMA_INITIALIZED, true).next();
LOGGER.debug("-- committing transaction ");
graph.tx().commit();
-
+
graph.close();
LOGGER.info("Closed the graph");
@@ -219,6 +196,18 @@ public class GenTester {
System.exit(0);
}
+ private static void createSchemaInitializedIndex(JanusGraph graph, JanusGraphManagement mgmt) throws InterruptedException {
+ // creating a composite index
+ PropertyKey schemaInitialized = mgmt.makePropertyKey(SCHEMA_INITIALIZED).dataType(Boolean.class).make();
+ mgmt.buildIndex(bySchemaInitialized, Vertex.class)
+ .addKey(schemaInitialized)
+ .buildCompositeIndex();
+ mgmt.commit();
+
+ // Wait for the index to become available
+ ManagementSystem.awaitGraphIndexStatus(graph, bySchemaInitialized).call();
+ }
+
/**
* Radical approach to avoiding index update failures.
* Indexes can get stuck in INSTALLED state, when there are stale transactions
@@ -244,7 +233,7 @@ public class GenTester {
LOGGER.info("Currently open instances: [{}]", instances);
instances.stream()
.filter(instance -> !instance.contains("graphadmin")) // Potentially comment this out, should there be
- // issues with the schema creation job
+ // issues with the schema creation job
.filter(instance -> !instance.contains("(current)"))
.forEach(instance -> {
LOGGER.debug("Closing open JanusGraph instance [{}] before reindexing procedure", instance);