You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/03/12 12:36:13 UTC
[1/2] incubator-tinkerpop git commit: Add basic Features to
RemoteGraph - disable transactions.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/TINKERPOP-575 6c438f43f -> feb8f1d85
Add basic Features to RemoteGraph - disable transactions.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/af5be942
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/af5be942
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/af5be942
Branch: refs/heads/TINKERPOP-575
Commit: af5be9421b8cedd8e6f8cdae14a50d5c8009df51
Parents: 6c438f4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Mar 12 06:02:25 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Sat Mar 12 06:02:25 2016 -0500
----------------------------------------------------------------------
.../gremlin/process/remote/RemoteGraph.java | 33 ++++++++++++++++++++
1 file changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/af5be942/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
index f818ba0..e88e824 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
@@ -162,4 +162,37 @@ public class RemoteGraph implements Graph {
public Configuration configuration() {
throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
}
+
+ @Override
+ public Features features() {
+ return RemoteFeatures.INSTANCE;
+ }
+
+ public static class RemoteFeatures implements Features {
+ static RemoteFeatures INSTANCE = new RemoteFeatures();
+
+ private RemoteFeatures() {}
+
+ @Override
+ public GraphFeatures graph() {
+ return RemoteGraphFeatures.INSTANCE;
+ }
+ }
+
+ public static class RemoteGraphFeatures implements Features.GraphFeatures {
+
+ static RemoteGraphFeatures INSTANCE = new RemoteGraphFeatures();
+
+ private RemoteGraphFeatures() {}
+
+ @Override
+ public boolean supportsTransactions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsThreadedTransactions() {
+ return false;
+ }
+ }
}
[2/2] incubator-tinkerpop git commit: Refactored RemoteGraphProvider
to speed up tests.
Posted by sp...@apache.org.
Refactored RemoteGraphProvider to speed up tests.
Cut the time down to about two-thirds of what it was by caching RemoteGraph instances, clearing graphs on the server with a Client instance and re-using the Cluster object.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/feb8f1d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/feb8f1d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/feb8f1d8
Branch: refs/heads/TINKERPOP-575
Commit: feb8f1d85a8082b6126b6d240c266c4559027787
Parents: af5be94
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Mar 12 06:34:29 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Sat Mar 12 06:34:29 2016 -0500
----------------------------------------------------------------------
.../driver/remote/DriverRemoteConnection.java | 7 ++
.../gremlin/remote/RemoteGraphProvider.java | 73 +++++++++-----------
.../tinkerpop/gremlin/AbstractGremlinTest.java | 1 +
3 files changed, 39 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/feb8f1d8/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index 7de5aaf..9527dfc 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -74,6 +74,13 @@ public class DriverRemoteConnection implements RemoteConnection {
this.conf = Optional.of(conf);
}
+ public DriverRemoteConnection(final Cluster cluster, final Configuration conf) {
+ connectionGraphName = conf.getString("connectionGraphName", "graph");
+ client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
+ tryCloseCluster = false;
+ this.conf = Optional.of(conf);
+ }
+
private DriverRemoteConnection(final Cluster cluster, final boolean tryCloseCluster, final String connectionGraphName){
client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
this.connectionGraphName = connectionGraphName;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/feb8f1d8/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/RemoteGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/RemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/RemoteGraphProvider.java
index 5ac1579..eba0a5d 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/RemoteGraphProvider.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/remote/RemoteGraphProvider.java
@@ -21,6 +21,8 @@ package org.apache.tinkerpop.gremlin.remote;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.AbstractGraphProvider;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest;
@@ -54,10 +56,10 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
add(RemoteGraph.class);
}};
- private TestListener testListener = new RemoteGraphTestListener();
private static GremlinServer server;
-
- private Executor executors = Executors.newFixedThreadPool(4);
+ private Map<String,RemoteGraph> remoteCache = new HashMap<>();
+ private Cluster cluster = Cluster.open();
+ private Client client = cluster.connect();
static {
try {
@@ -68,8 +70,28 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
}
@Override
+ public Graph openTestGraph(final Configuration config) {
+ final String serverGraphName = config.getString("connectionGraphName");
+ return remoteCache.computeIfAbsent(serverGraphName,
+ k -> RemoteGraph.open(new DriverRemoteConnection(cluster, config), TinkerGraph.class));
+ }
+
+ @Override
public Map<String, Object> getBaseConfiguration(final String graphName, Class<?> test, final String testMethodName,
final LoadGraphWith.GraphData loadGraphWith) {
+ final String serverGraphName = getServerGraphName(loadGraphWith);
+
+ final Supplier<Graph> graphGetter = () -> server.getServerGremlinExecutor().getGraphManager().getGraphs().get(serverGraphName);
+ return new HashMap<String, Object>() {{
+ put(Graph.GRAPH, RemoteGraph.class.getName());
+ put(RemoteGraph.GREMLIN_SERVERGRAPH_GRAPH_CLASS, TinkerGraph.class.getName());
+ put(RemoteGraph.GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS, DriverRemoteConnection.class.getName());
+ put("connectionGraphName", serverGraphName);
+ put("hidden.for.testing.only", graphGetter);
+ }};
+ }
+
+ private static String getServerGraphName(LoadGraphWith.GraphData loadGraphWith) {
final String serverGraphName;
switch (loadGraphWith) {
case CLASSIC:
@@ -88,28 +110,16 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
serverGraphName = "graph";
break;
}
-
- final Supplier<Graph> graphGetter = () -> server.getServerGremlinExecutor().getGraphManager().getGraphs().get(serverGraphName);
- return new HashMap<String, Object>() {{
- put(Graph.GRAPH, RemoteGraph.class.getName());
- put(RemoteGraph.GREMLIN_SERVERGRAPH_GRAPH_CLASS, TinkerGraph.class.getName());
- put(RemoteGraph.GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS, DriverRemoteConnection.class.getName());
- put("connectionGraphName", serverGraphName);
- put("hidden.for.testing.only", graphGetter);
- }};
+ return serverGraphName;
}
@Override
public void clear(final Graph graph, final Configuration configuration) throws Exception {
- if (graph != null) {
- executors.execute(() -> {
- try {
- graph.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- });
- }
+ // doesn't bother to clear grateful because i don't believe that ever gets mutated - read-only
+ client.submit("classic.clear();modern.clear();crew.clear();graph.clear();" +
+ "TinkerFactory.generateClassic(classic);" +
+ "TinkerFactory.generateModern(modern);" +
+ "TinkerFactory.generateTheCrew(crew);null").all().get();
}
@Override
@@ -122,11 +132,6 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
return IMPLEMENTATION;
}
- @Override
- public Optional<TestListener> getTestListener() {
- return Optional.of(testListener);
- }
-
public static void startServer() throws Exception {
final InputStream stream = RemoteGraphProvider.class.getResourceAsStream("gremlin-server-integration.yaml");
final Settings settings = Settings.read(stream);
@@ -140,20 +145,4 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
server.stop().join();
server = null;
}
-
- public class RemoteGraphTestListener implements TestListener {
- @Override
- public void onTestEnd(final Class<?> test, final String testName) {
- if (test.equals(DropTest.Traversals.class) ||
- test.equals(AddEdgeTest.Traversals.class) ||
- test.equals(AddVertexTest.Traversals.class)) {
- try {
- stopServer();
- startServer();
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/feb8f1d8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index 3f5b5c3..9354c18 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@ -31,6 +31,7 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.slf4j.Logger;