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/09 22:15:38 UTC

[10/17] incubator-tinkerpop git commit: Added allowRemoteConsole to RemoteAcceptor interface.

Added allowRemoteConsole to RemoteAcceptor interface.

This allows a RemnoteAcceptor implementation to opt-out of being used with :remote console. That's important because sometimes a plugin expects that the user will work with both local and remote resources and :remote console would mess that up.  Gephi is a good example of this.


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

Branch: refs/heads/TINKERPOP-1096
Commit: afeffc4b79313ec50a866e5563a1413fe53ef2a1
Parents: 0b0838a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 9 14:17:46 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 9 16:15:01 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                  |  1 +
 docs/src/dev/provider/index.asciidoc                |  1 +
 docs/src/upgrade/index.asciidoc                     |  1 +
 docs/src/upgrade/release-3.1.x-incubating.asciidoc  | 14 ++++++++++++++
 .../gremlin/console/commands/RemoteCommand.groovy   |  2 ++
 .../console/groovy/plugin/DriverRemoteAcceptor.java |  5 +++++
 .../gremlin/groovy/plugin/RemoteAcceptor.java       | 16 ++++++++++++++++
 .../hadoop/groovy/plugin/HadoopRemoteAcceptor.java  |  5 +++++
 8 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 6628c94..c14f6a8 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added `allowRemoteConsole()` to the `RemoteAcceptor` interface.
 * The `:remote` for `tinkerpop.server` now includes an option to establish the connection as a "session".
 * Provided an implementation for calls to `SessionedClient.alias()`, which formerly threw an `UnsupportedOperationException`.
 * Bumped to commons-collections 3.2.2.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/docs/src/dev/provider/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc
index 5968d87..4624bb1 100644
--- a/docs/src/dev/provider/index.asciidoc
+++ b/docs/src/dev/provider/index.asciidoc
@@ -33,6 +33,7 @@ This document attempts to address the needs of the different providers that have
 ** Graph Processor Provider
 * Graph Driver Provider
 * Graph Language Provider
+* Graph Plugin Provider
 
 [[graph-system-provider-requirements]]
 Graph System Provider Requirements

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/docs/src/upgrade/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/index.asciidoc b/docs/src/upgrade/index.asciidoc
index e877e07..e1d07db 100644
--- a/docs/src/upgrade/index.asciidoc
+++ b/docs/src/upgrade/index.asciidoc
@@ -33,6 +33,7 @@ These providers include:
 ** Graph Processor Provider
 * Graph Driver Provider
 * Graph Language Provider
+* Graph Plugin Provider
 
 include::release-3.1.x-incubating.asciidoc[]
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.1.x-incubating.asciidoc b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
index bc127b0..7816fc5 100644
--- a/docs/src/upgrade/release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
@@ -135,6 +135,20 @@ this value as `false`, so there is no change to the protocol for this feature.
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1039[TINKERPOP-1039],
 link:http://tinkerpop.apache.org/docs/3.1.2-incubating/reference/#sessions[Reference Documentation - Considering Sessions]
 
+Plugin Providers
+^^^^^^^^^^^^^^^^
+
+RemoteAcceptor allowRemoteConsole
++++++++++++++++++++++++++++++++++
+
+The `RemoteAcceptor` now has a new method called `allowRemoteConsole()`.  It has a default implementation that
+returns `false` and should thus be a non-breaking change for current implementations.  This value should only be set
+to `true` if the implementation expects the user to always use `:>` to interact with it.  For example, the
+`tinkerpop.server` plugin expects all user interaction through `:>`, where the line is sent to Gremlin Server.  In
+that case, that `RemoteAcceptor` implementation can return `true`.  On the other hand, the `tinkerpop.gephi` plugin,
+expects that the user sometimes call `:>` and sometimes work with local evaluation as well. It interacts with the
+local variable bindings in the console itself. For `tinkerpop.gephi`, this method returns `false`.
+
 TinkerPop 3.1.1
 ---------------
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
index 8236bf0..5662356 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
@@ -117,6 +117,8 @@ class RemoteCommand extends ComplexCommandSupport {
 
     def Object do_console = {
         if (mediator.remotes.size() == 0) return "Please add a remote first with [connect]"
+        if (!mediator.currentRemote().allowRemoteConsole()) return "The ${mediator.currentRemote()} is not compatible with 'connect' - use ':>' instead"
+
         mediator.localEvaluation = !mediator.localEvaluation
         if (mediator.localEvaluation)
             return "Exited remote console - all commands will be evaluated locally"

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
index 593ca6e..c32a593 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
@@ -187,6 +187,11 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
     }
 
     @Override
+    public boolean allowRemoteConsole() {
+        return true;
+    }
+
+    @Override
     public String toString() {
         return "Gremlin Server - [" + this.currentCluster + "]" + getSessionStringSegment();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java
index 4fee2b8..0cf8bac 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java
@@ -66,6 +66,22 @@ public interface RemoteAcceptor extends Closeable {
     public Object submit(final List<String> args) throws RemoteException;
 
     /**
+     * If the {@code RemoteAcceptor} is used in the Gremlin Console, then this method might be called to determine
+     * if it can be used in a fashion that supports the {@code :remote console} command.  By default, this value is
+     * set to {@code false}.
+     * <p/>
+     * A {@code RemoteAcceptor} should only return {@code true} for this method if it expects that all activities it
+     * supports are executed through the {@code :sumbit} command. If the users interaction with the remote requires
+     * working with both local and remote evaluation at the same time, it is likely best to keep this method return
+     * {@code false}. A good example of this type of plugin would be the Gephi Plugin which uses {@code :remote config}
+     * to configure a local {@code TraversalSource} to be used and expects calls to {@code :submit} for the same body
+     * of analysis.
+     */
+    public default boolean allowRemoteConsole() {
+        return false;
+    }
+
+    /**
      * Retrieve a script as defined in the shell context.  This allows for multi-line scripts to be submitted.
      */
     public static String getScript(final String submittedScript, final Groovysh shell) {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/afeffc4b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
index aa6e9f4..48db1b0 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
@@ -108,6 +108,11 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
     }
 
     @Override
+    public boolean allowRemoteConsole() {
+        return true;
+    }
+
+    @Override
     public void close() throws IOException {
         this.hadoopGraph.close();
     }