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/08/17 20:40:22 UTC

[1/3] tinkerpop git commit: Minor renaming of config options for withRemote()

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 4a6645517 -> b42fc2af9


Minor renaming of config options for withRemote()


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/17b3987c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/17b3987c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/17b3987c

Branch: refs/heads/TINKERPOP-1278
Commit: 17b3987c9d651c7c4e51e1b24ed7b65b65760e11
Parents: b4c6139
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 17 16:39:03 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 17 16:39:03 2016 -0400

----------------------------------------------------------------------
 .../process/traversal/TraversalSource.java      | 12 ++++++------
 .../tinkerpop/gremlin/util/CoreImports.java     |  2 ++
 .../driver/remote/DriverRemoteConnection.java   | 20 ++++++++++----------
 .../driver/remote/RemoteGraphProvider.java      |  5 ++---
 4 files changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/17b3987c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
index 5e82716..06971fb 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
@@ -55,8 +55,8 @@ import java.util.function.UnaryOperator;
  */
 public interface TraversalSource extends Cloneable {
 
-    // TODO: this is GraphFactory naming convention, but we're not GraphFactory compliant anymore so maybe change the config option?
-    public static final String GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS = "gremlin.remoteGraph.remoteConnectionClass";
+    public static final String GREMLIN_REMOTE = "gremlin.remote.";
+    public static final String GREMLIN_REMOTE_CONNECTION_CLASS = GREMLIN_REMOTE + "remoteConnectionClass";
 
     /**
      * Get the {@link TraversalStrategies} associated with this traversal source.
@@ -396,17 +396,17 @@ public interface TraversalSource extends Cloneable {
 
     /**
      * Configures the {@code TraversalSource} as a "remote" to issue the {@link Traversal} for execution elsewhere.
-     * Expects key for {@link #GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS} as well as any configuration required by
+     * Expects key for {@link #GREMLIN_REMOTE_CONNECTION_CLASS} as well as any configuration required by
      * the underlying {@link RemoteConnection} which will be instantiated. Note that the {@code Configuration} object
      * is passed down without change to the creation of the {@link RemoteConnection} instance.
      */
     public default TraversalSource withRemote(final Configuration conf) {
-        if (!conf.containsKey(GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS))
-            throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS + "' key");
+        if (!conf.containsKey(GREMLIN_REMOTE_CONNECTION_CLASS))
+            throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_REMOTE_CONNECTION_CLASS + "' key");
 
         final RemoteConnection remoteConnection;
         try {
-            final Class<? extends RemoteConnection> clazz = Class.forName(conf.getString(GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS)).asSubclass(RemoteConnection.class);
+            final Class<? extends RemoteConnection> clazz = Class.forName(conf.getString(GREMLIN_REMOTE_CONNECTION_CLASS)).asSubclass(RemoteConnection.class);
             final Constructor<? extends RemoteConnection> ctor = clazz.getConstructor(Configuration.class);
             remoteConnection = ctor.newInstance(conf);
         } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/17b3987c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
index d95f8ef..6dd1164 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
@@ -81,6 +81,7 @@ import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoCore;
 import org.apache.tinkerpop.gremlin.structure.io.Storage;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -126,6 +127,7 @@ public final class CoreImports {
         // remote
         CLASS_IMPORTS.add(RemoteConnection.class);
         CLASS_IMPORTS.add(RemoteGraph.class);
+        CLASS_IMPORTS.add(EmptyGraph.class);
         // io
         CLASS_IMPORTS.add(GraphReader.class);
         CLASS_IMPORTS.add(GraphWriter.class);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/17b3987c/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 394d418..c1eba34 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
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.RemoteTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
@@ -45,9 +46,8 @@ import java.util.function.Supplier;
  */
 public class DriverRemoteConnection implements RemoteConnection {
 
-    public static final String GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE = "gremlin.remoteGraph.driver.clusterFile";
-
-    public static final String GREMLIN_REMOTE_GRAPH_DRIVER_SOURCENAME = "gremlin.remoteGraph.driver.sourceName";
+    public static final String GREMLIN_REMOTE_DRIVER_CLUSTERFILE = TraversalSource.GREMLIN_REMOTE + "driver.clusterFile";
+    public static final String GREMLIN_REMOTE_DRIVER_SOURCENAME = TraversalSource.GREMLIN_REMOTE + "driver.sourceName";
 
     private static final String DEFAULT_TRAVERSAL_SOURCE = "g";
 
@@ -59,18 +59,18 @@ public class DriverRemoteConnection implements RemoteConnection {
     private static final boolean attachElements = Boolean.valueOf(System.getProperty("is.testing", "false"));
 
     public DriverRemoteConnection(final Configuration conf) {
-        if (conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) && conf.containsKey("clusterConfiguration"))
-            throw new IllegalStateException(String.format("A configuration should not contain both '%s' and 'clusterConfiguration'", GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE));
+        if (conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) && conf.containsKey("clusterConfiguration"))
+            throw new IllegalStateException(String.format("A configuration should not contain both '%s' and 'clusterConfiguration'", GREMLIN_REMOTE_DRIVER_CLUSTERFILE));
 
-        remoteTraversalSourceName = conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_SOURCENAME, DEFAULT_TRAVERSAL_SOURCE);
+        remoteTraversalSourceName = conf.getString(GREMLIN_REMOTE_DRIVER_SOURCENAME, DEFAULT_TRAVERSAL_SOURCE);
 
         try {
             final Cluster cluster;
-            if (!conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) && !conf.containsKey("clusterConfiguration"))
+            if (!conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) && !conf.containsKey("clusterConfiguration"))
                 cluster = Cluster.open();
             else
-                cluster = conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) ?
-                        Cluster.open(conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE)) : Cluster.open(conf.subset("clusterConfiguration"));
+                cluster = conf.containsKey(GREMLIN_REMOTE_DRIVER_CLUSTERFILE) ?
+                        Cluster.open(conf.getString(GREMLIN_REMOTE_DRIVER_CLUSTERFILE)) : Cluster.open(conf.subset("clusterConfiguration"));
 
             client = cluster.connect(Client.Settings.build().create()).alias(remoteTraversalSourceName);
         } catch (Exception ex) {
@@ -91,7 +91,7 @@ public class DriverRemoteConnection implements RemoteConnection {
      * This constructor is largely just for unit testing purposes and should not typically be used externally.
      */
     DriverRemoteConnection(final Cluster cluster, final Configuration conf) {
-        remoteTraversalSourceName = conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_SOURCENAME, DEFAULT_TRAVERSAL_SOURCE);
+        remoteTraversalSourceName = conf.getString(GREMLIN_REMOTE_DRIVER_SOURCENAME, DEFAULT_TRAVERSAL_SOURCE);
 
         client = cluster.connect(Client.Settings.build().create()).alias(remoteTraversalSourceName);
         tryCloseCluster = false;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/17b3987c/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
index 35bbd3f..c50d29a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
@@ -24,7 +24,6 @@ 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.process.remote.RemoteGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.server.GremlinServer;
 import org.apache.tinkerpop.gremlin.server.ServerTestHelper;
@@ -61,7 +60,7 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
 
     @Override
     public Graph openTestGraph(final Configuration config) {
-        final String serverGraphName = config.getString(DriverRemoteConnection.GREMLIN_REMOTE_GRAPH_DRIVER_SOURCENAME);
+        final String serverGraphName = config.getString(DriverRemoteConnection.GREMLIN_REMOTE_DRIVER_SOURCENAME);
         return remoteCache.computeIfAbsent(serverGraphName,
                 k -> RemoteGraph.open(new DriverRemoteConnection(cluster, config)));
     }
@@ -75,7 +74,7 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
         return new HashMap<String, Object>() {{
             put(Graph.GRAPH, RemoteGraph.class.getName());
             put(RemoteGraph.GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS, DriverRemoteConnection.class.getName());
-            put(DriverRemoteConnection.GREMLIN_REMOTE_GRAPH_DRIVER_SOURCENAME, "g" + serverGraphName);
+            put(DriverRemoteConnection.GREMLIN_REMOTE_DRIVER_SOURCENAME, "g" + serverGraphName);
             put("hidden.for.testing.only", graphGetter);
         }};
     }


[3/3] tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-1278' into TINKERPOP-1278

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP-1278' into TINKERPOP-1278


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b42fc2af
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b42fc2af
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b42fc2af

Branch: refs/heads/TINKERPOP-1278
Commit: b42fc2af92471cd4e2b3bef24fe239b1dac7d003
Parents: 1a519ac 4a66455
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 17 16:40:03 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 17 16:40:03 2016 -0400

----------------------------------------------------------------------
 docs/preprocessor/awk/init-code-blocks.awk      |  7 +-
 docs/src/reference/gremlin-variants.asciidoc    | 98 +++++++++++---------
 .../process/traversal/TraversalSource.java      |  1 +
 .../python/GraphTraversalSourceGenerator.groovy | 15 ++-
 .../python/TraversalSourceGenerator.groovy      |  7 +-
 .../jython/gremlin_python/driver/__init__.py    |  7 +-
 .../gremlin_python/driver/remote_connection.py  | 13 +++
 .../gremlin_python/process/graph_traversal.py   | 24 ++---
 .../jython/gremlin_python/process/traversal.py  |  7 +-
 .../jython/gremlin_python/structure/__init__.py |  1 -
 .../jython/gremlin_python/structure/graph.py    |  6 ++
 .../gremlin_python/structure/remote_graph.py    | 45 ---------
 .../driver/WebSocketRemoteConnectionTest.java   |  4 +-
 .../python/jsr223/JythonScriptEngineSetup.java  |  2 +-
 .../jsr223/PythonGraphSONJavaTranslator.java    |  2 +-
 .../conf/gremlin-server-modern-py.yaml          |  4 +-
 16 files changed, 124 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b42fc2af/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
----------------------------------------------------------------------


[2/3] tinkerpop git commit: Modified documentation of RemoteGraph to now be about withRemote()

Posted by sp...@apache.org.
Modified documentation of RemoteGraph to now be about withRemote()


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1a519acf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1a519acf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1a519acf

Branch: refs/heads/TINKERPOP-1278
Commit: 1a519acf3f6735f4dff9986d2cb2e9b23a966386
Parents: 17b3987
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 17 16:39:30 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 17 16:39:30 2016 -0400

----------------------------------------------------------------------
 .../src/reference/gremlin-applications.asciidoc | 52 ++++++++++----------
 1 file changed, 25 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1a519acf/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index bcae78f..86bd67c 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -811,8 +811,8 @@ quite possible that such a script will generate `OutOfMemoryError` exceptions on
 WebSockets configuration, which supports streaming, if that type of use case is required.
 
 [[connecting-via-remotegraph]]
-Connecting via RemoteGraph
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+Connecting via withRemote
+~~~~~~~~~~~~~~~~~~~~~~~~~
 
 [source,xml]
 ----
@@ -823,39 +823,33 @@ Connecting via RemoteGraph
 </dependency>
 ----
 
-image:remote-graph.png[width=145,float=left] `RemoteGraph` is a lightweight `Graph` implementation that acts as a
-proxy for sending traversals to Gremlin Server for remote execution. It is not a "full" implementation like
-`TinkerGraph` or `Neo4jGraph`, in that most of its methods are not implemented. For example, calls to most methods
-like, `addVertex()` or `edges()` will result in an `UnsupportedOperationException`. The only method used on
-`RemoteGraph` is `traversal()`, which generates a `GraphTraversalSource` that includes a `RemoteStrategy`. The
-`RemoteStrategy` takes traversals constructed from it, serializes them and submits them to Gremlin Server
-and the results are returned as though working with the `Graph` instance in embedded mode.
-
-`RemoteGraph` is an interesting alternative to the other methods for connecting to Gremlin Server in that all other
-methods involved construction of a `String` representation of the `Traversal` which is then submitted as a script
+image:remote-graph.png[width=145,float=left] A `TraversalSource` has several `withRemote()` methods which provide an
+interesting alternative to the other methods for connecting to Gremlin Server. It is interesting in that all other
+methods involve construction of a `String` representation of the `Traversal` which is then submitted as a script
 to Gremlin Server (via driver or REST). This approach is quite akin to SQL, where query strings are embedded into code
 and submitted to a database server. While there are patterns for taking this approach that can lead to maintainable
-application code, using `RemoteGraph` could be a better method as it brings some good benefits with it:
+application code, using `withRemote()` could be a better method as it brings some good benefits with it:
 
 * Get auto-complete when writing traversals in an IDE.
 * Get compile-time errors in traversal writing.
 * Get the feel of working with an embedded database.
 
-One way to create a `RemoteGraph` instance is by configuration file. Here is an example of what that file looks like:
+One way to create a `Traversal` instance that is remote-enabled is by configuration file. Here is an example of what
+that file looks like:
 
 [source,properties]
 ----
-gremlin.remoteGraph.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
-gremlin.remoteGraph.driver.clusterFile=conf/remote-objects.yaml
-gremlin.remoteGraph.driver.sourceName=g
+gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
+gremlin.remote.driver.clusterFile=conf/remote-objects.yaml
+gremlin.remote.driver.sourceName=g
 ----
 
-The `gremlin.remoteGraph.remoteConnectionClass` should be an implementation of the `RemoteConnection` interface in
+The `gremlin.remote.remoteConnectionClass` should be an implementation of the `RemoteConnection` interface in
 `gremlin-core`. In this case, it points at the `gremlin-driver` implementation, called `DriverRemoteConnection`. The
-other setting, `gremlin.remoteGraph.driver.clusterFile`, is a configuration to `DriverRemoteConnection`, and it
+other setting, `gremlin.remote.driver.clusterFile`, is a configuration to `DriverRemoteConnection`, and it
 provides a pointer to the config file to use to construct a `gremlin-driver` `Cluster` object to be utilized when
 connecting to Gremlin Server. Please see the <<connecting-via-java, "Connecting Via Java">> section for more
-information on those classes and their usage. Finally, the `gremlin.remoteGraph.driver.sourceName` setting tells the
+information on those classes and their usage. Finally, the `gremlin.remote.driver.sourceName` setting tells the
 `DriverRemoteConnection` the name of the `TraversalSource` in Gremlin Server to connect to.
 
 Gremlin Server needs to be running for this example to work. Use the following configuration:
@@ -863,23 +857,27 @@ Gremlin Server needs to be running for this example to work. Use the following c
 [source,bourne]
 $ bin/gremlin-server.sh conf/gremlin-server-modern.yaml
 
-`RemoteGraph` can be demonstrated in the Gremlin Console just like any other `Graph` instance:
+To configure a "remote" traversal, there first needs to be a `TraversalSource`. A `TraversalSource` can be generated
+from any `Graph` instance with the `traversal()` method. Of course, any traversals generated from this source using the
+`withRemote()` configuration option will not execute against the local graph. That could be confusing and it maybe be
+easier to think of the local graph as being "empty". To that end, it is recommended that when using `withRemote()`,
+the `TraversalSource` be generated with `EmptyGraph` as follows:
 
 [gremlin-groovy]
 ----
-graph = RemoteGraph.open('conf/remote-graph.properties')
-g = graph.traversal()
+graph = EmptyGraph.instance()
+g = graph.traversal().withRemote('conf/remote-graph.properties'))
 g.V().valueMap(true)
 ----
 
-If working with multiple `RemoteGraph` instances it is more efficient to construct your own `Cluster` object and
-re-use it.
+If working with multiple remote `TraversalSource` instances it is more efficient to construct a `Cluster` object and
+then re-use it.
 
 [gremlin-groovy]
 ----
 cluster = Cluster.open('conf/remote-objects.yaml')
-graph = RemoteGraph.open(DriverRemoteConnection.using(cluster, "graph"))
-g = graph.traversal()
+graph = EmptyGraph.instance()
+g = graph.traversal().withRemote(DriverRemoteConnection.using(cluster, "g"))
 g.V().valueMap(true)
 graph.close()
 cluster.close()