From 8d66894a3721b0e826573c87d40bc001cb242cd9 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Sat, 21 Sep 2024 19:21:35 +0200 Subject: Update Janusgraph to 1.0.0 - update Janusgraph (0.6.4 -> 1.0.0) - update Tinkerpop (3.5.8 -> 3.7.1) Issue-ID: AAI-3743 Change-Id: I5f2f929645b8f327bc90eabab6c06a6b80bdbc3e Signed-off-by: Fiete Ostkamp --- aai-core/pom.xml | 5 +++++ .../java/org/onap/aai/concurrent/AaiCallable.java | 1 - .../java/org/onap/aai/dbgen/SchemaGenerator.java | 14 ++++++-------- .../aai/query/builder/GraphTraversalBuilder.java | 7 ++++--- .../aai/serialization/queryformats/GraphSON.java | 2 +- .../onap/aai/util/StoreNotificationEventTest.java | 20 +++++++++----------- aai-parent/pom.xml | 4 ++-- .../onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java | 2 +- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/aai-core/pom.xml b/aai-core/pom.xml index a7225531..83cca34f 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -171,6 +171,11 @@ limitations under the License. com.google.guava guava + + org.glassfish + javax.json + 1.1.4 + org.janusgraph janusgraph-core diff --git a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java index 2703bdc4..9451e32e 100644 --- a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java +++ b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java @@ -35,7 +35,6 @@ public abstract class AaiCallable implements Callable { /** * The constructor. */ - @SuppressWarnings("unchecked") public AaiCallable() { mdcCopy = MDC.getCopyOfContextMap(); } 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 6430df50..055a70e3 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 @@ -26,12 +26,10 @@ import com.google.common.collect.Multimap; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -49,10 +47,10 @@ import org.janusgraph.core.PropertyKey; import org.janusgraph.core.schema.ConsistencyModifier; import org.janusgraph.core.schema.JanusGraphIndex; import org.janusgraph.core.schema.JanusGraphManagement; -import org.janusgraph.core.schema.JanusGraphManagement.IndexJobFuture; import org.janusgraph.core.schema.RelationTypeIndex; import org.janusgraph.core.schema.SchemaAction; import org.janusgraph.core.schema.SchemaStatus; +import org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJobFuture; import org.janusgraph.graphdb.database.StandardJanusGraph; import org.janusgraph.graphdb.database.management.ManagementSystem; import org.janusgraph.graphdb.database.management.RelationIndexStatusReport; @@ -109,7 +107,7 @@ public class SchemaGenerator { final Map objs = LoaderUtil.getLatestVersion().getAllObjects(); final Map seenProps = new HashMap<>(); - + for (Introspector obj : objs.values()) { createSchemaForObject(graphMgmt, seenProps, obj); } @@ -340,7 +338,7 @@ public class SchemaGenerator { private static void awaitRelationIndexStatus(JanusGraph graph, Collection labels, SchemaStatus newStatus) { LOGGER.info("Awaiting index status [{}]", newStatus);; CompletableFuture[] awaits = labels.stream() - .map(label -> + .map(label -> CompletableFuture.supplyAsync(() -> { try { return ManagementSystem @@ -365,8 +363,8 @@ public class SchemaGenerator { private static void updateRelationIndexes(JanusGraph graph, Collection labels, SchemaAction updateAction) { JanusGraphManagement graphMgmt = graph.openManagement(); - CompletableFuture[] awaits = labels.stream() - .map(label -> + CompletableFuture[] awaits = labels.stream() + .map(label -> CompletableFuture.supplyAsync(() -> { EdgeLabel relation = graphMgmt.getEdgeLabel(label); RelationTypeIndex index = graphMgmt.getRelationIndex(relation, label); @@ -398,7 +396,7 @@ public class SchemaGenerator { LOGGER.debug("Closing open transaction [{}] before schema generation", transaction.toString()); transaction.rollback(); }); - + final JanusGraphManagement graphMgtForClosing = graph.openManagement(); Set instances = graphMgtForClosing.getOpenInstances(); diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java index 10f5cbaf..4ea0c074 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java @@ -30,10 +30,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator; +import org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator; import org.apache.tinkerpop.gremlin.process.traversal.Order; import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.Path; @@ -519,7 +520,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder { @Override public QueryBuilder store(String name) { - this.traversal.store(name); + this.traversal.aggregate(Scope.local , name); stepIndex++; return this; @@ -1028,7 +1029,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder { try { return mapPaginationResult((Map) completeTraversal.next()); // .next() will throw an IllegalArguementException if there are no vertices of the given type - } catch (IllegalArgumentException e) { + } catch (NoSuchElementException | IllegalArgumentException e) { return new PaginationResult<>(Collections.emptyList(), 0L); } } 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 89970e24..9c7c4a44 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 @@ -54,7 +54,7 @@ public class GraphSON implements FormatMapper { private static final GraphSONVersion version = GraphSONVersion.V1_0; private final GraphSONMapper mapper = - GraphSONMapper.build().version(version).addRegistry(JanusGraphIoRegistry.getInstance()).create(); + GraphSONMapper.build().version(version).addRegistry(JanusGraphIoRegistry.instance()).create(); private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create(); @Override diff --git a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java index a0c3f639..7d3a19d4 100644 --- a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java @@ -25,12 +25,11 @@ import static org.junit.Assert.assertTrue; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.io.IOException; -import javax.json.Json; -import javax.json.JsonObject; - import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.junit.Before; @@ -51,6 +50,8 @@ public class StoreNotificationEventTest extends AAISetup { private static AAIKafkaEventJMSProducer producer; private static StoreNotificationEvent sne; + private final ObjectMapper mapper = new ObjectMapper(); + @BeforeClass public static void setUp() { producer = Mockito.mock(AAIKafkaEventJMSProducer.class); @@ -77,7 +78,8 @@ public class StoreNotificationEventTest extends AAISetup { @Test public void testStoreEventEmptyEventHeader() throws AAIException, JsonGenerationException, JsonMappingException, IOException { - JsonObject object = Json.createObjectBuilder().add("hello", "world").build(); + + ObjectNode object = mapper.createObjectNode().put("hello", "world"); String res = sne.storeEventAndSendToJms(new EventHeader(), object); assertNotNull(res); @@ -98,14 +100,12 @@ public class StoreNotificationEventTest extends AAISetup { assertTrue(res.contains("\"entity-link\" : \"UNK\"")); assertTrue(res.contains("\"entity\"")); assertTrue(res.contains("\"hello\"")); - assertTrue(res.contains("\"chars\" : \"world\"")); - assertTrue(res.contains("\"string\" : \"world\"")); - assertTrue(res.contains("\"valueType\" : \"STRING\"")); + assertTrue(res.contains("\"world\"")); } @Test public void testStoreEvent() throws AAIException, JsonGenerationException, JsonMappingException, IOException { - JsonObject object = Json.createObjectBuilder().add("hello", "world").build(); + ObjectNode object = mapper.createObjectNode().put("hello", "world"); EventHeader eh = new EventHeader(); eh.setId("123"); eh.setTimestamp("current-time"); @@ -135,9 +135,7 @@ public class StoreNotificationEventTest extends AAISetup { assertTrue(res.contains("\"entity-link\" : \"entity-link\"")); assertTrue(res.contains("\"entity\"")); assertTrue(res.contains("\"hello\"")); - assertTrue(res.contains("\"chars\" : \"world\"")); - assertTrue(res.contains("\"string\" : \"world\"")); - assertTrue(res.contains("\"valueType\" : \"STRING\"")); + assertTrue(res.contains("\"world\"")); } @Test(expected = AAIException.class) diff --git a/aai-parent/pom.xml b/aai-parent/pom.xml index c4b96c2d..99fe0aaf 100644 --- a/aai-parent/pom.xml +++ b/aai-parent/pom.xml @@ -61,8 +61,8 @@ limitations under the License. 2.0.0-oss 2.3.31 31.1-jre - 3.5.8 - 0.6.4 + 3.7.1 + 1.0.0 2.5.15 2.9.1 2.0.0.0 diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java index e7055a3f..08cf880e 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java @@ -31,7 +31,7 @@ import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.setup.AAIConfigTranslator; -- cgit 1.2.3-korg