From d9fd57707f476f6caedcd01c3ff372b216daac00 Mon Sep 17 00:00:00 2001 From: sjudeng Date: Mon, 6 Feb 2017 22:48:59 -0600 Subject: [PATCH] Cleanup after tinkerpop-upgrade merge. Code style fixes, add missing headers and replace legacy names. Signed-off-by: sjudeng --- .../BerkeleyGraphComputerProvider.java | 3 ++- .../thrift/ThriftGraphComputerProvider.java | 4 +++- .../java/org/janusgraph/core/JanusGraph.java | 6 ++++-- .../attribute/SerializableSerializer.java | 18 ++++++++++++++++++ .../graphdb/olap/computer/FulgoraMemory.java | 6 ++---- .../olap/computer/VertexMemoryHandler.java | 4 ++-- .../JanusGraphBlueprintsTransaction.java | 4 ++-- .../io/graphson/JanusGraphSONModule.java | 4 ++-- .../JanusGraphLocalQueryOptimizerStrategy.java | 4 ++-- .../tinkerpop/optimize/JanusGraphStep.java | 2 +- .../optimize/JanusGraphStepStrategy.java | 10 +++++----- .../blueprints/HBaseGraphComputerProvider.java | 4 +++- .../blueprints/AbstractJanusGraphProvider.java | 2 +- .../InMemoryGraphComputerProvider.java | 3 ++- 14 files changed, 49 insertions(+), 25 deletions(-) diff --git a/janusgraph-berkeleyje/src/test/java/org/janusgraph/blueprints/BerkeleyGraphComputerProvider.java b/janusgraph-berkeleyje/src/test/java/org/janusgraph/blueprints/BerkeleyGraphComputerProvider.java index a972b9788d1..57e7575478c 100644 --- a/janusgraph-berkeleyje/src/test/java/org/janusgraph/blueprints/BerkeleyGraphComputerProvider.java +++ b/janusgraph-berkeleyje/src/test/java/org/janusgraph/blueprints/BerkeleyGraphComputerProvider.java @@ -33,7 +33,8 @@ public class BerkeleyGraphComputerProvider extends AbstractJanusGraphComputerPro @Override public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class test, String testMethodName) { - ModifiableConfiguration config = BerkeleyStorageSetup.getBerkeleyJEConfiguration(StorageSetup.getHomeDir(graphName)); + ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName); + config.setAll(BerkeleyStorageSetup.getBerkeleyJEConfiguration(StorageSetup.getHomeDir(graphName)).getAll()); config.set(GraphDatabaseConfiguration.IDAUTHORITY_WAIT, Duration.ofMillis(20)); config.set(GraphDatabaseConfiguration.STORAGE_TRANSACTIONAL,false); return config; diff --git a/janusgraph-cassandra/src/test/java/org/janusgraph/blueprints/thrift/ThriftGraphComputerProvider.java b/janusgraph-cassandra/src/test/java/org/janusgraph/blueprints/thrift/ThriftGraphComputerProvider.java index 8d2fe520875..8253291909e 100644 --- a/janusgraph-cassandra/src/test/java/org/janusgraph/blueprints/thrift/ThriftGraphComputerProvider.java +++ b/janusgraph-cassandra/src/test/java/org/janusgraph/blueprints/thrift/ThriftGraphComputerProvider.java @@ -30,7 +30,9 @@ public class ThriftGraphComputerProvider extends AbstractJanusGraphComputerProvi @Override public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class test, String testMethodName) { CassandraStorageSetup.startCleanEmbedded(); - return CassandraStorageSetup.getCassandraThriftConfiguration(graphName); + ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName); + config.setAll(CassandraStorageSetup.getCassandraThriftConfiguration(graphName).getAll()); + return config; } } diff --git a/janusgraph-core/src/main/java/org/janusgraph/core/JanusGraph.java b/janusgraph-core/src/main/java/org/janusgraph/core/JanusGraph.java index dd51d2b9cf8..3c9f149fd93 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/core/JanusGraph.java +++ b/janusgraph-core/src/main/java/org/janusgraph/core/JanusGraph.java @@ -55,11 +55,13 @@ @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.structure.io.IoTest$GraphMLTest", method = "shouldReadGraphMLWithNoEdgeLabels", - reason = "Titan does not support default edge label (edge) used when GraphML is missing edge labels.") + reason = "JanusGraph does not support default edge label (edge) used when GraphML is missing edge labels.") @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest", method = "shouldSupportGraphFilter", - reason = "Titan currently does not support graph filters but does not throw proper exception because doing so breaks numerous tests in gremlin-test ProcessComputerSuite.") + reason = "JanusGraph test graph computer (FulgoraGraphComputer} " + + "currently does not support graph filters but does not throw proper exception because doing so breaks numerous " + + "tests in gremlin-test ProcessComputerSuite.") public interface JanusGraph extends Transaction { /* --------------------------------------------------------------- diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/serialize/attribute/SerializableSerializer.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/serialize/attribute/SerializableSerializer.java index 77625f0e11a..b28ea61d32a 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/serialize/attribute/SerializableSerializer.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/serialize/attribute/SerializableSerializer.java @@ -1,3 +1,17 @@ +// Copyright 2017 JanusGraph Authors +// +// 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. + package org.janusgraph.graphdb.database.serialize.attribute; import org.janusgraph.core.attribute.AttributeSerializer; @@ -11,6 +25,10 @@ import java.io.Serializable; import java.util.HashMap; +/** + * Serializes {@link Serializable} objects. + * @param Serializable type + */ public class SerializableSerializer implements AttributeSerializer, SerializerInjected { private Serializer serializer; diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/FulgoraMemory.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/FulgoraMemory.java index 7cd490a1204..18f31050c02 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/FulgoraMemory.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/FulgoraMemory.java @@ -158,9 +158,7 @@ protected void attachReferenceElements(Graph graph) { } private static void attachReferenceElements(TraverserSet toProcessTraversers, Graph graph) { - final Iterator> traversers = toProcessTraversers.iterator(); - while (traversers.hasNext()) { - final Traverser.Admin traverser = traversers.next(); + toProcessTraversers.stream().forEach(traverser -> { Object value = traverser.get(); if (value instanceof ReferenceVertex) { Vertex vertex = ((ReferenceVertex) value).attach(Attachable.Method.get(graph)); @@ -169,7 +167,7 @@ private static void attachReferenceElements(TraverserSet toProcessTraver Edge edge = ((ReferenceEdge) value).attach(Attachable.Method.get(graph)); traverser.set(edge); } - } + }); } } diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/VertexMemoryHandler.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/VertexMemoryHandler.java index ea8f6b906d1..bfc4d366579 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/VertexMemoryHandler.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/computer/VertexMemoryHandler.java @@ -41,7 +41,7 @@ class VertexMemoryHandler implements PreloadedVertex.PropertyMixing, Messenge protected final FulgoraVertexMemory vertexMemory; private final PreloadedVertex vertex; protected final long vertexId; - private boolean inExecute; + private volatile boolean inExecute; VertexMemoryHandler(FulgoraVertexMemory vertexMemory, PreloadedVertex vertex) { assert vertex!=null && vertexMemory!=null; @@ -67,7 +67,7 @@ public Iterator> properties(String... keys) { if (keys==null || keys.length==0) { keys = memoryKeys.stream().filter(k -> !k.equals(TraversalVertexProgram.HALTED_TRAVERSERS)).toArray(String[]::new); } - List> result = new ArrayList<>(Math.min(keys.length,memoryKeys.size())); + final List> result = new ArrayList<>(Math.min(keys.length,memoryKeys.size())); for (String key : keys) { if (!supports(key)) continue; V value = vertexMemory.getProperty(vertexId,key); diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java index eae0cdfa793..ed589cae025 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java @@ -78,14 +78,14 @@ public I io(final Io.Builder builder) { @Override public C compute(Class graphComputerClass) throws IllegalArgumentException { - TitanBlueprintsGraph graph = getGraph(); + JanusGraphBlueprintsGraph graph = getGraph(); if (isOpen()) commit(); return graph.compute(graphComputerClass); } @Override public FulgoraGraphComputer compute() throws IllegalArgumentException { - TitanBlueprintsGraph graph = getGraph(); + JanusGraphBlueprintsGraph graph = getGraph(); if (isOpen()) commit(); return graph.compute(); } diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java index c6ecf42de14..4065cc5b0b0 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java @@ -39,7 +39,7 @@ */ public class JanusGraphSONModule extends TinkerPopJacksonModule { - private static final String TYPE_NAMESPACE = "titan"; + private static final String TYPE_NAMESPACE = "janusgraph"; private static final Map TYPE_DEFINITIONS = Collections.unmodifiableMap( new LinkedHashMap() {{ @@ -48,7 +48,7 @@ public class JanusGraphSONModule extends TinkerPopJacksonModule { }}); private JanusGraphSONModule() { - super("titan"); + super("janusgraph"); addSerializer(RelationIdentifier.class, new RelationIdentifierSerializer()); addSerializer(Geoshape.class, new Geoshape.GeoshapeGsonSerializer()); diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphLocalQueryOptimizerStrategy.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphLocalQueryOptimizerStrategy.java index bee10e1784d..452a048b6fb 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphLocalQueryOptimizerStrategy.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphLocalQueryOptimizerStrategy.java @@ -50,8 +50,8 @@ public void apply(final Traversal.Admin traversal) { Graph graph = traversal.getGraph().get(); //If this is a compute graph then we can't apply local traversal optimisation at this stage. - StandardJanusGraph titanGraph = graph instanceof StandardJanusGraphTx ? ((StandardJanusGraphTx) graph).getGraph() : (StandardJanusGraph) graph; - final boolean useMultiQuery = !TraversalHelper.onGraphComputer(traversal) && titanGraph.getConfiguration().useMultiQuery(); + StandardJanusGraph janusGraph = graph instanceof StandardJanusGraphTx ? ((StandardJanusGraphTx) graph).getGraph() : (StandardJanusGraph) graph; + final boolean useMultiQuery = !TraversalHelper.onGraphComputer(traversal) && janusGraph.getConfiguration().useMultiQuery(); /* ====== VERTEX STEP ====== diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStep.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStep.java index 23400a90ef2..49d99565c54 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStep.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStep.java @@ -100,7 +100,7 @@ public List getHasContainers() { @Override public void addHasContainer(final HasContainer hasContainer) { - this.addAll(Collections.singleton(hasContainer)); + this.addAll(Collections.singleton(hasContainer)); } } diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStepStrategy.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStepStrategy.java index 57b1716ad4e..3a9d005b0f6 100644 --- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStepStrategy.java +++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/optimize/JanusGraphStepStrategy.java @@ -44,11 +44,11 @@ public void apply(final Traversal.Admin traversal) { TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(originalGraphStep -> { if (originalGraphStep.getIds() == null || originalGraphStep.getIds().length == 0) { //Try to optimize for index calls - final JanusGraphStep titanGraphStep = new JanusGraphStep<>(originalGraphStep); - TraversalHelper.replaceStep(originalGraphStep, (Step) titanGraphStep, traversal); - HasStepFolder.foldInHasContainer(titanGraphStep, traversal); - HasStepFolder.foldInOrder(titanGraphStep, traversal, traversal, titanGraphStep.returnsVertex()); - HasStepFolder.foldInRange(titanGraphStep, traversal); + final JanusGraphStep janusGraphStep = new JanusGraphStep<>(originalGraphStep); + TraversalHelper.replaceStep(originalGraphStep, (Step) janusGraphStep, traversal); + HasStepFolder.foldInHasContainer(janusGraphStep, traversal); + HasStepFolder.foldInOrder(janusGraphStep, traversal, traversal, janusGraphStep.returnsVertex()); + HasStepFolder.foldInRange(janusGraphStep, traversal); } else { //Make sure that any provided "start" elements are instantiated in the current transaction Object[] ids = originalGraphStep.getIds(); diff --git a/janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/blueprints/HBaseGraphComputerProvider.java b/janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/blueprints/HBaseGraphComputerProvider.java index cca13ba03c7..9ecda1d5d09 100644 --- a/janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/blueprints/HBaseGraphComputerProvider.java +++ b/janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/blueprints/HBaseGraphComputerProvider.java @@ -31,7 +31,9 @@ public class HBaseGraphComputerProvider extends AbstractJanusGraphComputerProvid @Override public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class test, String testMethodName) { - return HBaseStorageSetup.getHBaseConfiguration(graphName); + ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName); + config.setAll(HBaseStorageSetup.getHBaseConfiguration(graphName).getAll()); + return config; } @Override diff --git a/janusgraph-test/src/main/java/org/janusgraph/blueprints/AbstractJanusGraphProvider.java b/janusgraph-test/src/main/java/org/janusgraph/blueprints/AbstractJanusGraphProvider.java index 20eb13ec877..5bb45e9884f 100644 --- a/janusgraph-test/src/main/java/org/janusgraph/blueprints/AbstractJanusGraphProvider.java +++ b/janusgraph-test/src/main/java/org/janusgraph/blueprints/AbstractJanusGraphProvider.java @@ -73,7 +73,7 @@ */ public abstract class AbstractJanusGraphProvider extends AbstractGraphProvider { - private static final Logger logger = LoggerFactory.getLogger(AbstractTitanGraphProvider.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractJanusGraphProvider.class); private static final Set IMPLEMENTATION = new HashSet() {{ add(StandardJanusGraph.class); diff --git a/janusgraph-test/src/test/java/org/janusgraph/blueprints/InMemoryGraphComputerProvider.java b/janusgraph-test/src/test/java/org/janusgraph/blueprints/InMemoryGraphComputerProvider.java index e442487f3a0..31525f50505 100644 --- a/janusgraph-test/src/test/java/org/janusgraph/blueprints/InMemoryGraphComputerProvider.java +++ b/janusgraph-test/src/test/java/org/janusgraph/blueprints/InMemoryGraphComputerProvider.java @@ -28,7 +28,8 @@ public class InMemoryGraphComputerProvider extends AbstractJanusGraphComputerPro @Override public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class test, String testMethodName) { - ModifiableConfiguration config = StorageSetup.getInMemoryConfiguration(); + ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName); + config.setAll(StorageSetup.getInMemoryConfiguration().getAll()); config.set(GraphDatabaseConfiguration.STORAGE_TRANSACTIONAL,false); return config; }