Skip to content

Commit 486f4ae

Browse files
author
Alexander Patrikalakis
authored
Merge pull request JanusGraph#78 from ngageoint/tinkerpop-upgrade
Update to TinkerPop 3.2.3
2 parents b66a578 + 48104fe commit 486f4ae

36 files changed

Lines changed: 446 additions & 219 deletions

File tree

janusgraph-berkeleyje/src/test/java/org/janusgraph/blueprints/BerkeleyGraphComputerProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class BerkeleyGraphComputerProvider extends AbstractJanusGraphComputerPro
3333

3434
@Override
3535
public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class<?> test, String testMethodName) {
36-
ModifiableConfiguration config = BerkeleyStorageSetup.getBerkeleyJEConfiguration(StorageSetup.getHomeDir(graphName));
36+
ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName);
37+
config.setAll(BerkeleyStorageSetup.getBerkeleyJEConfiguration(StorageSetup.getHomeDir(graphName)).getAll());
3738
config.set(GraphDatabaseConfiguration.IDAUTHORITY_WAIT, Duration.ofMillis(20));
3839
config.set(GraphDatabaseConfiguration.STORAGE_TRANSACTIONAL,false);
3940
return config;

janusgraph-cassandra/src/test/java/org/janusgraph/blueprints/thrift/ThriftGraphComputerProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import org.janusgraph.CassandraStorageSetup;
1818
import org.janusgraph.blueprints.AbstractJanusGraphComputerProvider;
19-
import org.janusgraph.blueprints.AbstractJanusGraphProvider;
2019
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
2120
import org.janusgraph.graphdb.olap.computer.FulgoraGraphComputer;
2221
import org.apache.tinkerpop.gremlin.GraphProvider;
@@ -30,7 +29,9 @@ public class ThriftGraphComputerProvider extends AbstractJanusGraphComputerProvi
3029
@Override
3130
public ModifiableConfiguration getJanusGraphConfiguration(String graphName, Class<?> test, String testMethodName) {
3231
CassandraStorageSetup.startCleanEmbedded();
33-
return CassandraStorageSetup.getCassandraThriftConfiguration(graphName);
32+
ModifiableConfiguration config = super.getJanusGraphConfiguration(graphName, test, testMethodName);
33+
config.setAll(CassandraStorageSetup.getCassandraThriftConfiguration(graphName).getAll());
34+
return config;
3435
}
3536

3637
}

janusgraph-core/src/main/java/org/janusgraph/core/JanusGraph.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@
5252
test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest",
5353
method = "shouldProcessResultGraphNewWithPersistVertexProperties",
5454
reason = "The result graph should return an empty iterator when vertex.edges() or vertex.vertices() is called.")
55+
@Graph.OptOut(
56+
test = "org.apache.tinkerpop.gremlin.structure.io.IoTest$GraphMLTest",
57+
method = "shouldReadGraphMLWithNoEdgeLabels",
58+
reason = "JanusGraph does not support default edge label (edge) used when GraphML is missing edge labels.")
59+
@Graph.OptOut(
60+
test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest",
61+
method = "shouldSupportGraphFilter",
62+
reason = "JanusGraph test graph computer (FulgoraGraphComputer) " +
63+
"currently does not support graph filters but does not throw proper exception because doing so breaks numerous " +
64+
"tests in gremlin-test ProcessComputerSuite.")
5565
public interface JanusGraph extends Transaction {
5666

5767
/* ---------------------------------------------------------------

janusgraph-core/src/main/java/org/janusgraph/diskstorage/BackendTransaction.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.janusgraph.diskstorage.keycolumnvalue.cache.KCVSCache;
2727
import org.janusgraph.diskstorage.log.kcvs.ExternalCachePersistor;
2828
import org.apache.commons.lang.StringUtils;
29+
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalInterruptedException;
2930
import org.slf4j.Logger;
3031
import org.slf4j.LoggerFactory;
3132

@@ -439,8 +440,14 @@ public String toString() {
439440

440441

441442
private final <V> V executeRead(Callable<V> exe) throws JanusGraphException {
442-
return BackendOperation.execute(exe, maxReadTime);
443+
try {
444+
return BackendOperation.execute(exe, maxReadTime);
445+
} catch (JanusGraphException e) {
446+
// support traversal interruption
447+
// TODO: Refactor to allow direct propagation of underlying interrupt exception
448+
if (Thread.interrupted()) throw new TraversalInterruptedException();
449+
throw e;
450+
}
443451
}
444452

445-
446453
}

janusgraph-core/src/main/java/org/janusgraph/diskstorage/keycolumnvalue/scan/ScanJob.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface ScanJob extends Cloneable {
3333
/**
3434
* Invoked before a block of computation (i.e. multiple process() calls) is handed to this particular ScanJob.
3535
* Can be used to initialize the iteration. This method is called exactly once for each before a block of computation.
36-
* This method is semantically aligned with {@link com.tinkerpop.gremlin.process.computer.VertexProgram#workerIterationStart()}
36+
* This method is semantically aligned with {@link org.tinkerpop.gremlin.process.computer.VertexProgram#workerIterationStart()}
3737
*
3838
* This method may not be called if there is no data to be processed. Correspondingly, the end method won't be called either.
3939
*
@@ -49,7 +49,7 @@ public default void workerIterationStart(Configuration jobConfiguration,
4949
/**
5050
* Invoked after a block of computation (i.e. multiple process() calls) is handed to this particular ScanJob.
5151
* Can be used to close any resources held by this job. This method is called exactly once for each after a block of computation.
52-
* This method is semantically aligned with {@link com.tinkerpop.gremlin.process.computer.VertexProgram#workerIterationEnd()}
52+
* This method is semantically aligned with {@link org.tinkerpop.gremlin.process.computer.VertexProgram#workerIterationEnd()}
5353
*
5454
* This method may not be called if there is no data to be processed. Correspondingly, the start method won't be called either.
5555
*

janusgraph-core/src/main/java/org/janusgraph/diskstorage/util/BackendOperation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public static final<V> V executeDirect(Callable<V> exe, Duration totalWaitTime)
9090
try {
9191
Thread.sleep(waitTime.toMillis());
9292
} catch (InterruptedException r) {
93+
// added thread interrupt signal to support traversal interruption
94+
Thread.currentThread().interrupt();
9395
throw new PermanentBackendException("Interrupted while waiting to retry failed backend operation", r);
9496
}
9597
} else {

janusgraph-core/src/main/java/org/janusgraph/graphdb/database/serialize/StandardSerializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.janusgraph.graphdb.types.TypeDefinitionCategory;
4242
import org.janusgraph.graphdb.types.TypeDefinitionDescription;
4343

44+
import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
4445
import org.apache.tinkerpop.gremlin.structure.Direction;
4546
import org.slf4j.Logger;
4647
import org.slf4j.LoggerFactory;
@@ -133,6 +134,8 @@ public StandardSerializer() {
133134
registerClassInternal(64,Duration.class, new DurationSerializer());
134135
registerClassInternal(65,Instant.class, new InstantSerializer());
135136
registerClassInternal(66,StandardTransactionId.class, new StandardTransactionIdSerializer());
137+
registerClassInternal(67,TraverserSet.class, new SerializableSerializer());
138+
registerClassInternal(68,HashMap.class, new SerializableSerializer());
136139

137140
}
138141

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2017 JanusGraph Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package org.janusgraph.graphdb.database.serialize.attribute;
16+
17+
import org.janusgraph.core.attribute.AttributeSerializer;
18+
import org.janusgraph.diskstorage.ScanBuffer;
19+
import org.janusgraph.diskstorage.WriteBuffer;
20+
import org.janusgraph.graphdb.database.serialize.DataOutput;
21+
import org.janusgraph.graphdb.database.serialize.Serializer;
22+
import org.janusgraph.graphdb.database.serialize.SerializerInjected;
23+
import org.apache.commons.lang3.SerializationUtils;
24+
25+
import java.io.Serializable;
26+
27+
/**
28+
* Serializes {@link Serializable} objects.
29+
* @param <T> Serializable type
30+
*/
31+
public class SerializableSerializer<T extends Serializable> implements AttributeSerializer<T>, SerializerInjected {
32+
33+
private Serializer serializer;
34+
35+
@Override
36+
public T read(ScanBuffer buffer) {
37+
byte[] data = serializer.readObjectNotNull(buffer,byte[].class);
38+
return (T) SerializationUtils.deserialize(data);
39+
}
40+
41+
@Override
42+
public void write(WriteBuffer buffer, T attribute) {
43+
DataOutput out = (DataOutput) buffer;
44+
out.writeObjectNotNull(SerializationUtils.serialize(attribute));
45+
}
46+
47+
@Override
48+
public void setSerializer(Serializer serializer) {
49+
this.serializer = serializer;
50+
}
51+
52+
}

janusgraph-core/src/main/java/org/janusgraph/graphdb/olap/VertexJobConverter.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ protected VertexJobConverter(JanusGraph graph, VertexScanJob job) {
7272
}
7373

7474
protected VertexJobConverter(VertexJobConverter copy) {
75-
this.graph = new GraphProvider();
76-
if (copy.graph.isProvided()) this.graph.setGraph(copy.graph.get());
75+
this.graph = copy.graph;
7776
this.job = copy.job.clone();
77+
this.tx = copy.tx;
78+
this.idManager = copy.idManager;
7879
}
7980

8081
public static ScanJob convert(JanusGraph graph, VertexScanJob vertexJob) {
@@ -96,18 +97,22 @@ public static StandardJanusGraphTx startTransaction(StandardJanusGraph graph) {
9697

9798
@Override
9899
public void workerIterationStart(Configuration jobConfig, Configuration graphConfig, ScanMetrics metrics) {
99-
graph.initializeGraph(graphConfig);
100-
idManager = graph.get().getIDManager();
101100
try {
102-
tx = startTransaction(graph.get());
101+
open(graphConfig);
103102
job.workerIterationStart(graph.get(), jobConfig, metrics);
104103
} catch (Throwable e) {
105104
close();
106105
throw e;
107106
}
108107
}
109108

110-
private void close() {
109+
protected void open(Configuration graphConfig) {
110+
graph.initializeGraph(graphConfig);
111+
idManager = graph.get().getIDManager();
112+
tx = startTransaction(graph.get());
113+
}
114+
115+
protected void close() {
111116
if (null != tx && tx.isOpen())
112117
tx.rollback();
113118
graph.close();

0 commit comments

Comments
 (0)