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 2015/11/05 22:31:06 UTC

[01/12] incubator-tinkerpop git commit: TINKERPOP3-913 Deprecated rebindings argument in favor of aliases.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP3-923 7e9aef4f5 -> f7b070dec


TINKERPOP3-913 Deprecated rebindings argument in favor of aliases.

Should not be a breaking change as everything was done through deprecation.


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

Branch: refs/heads/TINKERPOP3-923
Commit: 180a6cb22c851273c688ff2d39f1d76ba877c987
Parents: 558c04e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 4 12:42:09 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Nov 4 12:42:09 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/gremlin-applications.asciidoc          | 18 ++---
 .../upgrade-release-3.1.x-incubating.asciidoc   | 14 +++-
 .../apache/tinkerpop/gremlin/driver/Client.java | 71 ++++++++++++++++++--
 .../apache/tinkerpop/gremlin/driver/Tokens.java |  6 ++
 .../handler/HttpGremlinEndpointHandler.java     | 47 ++++++++++---
 .../server/op/standard/StandardOpProcessor.java | 20 ++++--
 .../server/GremlinDriverIntegrateTest.java      | 29 +++++---
 .../server/GremlinServerHttpIntegrateTest.java  | 38 +++++++++--
 .../server/GremlinServerIntegrateTest.java      | 27 +++++++-
 10 files changed, 224 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5ad89e5..a405b58 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,7 @@ TinkerPop 3.1.0 (NOT OFFICIALLY RELEASED YET)
 
 * Integrated `NumberHelper` in `SumStep`, `MinStep`, `MaxStep` and `MeanStep` (local and global step variants).
 * Bumped to Neo4j 2.3.0.
+* Deprecated "rebindings" as an argument to Gremlin Server and replaced it with "aliases".
 * Added `PersistedInputRDD` and `PersistedOutputRDD` which enables `SparkGraphComputer` to store the graph RDD in the context between jobs (no HDFS serialization required).
 * Renamed the `public static String` configuration variable names of TinkerGraph (deprecated old variables).
 * Added `GraphComputer.configure(key,value)` to allow engine-specific configurations.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/docs/src/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/gremlin-applications.asciidoc b/docs/src/gremlin-applications.asciidoc
index 88684ab..8343d7a 100644
--- a/docs/src/gremlin-applications.asciidoc
+++ b/docs/src/gremlin-applications.asciidoc
@@ -491,8 +491,8 @@ In this case, they are streamed from the server as they arrive.
 <5> Parameterized request are considered the most efficient way to send Gremlin to the server as they can be cached,
 which will boost performance and reduce resources required on the server.
 
-Rebinding
-^^^^^^^^^
+Aliases
+^^^^^^^
 
 Scripts submitted to Gremlin Server automatically have the globally configured `Graph` and `TraversalSource` instances
 made available to them.  Therefore, if Gremlin Server configures two `TraversalSource` instances called "g1" and "g2"
@@ -505,15 +505,15 @@ client.submit("g2.V()")
 While this is an acceptable way to submit scripts, it has the downside of forcing the client to encode the server-side
 variable name directly into the script being sent.  If the server configuration ever changed such that "g1" became
 "g100", the client-side code might have to see a significant amount of change.  Decoupling the script code from the
-server configuration can be managed by the `rebind` method on `Client` as follows:
+server configuration can be managed by the `alias` method on `Client` as follows:
 
 [source,java]
-Client g1Client = client.rebind("g1")
-Client g2Client = client.rebind("g2")
+Client g1Client = client.alias("g1")
+Client g2Client = client.alias("g2")
 g1Client.submit("g.V()")
 g2Client.submit("g.V()")
 
-The above code demonstrates how the `rebind` method can be used such that the script need only contain a reference
+The above code demonstrates how the `alias` method can be used such that the script need only contain a reference
 to "g" and "g1" and "g2" are automatically rebound into "g" on the server-side.
 
 Serialization
@@ -1303,11 +1303,11 @@ evaluated and is committed when the script completes (or rolled back if an error
 |gremlin |String | *Required* The Gremlin script to evaluate
 |bindings |Map |A map of key/value pairs to apply as variables in the context of the Gremlin script
 |language |String |The flavor used (e.g. `gremlin-groovy`)
-|rebindings |Map |A map of key/value pairs that allow globally bound `Graph` and `TraversalSource` objects to
-be rebound to different variable names for purposes of the current request.  The value represents the name the
+|aliases |Map |A map of key/value pairs that allow globally bound `Graph` and `TraversalSource` objects to
+be aliased to different variable names for purposes of the current request.  The value represents the name the
 global variable and its key represents the new binding name as it will be referenced in the Gremlin query.  For
 example, if the Gremlin Server defines two `TraversalSource` instances named `g1` and `g2`, it would be possible
-to send a `rebinding` pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
+to send an alias pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
 |=========================================================
 
 Session OpProcessor

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/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 ada54f9..5632468 100644
--- a/docs/src/upgrade-release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade-release-3.1.x-incubating.asciidoc
@@ -85,7 +85,6 @@ TinkerGraph-Gremlin Updates
 
 * The `public static String` configurations have been renamed. The old `public static` variables have been deprecated.
 
-
 Gremlin Process
 ^^^^^^^^^^^^^^^
 
@@ -181,3 +180,16 @@ GraphComputer Updates
 This allows the user to specify engine-specific parameters to the underlying OLAP system. These parameters are not intended
 to be cross engine supported. Moreover, if there are not parameters that can be altered (beyond the standard `GraphComputer`
 methods), then the provider's `GraphComputer` implementation should simply return and do nothing.
+
+Driver Providers
+^^^^^^^^^^^^^^^^
+
+Aliases Parameter
++++++++++++++++++
+
+The "rebindings" argument to the "standard" `OpProcessor` has been renamed to "aliases". While "rebindings" is still
+supported it is recommended that the upgrade to "aliases" be made as soon as possible as support will be removed in
+the future.  Gremlin Server will not accept both parameters at the same time - a request must contain either one
+parameter or the other if either is supplied.
+
+See link:https://issues.apache.org/jira/browse/TINKERPOP3-913[TINKERPOP3-913] for more information.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index b54d6dc..a8fa127 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -84,13 +84,24 @@ public abstract class Client {
     public abstract CompletableFuture<Void> closeAsync();
 
     /**
-     * Create a new {@code Client} that rebinds the specified {@link Graph} or {@link TraversalSource} name on the
+     * Create a new {@code Client} that aliases the specified {@link Graph} or {@link TraversalSource} name on the
      * server to a variable called "g" for the context of the requests made through that {@code Client}.
      *
      * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
+     * @deprecated As of release 3.1.0, replaced by {@link #alias(String)}
      */
+    @Deprecated
     public abstract Client rebind(final String graphOrTraversalSource);
 
+
+    /**
+     * Create a new {@code Client} that aliases the specified {@link Graph} or {@link TraversalSource} name on the
+     * server to a variable called "g" for the context of the requests made through that {@code Client}.
+     *
+     * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
+     */
+    public abstract Client alias(final String graphOrTraversalSource);
+
     /**
      * Initializes the client which typically means that a connection is established to the server.  Depending on the
      * implementation and configuration this blocking call may take some time.  This method will be called
@@ -256,7 +267,7 @@ public abstract class Client {
             Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
 
             if (graphOrTraversalSource != null && !graphOrTraversalSource.isEmpty())
-                request.addArg(Tokens.ARGS_REBINDINGS, makeRebindings(graphOrTraversalSource));
+                request.addArg(Tokens.ARGS_ALIASES, makeRebindings(graphOrTraversalSource));
 
             return submitAsync(buildMessage(request));
         }
@@ -265,17 +276,36 @@ public abstract class Client {
          * {@inheritDoc}
          */
         @Override
+        @Deprecated
         public Client rebind(final String graphOrTraversalSource) {
+            return alias(graphOrTraversalSource);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
             return new ReboundClusteredClient(this, graphOrTraversalSource);
         }
 
         /**
-         * Creates a {@code Client} that supplies the specified set of rebindings, thus allowing the user to re-name
+         * Creates a {@code Client} that supplies the specified set of aliases, thus allowing the user to re-name
          * one or more globally defined {@link Graph} or {@link TraversalSource} server bindings for the context of
          * the created {@code Client}.
          */
+        @Deprecated
         public Client rebind(final Map<String,String> rebindings) {
-            return new ReboundClusteredClient(this, rebindings);
+            return alias(rebindings);
+        }
+
+        /**
+         * Creates a {@code Client} that supplies the specified set of aliases, thus allowing the user to re-name
+         * one or more globally defined {@link Graph} or {@link TraversalSource} server bindings for the context of
+         * the created {@code Client}.
+         */
+        public Client alias(final Map<String,String> aliases) {
+            return new ReboundClusteredClient(this, aliases);
         }
 
         /**
@@ -363,7 +393,7 @@ public abstract class Client {
         public RequestMessage buildMessage(final RequestMessage.Builder builder) {
             if (close.isDone()) throw new IllegalStateException("Client is closed");
             if (!rebindings.isEmpty())
-                builder.addArg(Tokens.ARGS_REBINDINGS, rebindings);
+                builder.addArg(Tokens.ARGS_ALIASES, rebindings);
 
             return builder.create();
         }
@@ -393,8 +423,20 @@ public abstract class Client {
             return close;
         }
 
+        /**
+         * {@inheritDoc}
+         */
         @Override
+        @Deprecated
         public Client rebind(final String graphOrTraversalSource) {
+            return alias(graphOrTraversalSource);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
             if (close.isDone()) throw new IllegalStateException("Client is closed");
             return new ReboundClusteredClient(clusteredClient, graphOrTraversalSource);
         }
@@ -419,9 +461,26 @@ public abstract class Client {
             return sessionId;
         }
 
+        /**
+         * The sessioned client does not support this feature.
+         *
+         * @throws UnsupportedOperationException
+         * @deprecated As of release 3.1.0, replaced by {@link #alias(String)}
+         */
+        @Deprecated
         @Override
         public Client rebind(final String graphOrTraversalSourceName){
-            throw new UnsupportedOperationException("Sessioned client do no support rebinding");
+            throw new UnsupportedOperationException("Sessioned client do no support aliasing");
+        }
+
+        /**
+         * The sessioned client does not support this feature.
+         *
+         * @throws UnsupportedOperationException
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
+            throw new UnsupportedOperationException("Sessioned client do no support aliasing");
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
index 447f42d..64d2fe1 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
@@ -41,11 +41,17 @@ public final class Tokens {
 
     public static final String ARGS_BATCH_SIZE = "batchSize";
     public static final String ARGS_BINDINGS = "bindings";
+    public static final String ARGS_ALIASES = "aliases";
     public static final String ARGS_COORDINATES = "coordinates";
     public static final String ARGS_GREMLIN = "gremlin";
     public static final String ARGS_IMPORTS = "imports";
     public static final String ARGS_INFO_TYPE = "infoType";
     public static final String ARGS_LANGUAGE = "language";
+
+    /**
+     * @deprecated As of release 3.1.0, replaced by {@link #ARGS_ALIASES}.
+     */
+    @Deprecated
     public static final String ARGS_REBINDINGS = "rebindings";
     public static final String ARGS_SESSION = "session";
     public static final String ARGS_SASL = "sasl";

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
index 2852dc9..51fcc26 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
@@ -97,7 +97,13 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
     static final Meter errorMeter = MetricManager.INSTANCE.getMeter(name(GremlinServer.class, "errors"));
 
     private static final String ARGS_BINDINGS_DOT = Tokens.ARGS_BINDINGS + ".";
+
+    /**
+     * @deprecated As of release 3.1.0, replaced by {@link #ARGS_ALIASES_DOT}.
+     */
+    @Deprecated
     private static final String ARGS_REBINDINGS_DOT = Tokens.ARGS_REBINDINGS + ".";
+    private static final String ARGS_ALIASES_DOT = Tokens.ARGS_ALIASES + ".";
 
     private static final Timer evalOpTimer = MetricManager.INSTANCE.getTimer(name(GremlinServer.class, "op", "eval"));
 
@@ -317,6 +323,7 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
         if (request.getMethod() == GET) {
             final QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
             final List<String> gremlinParms = decoder.parameters().get(Tokens.ARGS_GREMLIN);
+
             if (null == gremlinParms || gremlinParms.size() == 0)
                 throw new IllegalArgumentException("no gremlin script supplied");
             final String script = gremlinParms.get(0);
@@ -327,14 +334,23 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
             decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(ARGS_BINDINGS_DOT))
                     .forEach(kv -> bindings.put(kv.getKey().substring(ARGS_BINDINGS_DOT.length()), kv.getValue().get(0)));
 
-            final Map<String, String> rebindings = new HashMap<>();
-            decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(ARGS_REBINDINGS_DOT))
-                    .forEach(kv -> rebindings.put(kv.getKey().substring(ARGS_REBINDINGS_DOT.length()), kv.getValue().get(0)));
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = decoder.parameters().entrySet().stream().anyMatch(kv -> kv.getKey().startsWith(ARGS_REBINDINGS_DOT));
+            final boolean hasAliases = decoder.parameters().entrySet().stream().anyMatch(kv -> kv.getKey().startsWith(ARGS_ALIASES_DOT));
+            if (hasRebindings && hasAliases)
+                throw new IllegalArgumentException("prefer use of the 'aliases' parameter over 'rebindings' and do not use both");
+
+            final Map<String, String> aliases = new HashMap<>();
+            final String rebindingOrAliasParameter = hasRebindings ? ARGS_REBINDINGS_DOT : ARGS_ALIASES_DOT;
+            decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(rebindingOrAliasParameter))
+                    .forEach(kv -> aliases.put(kv.getKey().substring(rebindingOrAliasParameter.length()), kv.getValue().get(0)));
 
             final List<String> languageParms = decoder.parameters().get(Tokens.ARGS_LANGUAGE);
             final String language = (null == languageParms || languageParms.size() == 0) ? null : languageParms.get(0);
 
-            return Quartet.with(script, bindings, language, rebindings);
+            return Quartet.with(script, bindings, language, aliases);
         } else {
             final JsonNode body;
             try {
@@ -354,18 +370,27 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
             if (bindingsNode != null)
                 bindingsNode.fields().forEachRemaining(kv -> bindings.put(kv.getKey(), fromJsonNode(kv.getValue())));
 
-            final JsonNode rebindingsNode = body.get(Tokens.ARGS_REBINDINGS);
-            if (rebindingsNode != null && !rebindingsNode.isObject())
-                throw new IllegalArgumentException("rebindings must be a Map");
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = body.has(Tokens.ARGS_REBINDINGS);
+            final boolean hasAliases = body.has(Tokens.ARGS_ALIASES);
+            if (hasRebindings && hasAliases)
+                throw new IllegalArgumentException("prefer use of the 'aliases' parameter over 'rebindings' and do not use both");
+
+            final String rebindingOrAliasParameter = hasRebindings ? Tokens.ARGS_REBINDINGS : Tokens.ARGS_ALIASES;
+            final JsonNode aliasesNode = body.get(rebindingOrAliasParameter);
+            if (aliasesNode != null && !aliasesNode.isObject())
+                throw new IllegalArgumentException("aliases must be a Map");
 
-            final Map<String, String> rebindings = new HashMap<>();
-            if (rebindingsNode != null)
-                rebindingsNode.fields().forEachRemaining(kv -> rebindings.put(kv.getKey(), kv.getValue().asText()));
+            final Map<String, String> aliases = new HashMap<>();
+            if (aliasesNode != null)
+                aliasesNode.fields().forEachRemaining(kv -> aliases.put(kv.getKey(), kv.getValue().asText()));
 
             final JsonNode languageNode = body.get(Tokens.ARGS_LANGUAGE);
             final String language = null == languageNode ? null : languageNode.asText();
 
-            return Quartet.with(scriptNode.asText(), bindings, language, rebindings);
+            return Quartet.with(scriptNode.asText(), bindings, language, aliases);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
index 017594f..c54cbad 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
@@ -80,9 +80,21 @@ public class StandardOpProcessor extends AbstractEvalOpProcessor {
         super.evalOpInternal(context, context::getGremlinExecutor, () -> {
             final Bindings bindings = new SimpleBindings();
 
-            // rebind any global bindings to a different variable.
-            if (msg.getArgs().containsKey(Tokens.ARGS_REBINDINGS)) {
-                final Map<String, String> rebinds = (Map<String, String>) msg.getArgs().get(Tokens.ARGS_REBINDINGS);
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = msg.getArgs().containsKey(Tokens.ARGS_REBINDINGS);
+            final boolean hasAliases = msg.getArgs().containsKey(Tokens.ARGS_ALIASES);
+            if (hasRebindings && hasAliases) {
+                final String error = "Prefer use of the 'aliases' parameter over 'rebindings' and do not use both";
+                throw new OpProcessorException(error, ResponseMessage.build(msg).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).result(error).create());
+            }
+
+            final String rebindingOrAliasParameter = hasRebindings ? Tokens.ARGS_REBINDINGS : Tokens.ARGS_ALIASES;
+
+            // alias any global bindings to a different variable.
+            if (msg.getArgs().containsKey(rebindingOrAliasParameter)) {
+                final Map<String, String> rebinds = (Map<String, String>) msg.getArgs().get(rebindingOrAliasParameter);
                 for (Map.Entry<String,String> kv : rebinds.entrySet()) {
                     boolean found = false;
                     final Map<String, Graph> graphs = context.getGraphManager().getGraphs();
@@ -100,7 +112,7 @@ public class StandardOpProcessor extends AbstractEvalOpProcessor {
                     }
 
                     if (!found) {
-                        final String error = String.format("Could not rebind [%s] to [%s] as [%s] not in the Graph or TraversalSource global bindings",
+                        final String error = String.format("Could not alias [%s] to [%s] as [%s] not in the Graph or TraversalSource global bindings",
                                 kv.getKey(), kv.getValue(), kv.getValue());
                         throw new OpProcessorException(error, ResponseMessage.build(msg).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).result(error).create());
                     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index cbe23d5..92c9671 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -80,7 +80,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final String nameOfTest = name.getMethodName();
 
         switch (nameOfTest) {
-            case "shouldRebindTraversalSourceVariables":
+            case "shouldAliasTraversalSourceVariables":
                 try {
                     final String p = TestHelper.generateTempFileFromResource(
                             GremlinDriverIntegrateTest.class, "generate-shouldRebindTraversalSourceVariables.groovy", "").getAbsolutePath();
@@ -787,7 +787,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
-    public void shouldRebindGraphVariables() throws Exception {
+    public void shouldAliasGraphVariables() throws Exception {
         final Cluster cluster = Cluster.build().create();
         final Client client = cluster.connect();
 
@@ -801,20 +801,25 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
         }
 
-        final Client rebound = cluster.connect().rebind("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", v.value("name"));
+        // keep the testing here until "rebind" is completely removed
+        final Client reboundLegacy = cluster.connect().rebind("graph");
+        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client rebound = cluster.connect().alias("graph");
+        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
 
         cluster.close();
     }
 
     @Test
-    public void shouldRebindTraversalSourceVariables() throws Exception {
+    public void shouldAliasTraversalSourceVariables() throws Exception {
         final Cluster cluster = Cluster.build().create();
         final Client client = cluster.connect();
 
         try {
-            client.submit("g.addV('name','stephen');").all().get().get(0).getVertex();
+            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
             fail("Should have tossed an exception because \"g\" is readonly in this context");
         } catch (Exception ex) {
             final Throwable root = ExceptionUtils.getRootCause(ex);
@@ -823,8 +828,14 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
         }
 
-        final Vertex v = client.rebind("g1").submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", v.value("name"));
+        // keep the testing here until "rebind" is completely removed
+        final Client clientLegacy = client.rebind("g1");
+        final Vertex vLegacy = clientLegacy.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client clientAliased = client.alias("g1");
+        final Vertex v = clientAliased.submit("g.addV('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
 
         cluster.close();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index a56b9cf..f46f022 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -61,8 +61,8 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
         switch (nameOfTest) {
             case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResult":
             case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResult":
-            case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndRebinding":
-            case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndRebinding":
+            case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases":
+            case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases":
                 settings.scriptEngines.get("gremlin-groovy").scripts = Arrays.asList("scripts/generate-classic.groovy");
                 break;
             case "should200OnPOSTTransactionalGraph":
@@ -253,9 +253,21 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
-    public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndRebinding() throws Exception {
+    public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases() throws Exception {
+        // we can remove this first test when rebindings are completely removed
+        final CloseableHttpClient httpclientLegacy = HttpClients.createDefault();
+        final HttpGet httpgetLegacy = new HttpGet("http://localhost:8182?gremlin=g1.V()&rebindings.g1=g");
+
+        try (final CloseableHttpResponse response = httpclientLegacy.execute(httpgetLegacy)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode node = mapper.readTree(json);
+            assertEquals(6, node.get("result").get("data").size());
+        }
+
         final CloseableHttpClient httpclient = HttpClients.createDefault();
-        final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=g1.V()&rebindings.g1=g");
+        final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=g1.V()&aliases.g1=g");
 
         try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
             assertEquals(200, response.getStatusLine().getStatusCode());
@@ -411,11 +423,25 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
-    public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndRebinding() throws Exception {
+    public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases() throws Exception {
+        // we can remove this first test when rebindings are completely removed
+        final CloseableHttpClient httpclientLegacy = HttpClients.createDefault();
+        final HttpPost httppostLegacy = new HttpPost("http://localhost:8182");
+        httppostLegacy.addHeader("Content-Type", "application/json");
+        httppostLegacy.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"g\"}}", Consts.UTF_8));
+
+        try (final CloseableHttpResponse response = httpclientLegacy.execute(httppostLegacy)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode node = mapper.readTree(json);
+            assertEquals(6, node.get("result").get("data").size());
+        }
+
         final CloseableHttpClient httpclient = HttpClients.createDefault();
         final HttpPost httppost = new HttpPost("http://localhost:8182");
         httppost.addHeader("Content-Type", "application/json");
-        httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"g\"}}", Consts.UTF_8));
+        httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"aliases\":{\"g1\":\"g\"}}", Consts.UTF_8));
 
         try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
             assertEquals(200, response.getStatusLine().getStatusCode());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/180a6cb2/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index 0b4f7cd..6977100 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.server.channel.NioChannelizer;
 import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
 import org.junit.After;
 import org.junit.Before;
@@ -44,6 +45,7 @@ import org.junit.Test;
 import java.nio.channels.ClosedChannelException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
@@ -660,6 +662,29 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         
         assertTrue("Transaction should still be closed", !isStillOpen.get());
     }
- 
+
+    @Test
+    public void shouldStillSupportDeprecatedRebindingsParameterOnServer() throws Exception {
+        // this test can be removed when the rebindings arg is removed
+        try (SimpleClient client = new WebSocketClient()) {
+            final Map<String,String> rebindings = new HashMap<>();
+            rebindings.put("xyz", "graph");
+            final RequestMessage request = RequestMessage.build(Tokens.OPS_EVAL)
+                    .addArg(Tokens.ARGS_GREMLIN, "xyz.addVertex('name','jason')")
+                    .addArg(Tokens.ARGS_REBINDINGS, rebindings).create();
+            final CountDownLatch latch = new CountDownLatch(1);
+            final AtomicBoolean pass = new AtomicBoolean(false);
+            client.submit(request, result -> {
+                final List<Object> results = (List<Object>) result.getResult().getData();
+                final DetachedVertex v = (DetachedVertex) results.get(0);
+                pass.set(ResponseStatusCode.SUCCESS == result.getStatus().getCode() && v.value("name").equals("jason"));
+                latch.countDown();
+            });
+
+            if (!latch.await(300, TimeUnit.MILLISECONDS)) fail("Request should have returned a response");
+
+            assertTrue(pass.get());
+        }
+    }
     
 }


[12/12] incubator-tinkerpop git commit: Added "the next ten minutes" to the tutorial.

Posted by sp...@apache.org.
Added "the next ten minutes" to the tutorial.

Dropped the idea of a "tutorial" book and made the "getting started" standalone as an "article".


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

Branch: refs/heads/TINKERPOP3-923
Commit: f7b070dec1915a8fc9400f34e02369d026e14528
Parents: dde1dca
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 5 16:30:07 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 5 16:30:07 2015 -0500

----------------------------------------------------------------------
 docs/src/tutorials-getting-started.asciidoc     | 284 +++++++++++++++++--
 docs/src/tutorials.asciidoc                     |  27 --
 .../images/modern-edge-1-to-3-1-gremlin.png     | Bin 0 -> 11607 bytes
 .../images/modern-edge-1-to-3-2-gremlin.png     | Bin 0 -> 15248 bytes
 .../images/modern-edge-1-to-3-3-gremlin.png     | Bin 0 -> 18565 bytes
 pom.xml                                         |   7 +-
 6 files changed, 266 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/docs/src/tutorials-getting-started.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/tutorials-getting-started.asciidoc b/docs/src/tutorials-getting-started.asciidoc
index 6cd99a5..b95a59f 100644
--- a/docs/src/tutorials-getting-started.asciidoc
+++ b/docs/src/tutorials-getting-started.asciidoc
@@ -14,22 +14,28 @@ 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.
 ////
+
 Getting Started
 ===============
 
-Apache TinkerPop is an open source Graph Computing Framework.  Within itself, TinkerPop represents a large collection
-of capabilities and technologies and in its wider ecosystem an additionally extended world of
-link:http://tinkerpop.incubator.apache.org/#graph-systems[third-party contributed] graph libraries and systems.
-TinkerPop's ecosystem can appear complex to newcomers of all experience, especially when glancing at the
+link:http://tinkerpop.com[Apache TinkerPop] is an open source Graph Computing Framework.  Within itself, TinkerPop
+represents a large collection of capabilities and technologies and in its wider ecosystem an additionally extended
+world of link:http://tinkerpop.incubator.apache.org/#graph-systems[third-party contributed] graph libraries and
+systems. TinkerPop's ecosystem can appear complex to newcomers of all experience, especially when glancing at the
 link:http://tinkerpop.incubator.apache.org/docs/x.y.z/index.html[reference documentation] for the first time.
 
-So, where do you get started with TinkerPop?
+So, where do you get started with TinkerPop? How do you dive in quickly and get productive?  Well - Gremlin, the
+most recognizable citizen of The TinkerPop, is here to help with this thirty minute tutorial.  That's right - in just
+thirty short minutes, you too can be fit to start building graph applications with TinkerPop.  Welcome to _The Gremlin
+Workout - by Gremlin_!
+
+image::gremlin-gym.png[]
 
-In Five Minutes
----------------
+The First Five Minutes
+----------------------
 
-It is quite possible to learn a lot in just five minutes with TinkerPop, but before doing so, introductions are in
-order.  Meet Gremlin, the most recognizable citizen of The TinkerPop!
+It is quite possible to learn a lot in just five minutes with TinkerPop, but before doing so, a proper introduction of
+your trainer is in order.  Meet Gremlin!
 
 image:gremlin-standing.png[width=125,align=center]
 
@@ -77,7 +83,7 @@ trying out, working with a static graph that doesn't change much, unit tests and
 can fit in memory.
 
 TIP: Resist the temptation to "get started" with more complex databases like link:http://thinkaurelius.github.io/titan/[Titan]
-or worrying how to get link:http://tinkerpop.incubator.apache.org/docs/x.y.zg/#gremlin-server[Gremlin Server]
+or to delve into how to get link:http://tinkerpop.incubator.apache.org/docs/x.y.zg/#gremlin-server[Gremlin Server]
 working properly.  Focusing on the basics builds a good foundation for all the other things TinkerPop offers.
 
 To make your process even easier, start with one of TinkerPop's toy graphs.  These are "small" graphs designed to
@@ -131,34 +137,272 @@ some traversals and hopefully learned something about TinkerPop in general.  You
 what there is to know, but those accomplishments will help enable understanding of the more detailed tutorials to
 come.
 
-In Ten More Minutes
--------------------
+The Next Ten Minutes
+--------------------
 
 In the first five minutes of getting started with TinkerPop, you learned some basics for telling Gremlin how to
 traverse a graph.  Of course, there wasn't much discussion about what a graph is.  A graph is a collection of
-vertices (i.e. nodes, dots, etc.) and edges (i.e. relationships, lines, etc.), where a vertex is an entity which
+vertices (i.e. nodes, dots) and edges (i.e. relationships, lines), where a vertex is an entity which
 represents some domain object (e.g. a person, a place, etc.) and an edge represents the relationship between two
 vertices.
 
-image:modern-edge-1-to-3-1.png[width=300,align=center]
+image:modern-edge-1-to-3-1.png[width=300]
 
 The above example shows a graph with two vertices, one with a unique identifier of "1" and another with a unique
 identifier of "3".  There is a edge connecting the two with a unique identifier of "9". It is important to consider
-that the edge has a direction which goes out from vertex "1" and in to vertex "3'.
+that the edge has a direction which goes _out_ from vertex "1" and _in_ to vertex "3'.
 
-IMPORTANT: Most TinkerPop implementations do not allow for identifier assignment.  They will rather assign identifiers
-and ignore assigned identifiers you attempt to assign to them.
+IMPORTANT: Most TinkerPop implementations do not allow for identifier assignment.  They will rather assign
+their own identifiers and ignore assigned identifiers that you attempt to assign to them.
 
 A graph with elements that just have identifiers does not make for much of a database.  To give some meaning to
 this basic structure, vertices and edges can each be given labels to categorize them.
 
-image:modern-edge-1-to-3-2.png[width=300,align=center]
+image:modern-edge-1-to-3-2.png[width=300]
 
 You can now see that a vertex "1" is a "person" and vertex "3" is a "software" vertex.  They are joined by a "created"
 edge which allows you to see that a "person created software".  The "label" and the "id" are reserved attributes of
 vertices and edges, but you can add your own arbitrary properties as well:
 
-image:modern-edge-1-to-3-3.png[width=300,align=center]
+image:modern-edge-1-to-3-3.png[width=325]
+
+This model is referred to as a _property graph_ and it provides a flexible and intuitive way in which to model your
+data.
+
+Creating a Graph
+^^^^^^^^^^^^^^^^
+
+As intuitive as it is to you, it is perhaps more intuitive to Gremlin himself, as vertices, edges and properties make
+up the very elements of his existence. It is indeed helpful to think of our friend, Gremlin, moving about a graph when
+developing traversals, as picturing his position as the link:http://tinkerpop.incubator.apache.org/docs/3.0.2-incubating/#_the_traverser[traverser]
+helps orient where you need him to go next.  Let's use the two vertex, one edge graph we've been discussing above
+as an example.  First, you need to create this graph:
+
+[gremlin-groovy]
+----
+graph = TinkerGraph.open()
+g = graph.traversal()
+v1 = g.addV(id, 1, label, "person", "name", "marko", "age" 29).next()
+v2 = g.addV(id, 3, label, "software", "name", "lop", "lang", "java").next()
+v1.addEdge("created", v2, id, 9, "weight", 0.4)
+----
+
+There are a number of important things to consider in the above code.  First, why didn't we use `graph.addVertex()`?
+Couldn't that just as easily performed the same function?  Yes - it could have, however, TinkerPop encourages
+end-users to utilizes the methods of the `TraversalSource` rather than `Graph`.  The `Graph` methods are considered
+"low-level" and for use by providers developing TinkerPop implementations.  In addition, using `Graph` methods bypass
+features you may find important as you learn more about TinkerPop, such as
+link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#traversalstrategy[traversal strategies].
+
+Second, recall that `id` and `label` are "reserved" for special usage in TinkerPop.  Those "keys" supplied to the
+creation method are statically imported to the console.  You would normally refer to them as `T.id` and `T.label`.
+
+NOTE: The fully qualified name for `T` is `org.apache.tinkerpop.gremlin.structure.T`.
+
+Third, don't forget that you are working with TinkerGraph and so identifier assignment is allowed.  That is _not_ the
+case with most graph databases (don't bother to try with Neo4j).
+
+Finally, the label for an `Edge` is required and is thus part of the method signature of `addEdge()`.  It is the first
+parameter supplied, followed by `Vertex` to which `v1` should be connected.  Therefore, this usage of `addEdge` is
+creating an edge that goes _out_ of `v1` and into `v2` with a label of "created".
+
+Graph Traversal - Staying Simple
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Now that Gremlin knows where the graph data is, you can ask him to get you some data from it by doing a traversal,
+which you can think of as executing some link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#_the_graph_process[process]
+over the structure of the graph. We can form our question in English and then translate it to Gremlin. For this
+initial example, let's ask Gremlin: "What software has Marko created?"
+
+To answer this question, we would want Gremlin to:
+
+. Find "marko" in the graph
+. Walk along the "created" edges to "software" vertices
+. Select the "name" property of the "software" vertices
+
+The English-based steps above largely translate to Gremlin's position in the graph and to the steps we need to take
+to ask him to answer our question. By stringing these steps together, we form a `Traversal` or the sequence of programmatic
+link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#graph-traversal-steps[steps] Gremlin needs to perform
+in order to get you an answer.
+
+Let's start with finding "marko".  This operation is a filtering step as it searches the full set of vertices to match
+those that have the "name" property value of "marko". This can be done with the
+link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#has-step[has()] step as follows:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko')
+----
+
+We can picture this traversal in our little graph with Gremlin sitting on vertex "1".
+
+image:modern-edge-1-to-3-1-gremlin.png[width=325]
+
+When Gremlin is on a vertex or an edge, he has access to all the properties that are available to that element.
+
+IMPORTANT: The above query iterates all the vertices in the graph to get its answer. That's fine for our little example,
+but for multi-million or billion edge graphs that is a big problem. To solve this problem, you should look to use
+indices.  TinkerPop does not provide an abstraction for index management.  You should consult the documentation of the
+graph you have chosen and utilize its native API to create indices that will speed up these types of lookups. Your
+traversals will remain unchanged however, as the indices will be used transparently at execution time.
+
+Now that Gremlin has found "marko", he can now consider the next step in the traversal where we ask him to "walk"
+along "created" edges to "software" vertices. As described earlier, edges have direction, so we have to tell Gremlin
+what direction to follow.  In this case, we want him to traverse on outgoing edges from the "marko" vertex.  For this,
+we use the link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#vertex-steps[outE] step.
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').outE('created')
+----
+
+At this point, you can picture Gremlin moving from the "marko" vertex to the "created" edge.
+
+image:modern-edge-1-to-3-2-gremlin.png[width=325]
+
+To get to the vertex on the other end of the edge, you need to tell Gremlin to move from the edge to the incoming
+vertex with `inV()`.
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').outE('created').inV()
+----
+
+You can now picture Gremlin on the "software" vertex as follows:
+
+image:modern-edge-1-to-3-3-gremlin.png[width=325]
+
+As you are not asking Gremlin to do anything with the properties of the "created" edge, you can simplify the
+statement above with:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').out('created')
+----
+
+Finally, now that Gremlin has reached the "software that Marko created", he has access to the properties of the
+"software" vertex and you can therefore ask Gremlin to extract the "name" property as follows:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').out('created').values('name')
+----
+
+You should now be able to see the connection Gremlin has to the structure of the graph and how Gremlin maneuvers from
+vertices to edges and so on.  Your ability to string together steps to ask Gremlin to do more complex things, depends
+on your understanding of these basic concepts.
+
+Graph Traversal - Increasing Complexity
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Armed with the knowledge from the previous section, let's ask Gremlin to do some more complex things. There's not much
+more that can be done with the "baby" graph we had, so let's return to the "modern" toy graph from the "five
+minutes section".  Recall that you can create this `Graph` and establish a `TraversalSource` with:
+
+[gremlin-groovy]
+----
+graph = TinkerFactory.createModern()
+g = graph.traversal()
+----
+
+Earlier we'd used the `has()` step to tell Gremlin how to find the "marko" vertex. Let's look at some other ways to
+use `has()`.  What if we wanted Gremlin to find the "age" values of both "vadas" and "marko"?  In this case we could
+use the `within` comparator with `has()` as follows:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name',within('vadas','marko')).values('age')
+----
+
+It is worth noting that `within` is statically imported to the Gremlin Console (much like `T` is, as described
+earlier).
+
+NOTE: The fully qualified name for `P` is `org.apache.tinkerpop.gremlin.process.traversal.P`.
+
+If we wanted to ask Gremlin the average age of "vadas" and "marko" we could use the
+link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#mean-step[mean()] step as follows:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name',within('vadas','marko')).values('age').mean()
+----
+
+Another method of filtering is seen in the use of the link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#where-step[where]
+step.  We know how to find the "software" that "marko" created:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').out('created')
+----
+
+Let's extend on that to try to learn who "marko" collaborates with. To do that, we should first picture Gremlin
+standing on the "software" vertex.  To find out who "created" that "software" we need to have Gremlin traverse back
+_in_ along the "created" edges to find the "person" vertices tied to it.
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').out('created').in('created').values('name')
+----
+
+So that's nice, we can see that "peter", "josh" and "marko" are both responsible for creating "lop".  Of course, we already
+know about the involvement of "marko" and it seems strange to say that "marko" collaborates with himself, so excluding
+"marko" from the results seems logical.  The following traversal handles that exclusion:
+
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').as('exclude').out('created').in('created').where(neq('exclude')).values('name')
+----
+
+We made two additions to the traversal to make it exclude "marko" from the results.  First, we added the
+link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#as-step[as()] step.  The `as()` step is not really a "step",
+but a "step modulator" - something that adds features to a step or the traversal.  Here, the `as('exclude')` labels
+the `has()` step with "exclude" and all values that pass through that step are held in that "label" for later use.  In
+this case, the "marko" vertex is the only vertex to pass through that point, so it is held in "exclude".
+
+The other addition that was made was the `where()` step which is a filter step like `has()`.  The `where()` is
+positioned after the `in()` step that has "person" vertices, which means that the `where()` filter is occurring
+on the list of "marko" collaborators.  The `where()` specifies that the "person" vertices passing through it should
+not equal (i.e. `neq()`) the contents of the "exclude" label.  As it just contains the "marko" vertex, the `where()`
+filters out the "marko" that we get when we traverse back _in_ on the "created" edges.
+
+You will find many uses of `as()`.  Here it is in combination with link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#select-step[select]:
+
+[gremlin-groovy,modern]
+----
+g.V().as('a').out().as('b').out().as('c').select('a','b','c')
+----
+
+In the above example, we tell Gremlin to iterate through all vertices and traverse _out_ twice from each.  Gremlin
+will label each vertex in that path with "a", "b" and "c", respectively.  We can then use `select` to extract the
+contents of that label.
+
+Another common but important step is the link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#group-step[group()]
+step and its related step modulator called link:http://tinkerpop.incubator.apache.org/docs/x.y.z/#by-step[by()]. If
+we wanted to ask Gremlin to group all the vertices in the graph by their vertex label we could do:
+
+[gremlin-groovy,modern]
+----
+g.V().group().by(label)
+----
+
+The use of `by()` here provides the mechanism by which to do the grouping.  In this case, we've asked Gremlin to
+use the `label` (which, again, is an automatic static import from `T` in the console). We can't really tell much
+about our distribution though because we just have vertex unique identifiers as output.  To make that nicer we
+could ask Gremlin to get us the value of the "name" property from those vertices, by supplying another `by()`
+modulator to `group()` to transform the values.
+
+[gremlin-groovy,modern]
+----
+g.V().group().by(label).by('name')
+----
+
+In this section, you have learned a bit more about what property graphs are and how Gremlin interacts with them.
+You also learned how to envision Gremlin moving about a graph and how to use some of the more complex but commonly
+utilized traversal steps. You are now ready to think about TinkerPop in terms of its wider applicability to
+graph computing and application development.
+
+The Final Fifteen Minutes
+-------------------------
+
 
-This model is referred to as a property graph and it provides a flexible and intuitive way in which to model your data.
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/docs/src/tutorials.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/tutorials.asciidoc b/docs/src/tutorials.asciidoc
deleted file mode 100644
index 754b9e9..0000000
--- a/docs/src/tutorials.asciidoc
+++ /dev/null
@@ -1,27 +0,0 @@
-////
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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.
-////
-image::apache-tinkerpop-logo.png[width=500]
-
-:toc-position: left
-
-Tutorials
-=========
-
-Tutorials are a companion set of documentation to TinkerPop's standard link:http://tinkerpop.incubator.apache.org/docs/x.y.z/index.html[reference documentation].
-The tutorials provide more context and example for specific topics in a way that should be more approachable to users.
-
-include::tutorials-getting-started.asciidoc[]

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/docs/static/images/modern-edge-1-to-3-1-gremlin.png
----------------------------------------------------------------------
diff --git a/docs/static/images/modern-edge-1-to-3-1-gremlin.png b/docs/static/images/modern-edge-1-to-3-1-gremlin.png
new file mode 100755
index 0000000..19b4d3f
Binary files /dev/null and b/docs/static/images/modern-edge-1-to-3-1-gremlin.png differ

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/docs/static/images/modern-edge-1-to-3-2-gremlin.png
----------------------------------------------------------------------
diff --git a/docs/static/images/modern-edge-1-to-3-2-gremlin.png b/docs/static/images/modern-edge-1-to-3-2-gremlin.png
new file mode 100755
index 0000000..0df3ef2
Binary files /dev/null and b/docs/static/images/modern-edge-1-to-3-2-gremlin.png differ

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/docs/static/images/modern-edge-1-to-3-3-gremlin.png
----------------------------------------------------------------------
diff --git a/docs/static/images/modern-edge-1-to-3-3-gremlin.png b/docs/static/images/modern-edge-1-to-3-3-gremlin.png
new file mode 100755
index 0000000..4513489
Binary files /dev/null and b/docs/static/images/modern-edge-1-to-3-3-gremlin.png differ

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f7b070de/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 84e0fba..f569cef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -769,16 +769,13 @@ limitations under the License.
                                 </goals>
                                 <configuration>
                                     <sourceDirectory>${asciidoc.input.dir}</sourceDirectory>
-                                    <sourceDocumentName>tutorials.asciidoc</sourceDocumentName>
+                                    <sourceDocumentName>tutorials-getting-started.asciidoc</sourceDocumentName>
                                     <outputDirectory>${htmlsingle.output.dir}</outputDirectory>
                                     <backend>html5</backend>
-                                    <doctype>book</doctype>
+                                    <doctype>article</doctype>
                                     <attributes>
                                         <imagesdir>images</imagesdir>
                                         <encoding>UTF-8</encoding>
-                                        <toc>true</toc>
-                                        <toclevels>3</toclevels>
-                                        <toc-position>left</toc-position>
                                         <!--<iconsdir>images/icons</iconsdir>-->
                                         <!-- AsciiDoctor CSS3-based theme configuration -->
                                         <stylesdir>${asciidoctor.style.dir}</stylesdir>


[02/12] incubator-tinkerpop git commit: TINKERPOP3-913 Deprecated rebindings argument in favor of aliases.

Posted by sp...@apache.org.
TINKERPOP3-913 Deprecated rebindings argument in favor of aliases.

Should not be a breaking change as everything was done through deprecation.


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

Branch: refs/heads/TINKERPOP3-923
Commit: bdf0553420ef830f72e43b42b9c471e62a92dcf1
Parents: ebec095
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 4 12:42:09 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Nov 4 13:10:03 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/gremlin-applications.asciidoc          | 18 ++---
 .../upgrade-release-3.1.x-incubating.asciidoc   | 14 +++-
 .../apache/tinkerpop/gremlin/driver/Client.java | 71 ++++++++++++++++++--
 .../apache/tinkerpop/gremlin/driver/Tokens.java |  6 ++
 .../handler/HttpGremlinEndpointHandler.java     | 47 ++++++++++---
 .../server/op/standard/StandardOpProcessor.java | 20 ++++--
 .../server/GremlinDriverIntegrateTest.java      | 29 +++++---
 .../server/GremlinServerHttpIntegrateTest.java  | 38 +++++++++--
 .../server/GremlinServerIntegrateTest.java      | 27 +++++++-
 10 files changed, 224 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 31671c0..b91ac0c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,6 +29,7 @@ TinkerPop 3.1.0 (NOT OFFICIALLY RELEASED YET)
 * `CountMatchAlgorithm`, in OLAP, now biases traversal selection towards those traversals that start at the current traverser location to reduce message passing.
 * Fixed a file stream bug in Hadoop OLTP that showed up if the streamed file was more than 2G of data.
 * Bumped to Neo4j 2.3.0.
+* Deprecated "rebindings" as an argument to Gremlin Server and replaced it with "aliases".
 * Added `PersistedInputRDD` and `PersistedOutputRDD` which enables `SparkGraphComputer` to store the graph RDD in the context between jobs (no HDFS serialization required).
 * Renamed the `public static String` configuration variable names of TinkerGraph (deprecated old variables).
 * Added `GraphComputer.configure(key,value)` to allow engine-specific configurations.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/docs/src/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/gremlin-applications.asciidoc b/docs/src/gremlin-applications.asciidoc
index 88684ab..8343d7a 100644
--- a/docs/src/gremlin-applications.asciidoc
+++ b/docs/src/gremlin-applications.asciidoc
@@ -491,8 +491,8 @@ In this case, they are streamed from the server as they arrive.
 <5> Parameterized request are considered the most efficient way to send Gremlin to the server as they can be cached,
 which will boost performance and reduce resources required on the server.
 
-Rebinding
-^^^^^^^^^
+Aliases
+^^^^^^^
 
 Scripts submitted to Gremlin Server automatically have the globally configured `Graph` and `TraversalSource` instances
 made available to them.  Therefore, if Gremlin Server configures two `TraversalSource` instances called "g1" and "g2"
@@ -505,15 +505,15 @@ client.submit("g2.V()")
 While this is an acceptable way to submit scripts, it has the downside of forcing the client to encode the server-side
 variable name directly into the script being sent.  If the server configuration ever changed such that "g1" became
 "g100", the client-side code might have to see a significant amount of change.  Decoupling the script code from the
-server configuration can be managed by the `rebind` method on `Client` as follows:
+server configuration can be managed by the `alias` method on `Client` as follows:
 
 [source,java]
-Client g1Client = client.rebind("g1")
-Client g2Client = client.rebind("g2")
+Client g1Client = client.alias("g1")
+Client g2Client = client.alias("g2")
 g1Client.submit("g.V()")
 g2Client.submit("g.V()")
 
-The above code demonstrates how the `rebind` method can be used such that the script need only contain a reference
+The above code demonstrates how the `alias` method can be used such that the script need only contain a reference
 to "g" and "g1" and "g2" are automatically rebound into "g" on the server-side.
 
 Serialization
@@ -1303,11 +1303,11 @@ evaluated and is committed when the script completes (or rolled back if an error
 |gremlin |String | *Required* The Gremlin script to evaluate
 |bindings |Map |A map of key/value pairs to apply as variables in the context of the Gremlin script
 |language |String |The flavor used (e.g. `gremlin-groovy`)
-|rebindings |Map |A map of key/value pairs that allow globally bound `Graph` and `TraversalSource` objects to
-be rebound to different variable names for purposes of the current request.  The value represents the name the
+|aliases |Map |A map of key/value pairs that allow globally bound `Graph` and `TraversalSource` objects to
+be aliased to different variable names for purposes of the current request.  The value represents the name the
 global variable and its key represents the new binding name as it will be referenced in the Gremlin query.  For
 example, if the Gremlin Server defines two `TraversalSource` instances named `g1` and `g2`, it would be possible
-to send a `rebinding` pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
+to send an alias pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
 |=========================================================
 
 Session OpProcessor

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/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 ada54f9..5632468 100644
--- a/docs/src/upgrade-release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade-release-3.1.x-incubating.asciidoc
@@ -85,7 +85,6 @@ TinkerGraph-Gremlin Updates
 
 * The `public static String` configurations have been renamed. The old `public static` variables have been deprecated.
 
-
 Gremlin Process
 ^^^^^^^^^^^^^^^
 
@@ -181,3 +180,16 @@ GraphComputer Updates
 This allows the user to specify engine-specific parameters to the underlying OLAP system. These parameters are not intended
 to be cross engine supported. Moreover, if there are not parameters that can be altered (beyond the standard `GraphComputer`
 methods), then the provider's `GraphComputer` implementation should simply return and do nothing.
+
+Driver Providers
+^^^^^^^^^^^^^^^^
+
+Aliases Parameter
++++++++++++++++++
+
+The "rebindings" argument to the "standard" `OpProcessor` has been renamed to "aliases". While "rebindings" is still
+supported it is recommended that the upgrade to "aliases" be made as soon as possible as support will be removed in
+the future.  Gremlin Server will not accept both parameters at the same time - a request must contain either one
+parameter or the other if either is supplied.
+
+See link:https://issues.apache.org/jira/browse/TINKERPOP3-913[TINKERPOP3-913] for more information.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index b54d6dc..a8fa127 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -84,13 +84,24 @@ public abstract class Client {
     public abstract CompletableFuture<Void> closeAsync();
 
     /**
-     * Create a new {@code Client} that rebinds the specified {@link Graph} or {@link TraversalSource} name on the
+     * Create a new {@code Client} that aliases the specified {@link Graph} or {@link TraversalSource} name on the
      * server to a variable called "g" for the context of the requests made through that {@code Client}.
      *
      * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
+     * @deprecated As of release 3.1.0, replaced by {@link #alias(String)}
      */
+    @Deprecated
     public abstract Client rebind(final String graphOrTraversalSource);
 
+
+    /**
+     * Create a new {@code Client} that aliases the specified {@link Graph} or {@link TraversalSource} name on the
+     * server to a variable called "g" for the context of the requests made through that {@code Client}.
+     *
+     * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
+     */
+    public abstract Client alias(final String graphOrTraversalSource);
+
     /**
      * Initializes the client which typically means that a connection is established to the server.  Depending on the
      * implementation and configuration this blocking call may take some time.  This method will be called
@@ -256,7 +267,7 @@ public abstract class Client {
             Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
 
             if (graphOrTraversalSource != null && !graphOrTraversalSource.isEmpty())
-                request.addArg(Tokens.ARGS_REBINDINGS, makeRebindings(graphOrTraversalSource));
+                request.addArg(Tokens.ARGS_ALIASES, makeRebindings(graphOrTraversalSource));
 
             return submitAsync(buildMessage(request));
         }
@@ -265,17 +276,36 @@ public abstract class Client {
          * {@inheritDoc}
          */
         @Override
+        @Deprecated
         public Client rebind(final String graphOrTraversalSource) {
+            return alias(graphOrTraversalSource);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
             return new ReboundClusteredClient(this, graphOrTraversalSource);
         }
 
         /**
-         * Creates a {@code Client} that supplies the specified set of rebindings, thus allowing the user to re-name
+         * Creates a {@code Client} that supplies the specified set of aliases, thus allowing the user to re-name
          * one or more globally defined {@link Graph} or {@link TraversalSource} server bindings for the context of
          * the created {@code Client}.
          */
+        @Deprecated
         public Client rebind(final Map<String,String> rebindings) {
-            return new ReboundClusteredClient(this, rebindings);
+            return alias(rebindings);
+        }
+
+        /**
+         * Creates a {@code Client} that supplies the specified set of aliases, thus allowing the user to re-name
+         * one or more globally defined {@link Graph} or {@link TraversalSource} server bindings for the context of
+         * the created {@code Client}.
+         */
+        public Client alias(final Map<String,String> aliases) {
+            return new ReboundClusteredClient(this, aliases);
         }
 
         /**
@@ -363,7 +393,7 @@ public abstract class Client {
         public RequestMessage buildMessage(final RequestMessage.Builder builder) {
             if (close.isDone()) throw new IllegalStateException("Client is closed");
             if (!rebindings.isEmpty())
-                builder.addArg(Tokens.ARGS_REBINDINGS, rebindings);
+                builder.addArg(Tokens.ARGS_ALIASES, rebindings);
 
             return builder.create();
         }
@@ -393,8 +423,20 @@ public abstract class Client {
             return close;
         }
 
+        /**
+         * {@inheritDoc}
+         */
         @Override
+        @Deprecated
         public Client rebind(final String graphOrTraversalSource) {
+            return alias(graphOrTraversalSource);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
             if (close.isDone()) throw new IllegalStateException("Client is closed");
             return new ReboundClusteredClient(clusteredClient, graphOrTraversalSource);
         }
@@ -419,9 +461,26 @@ public abstract class Client {
             return sessionId;
         }
 
+        /**
+         * The sessioned client does not support this feature.
+         *
+         * @throws UnsupportedOperationException
+         * @deprecated As of release 3.1.0, replaced by {@link #alias(String)}
+         */
+        @Deprecated
         @Override
         public Client rebind(final String graphOrTraversalSourceName){
-            throw new UnsupportedOperationException("Sessioned client do no support rebinding");
+            throw new UnsupportedOperationException("Sessioned client do no support aliasing");
+        }
+
+        /**
+         * The sessioned client does not support this feature.
+         *
+         * @throws UnsupportedOperationException
+         */
+        @Override
+        public Client alias(String graphOrTraversalSource) {
+            throw new UnsupportedOperationException("Sessioned client do no support aliasing");
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
index 447f42d..64d2fe1 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
@@ -41,11 +41,17 @@ public final class Tokens {
 
     public static final String ARGS_BATCH_SIZE = "batchSize";
     public static final String ARGS_BINDINGS = "bindings";
+    public static final String ARGS_ALIASES = "aliases";
     public static final String ARGS_COORDINATES = "coordinates";
     public static final String ARGS_GREMLIN = "gremlin";
     public static final String ARGS_IMPORTS = "imports";
     public static final String ARGS_INFO_TYPE = "infoType";
     public static final String ARGS_LANGUAGE = "language";
+
+    /**
+     * @deprecated As of release 3.1.0, replaced by {@link #ARGS_ALIASES}.
+     */
+    @Deprecated
     public static final String ARGS_REBINDINGS = "rebindings";
     public static final String ARGS_SESSION = "session";
     public static final String ARGS_SASL = "sasl";

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
index 2852dc9..51fcc26 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
@@ -97,7 +97,13 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
     static final Meter errorMeter = MetricManager.INSTANCE.getMeter(name(GremlinServer.class, "errors"));
 
     private static final String ARGS_BINDINGS_DOT = Tokens.ARGS_BINDINGS + ".";
+
+    /**
+     * @deprecated As of release 3.1.0, replaced by {@link #ARGS_ALIASES_DOT}.
+     */
+    @Deprecated
     private static final String ARGS_REBINDINGS_DOT = Tokens.ARGS_REBINDINGS + ".";
+    private static final String ARGS_ALIASES_DOT = Tokens.ARGS_ALIASES + ".";
 
     private static final Timer evalOpTimer = MetricManager.INSTANCE.getTimer(name(GremlinServer.class, "op", "eval"));
 
@@ -317,6 +323,7 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
         if (request.getMethod() == GET) {
             final QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
             final List<String> gremlinParms = decoder.parameters().get(Tokens.ARGS_GREMLIN);
+
             if (null == gremlinParms || gremlinParms.size() == 0)
                 throw new IllegalArgumentException("no gremlin script supplied");
             final String script = gremlinParms.get(0);
@@ -327,14 +334,23 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
             decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(ARGS_BINDINGS_DOT))
                     .forEach(kv -> bindings.put(kv.getKey().substring(ARGS_BINDINGS_DOT.length()), kv.getValue().get(0)));
 
-            final Map<String, String> rebindings = new HashMap<>();
-            decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(ARGS_REBINDINGS_DOT))
-                    .forEach(kv -> rebindings.put(kv.getKey().substring(ARGS_REBINDINGS_DOT.length()), kv.getValue().get(0)));
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = decoder.parameters().entrySet().stream().anyMatch(kv -> kv.getKey().startsWith(ARGS_REBINDINGS_DOT));
+            final boolean hasAliases = decoder.parameters().entrySet().stream().anyMatch(kv -> kv.getKey().startsWith(ARGS_ALIASES_DOT));
+            if (hasRebindings && hasAliases)
+                throw new IllegalArgumentException("prefer use of the 'aliases' parameter over 'rebindings' and do not use both");
+
+            final Map<String, String> aliases = new HashMap<>();
+            final String rebindingOrAliasParameter = hasRebindings ? ARGS_REBINDINGS_DOT : ARGS_ALIASES_DOT;
+            decoder.parameters().entrySet().stream().filter(kv -> kv.getKey().startsWith(rebindingOrAliasParameter))
+                    .forEach(kv -> aliases.put(kv.getKey().substring(rebindingOrAliasParameter.length()), kv.getValue().get(0)));
 
             final List<String> languageParms = decoder.parameters().get(Tokens.ARGS_LANGUAGE);
             final String language = (null == languageParms || languageParms.size() == 0) ? null : languageParms.get(0);
 
-            return Quartet.with(script, bindings, language, rebindings);
+            return Quartet.with(script, bindings, language, aliases);
         } else {
             final JsonNode body;
             try {
@@ -354,18 +370,27 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
             if (bindingsNode != null)
                 bindingsNode.fields().forEachRemaining(kv -> bindings.put(kv.getKey(), fromJsonNode(kv.getValue())));
 
-            final JsonNode rebindingsNode = body.get(Tokens.ARGS_REBINDINGS);
-            if (rebindingsNode != null && !rebindingsNode.isObject())
-                throw new IllegalArgumentException("rebindings must be a Map");
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = body.has(Tokens.ARGS_REBINDINGS);
+            final boolean hasAliases = body.has(Tokens.ARGS_ALIASES);
+            if (hasRebindings && hasAliases)
+                throw new IllegalArgumentException("prefer use of the 'aliases' parameter over 'rebindings' and do not use both");
+
+            final String rebindingOrAliasParameter = hasRebindings ? Tokens.ARGS_REBINDINGS : Tokens.ARGS_ALIASES;
+            final JsonNode aliasesNode = body.get(rebindingOrAliasParameter);
+            if (aliasesNode != null && !aliasesNode.isObject())
+                throw new IllegalArgumentException("aliases must be a Map");
 
-            final Map<String, String> rebindings = new HashMap<>();
-            if (rebindingsNode != null)
-                rebindingsNode.fields().forEachRemaining(kv -> rebindings.put(kv.getKey(), kv.getValue().asText()));
+            final Map<String, String> aliases = new HashMap<>();
+            if (aliasesNode != null)
+                aliasesNode.fields().forEachRemaining(kv -> aliases.put(kv.getKey(), kv.getValue().asText()));
 
             final JsonNode languageNode = body.get(Tokens.ARGS_LANGUAGE);
             final String language = null == languageNode ? null : languageNode.asText();
 
-            return Quartet.with(scriptNode.asText(), bindings, language, rebindings);
+            return Quartet.with(scriptNode.asText(), bindings, language, aliases);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
index 017594f..c54cbad 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
@@ -80,9 +80,21 @@ public class StandardOpProcessor extends AbstractEvalOpProcessor {
         super.evalOpInternal(context, context::getGremlinExecutor, () -> {
             final Bindings bindings = new SimpleBindings();
 
-            // rebind any global bindings to a different variable.
-            if (msg.getArgs().containsKey(Tokens.ARGS_REBINDINGS)) {
-                final Map<String, String> rebinds = (Map<String, String>) msg.getArgs().get(Tokens.ARGS_REBINDINGS);
+            // don't allow both rebindings and aliases parameters as they are the same thing. aliases were introduced
+            // as of 3.1.0 as a replacement for rebindings. this check can be removed when rebindings are completely
+            // removed from the protocol
+            final boolean hasRebindings = msg.getArgs().containsKey(Tokens.ARGS_REBINDINGS);
+            final boolean hasAliases = msg.getArgs().containsKey(Tokens.ARGS_ALIASES);
+            if (hasRebindings && hasAliases) {
+                final String error = "Prefer use of the 'aliases' parameter over 'rebindings' and do not use both";
+                throw new OpProcessorException(error, ResponseMessage.build(msg).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).result(error).create());
+            }
+
+            final String rebindingOrAliasParameter = hasRebindings ? Tokens.ARGS_REBINDINGS : Tokens.ARGS_ALIASES;
+
+            // alias any global bindings to a different variable.
+            if (msg.getArgs().containsKey(rebindingOrAliasParameter)) {
+                final Map<String, String> rebinds = (Map<String, String>) msg.getArgs().get(rebindingOrAliasParameter);
                 for (Map.Entry<String,String> kv : rebinds.entrySet()) {
                     boolean found = false;
                     final Map<String, Graph> graphs = context.getGraphManager().getGraphs();
@@ -100,7 +112,7 @@ public class StandardOpProcessor extends AbstractEvalOpProcessor {
                     }
 
                     if (!found) {
-                        final String error = String.format("Could not rebind [%s] to [%s] as [%s] not in the Graph or TraversalSource global bindings",
+                        final String error = String.format("Could not alias [%s] to [%s] as [%s] not in the Graph or TraversalSource global bindings",
                                 kv.getKey(), kv.getValue(), kv.getValue());
                         throw new OpProcessorException(error, ResponseMessage.build(msg).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).result(error).create());
                     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index cbe23d5..92c9671 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -80,7 +80,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final String nameOfTest = name.getMethodName();
 
         switch (nameOfTest) {
-            case "shouldRebindTraversalSourceVariables":
+            case "shouldAliasTraversalSourceVariables":
                 try {
                     final String p = TestHelper.generateTempFileFromResource(
                             GremlinDriverIntegrateTest.class, "generate-shouldRebindTraversalSourceVariables.groovy", "").getAbsolutePath();
@@ -787,7 +787,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
-    public void shouldRebindGraphVariables() throws Exception {
+    public void shouldAliasGraphVariables() throws Exception {
         final Cluster cluster = Cluster.build().create();
         final Client client = cluster.connect();
 
@@ -801,20 +801,25 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
         }
 
-        final Client rebound = cluster.connect().rebind("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", v.value("name"));
+        // keep the testing here until "rebind" is completely removed
+        final Client reboundLegacy = cluster.connect().rebind("graph");
+        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client rebound = cluster.connect().alias("graph");
+        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
 
         cluster.close();
     }
 
     @Test
-    public void shouldRebindTraversalSourceVariables() throws Exception {
+    public void shouldAliasTraversalSourceVariables() throws Exception {
         final Cluster cluster = Cluster.build().create();
         final Client client = cluster.connect();
 
         try {
-            client.submit("g.addV('name','stephen');").all().get().get(0).getVertex();
+            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
             fail("Should have tossed an exception because \"g\" is readonly in this context");
         } catch (Exception ex) {
             final Throwable root = ExceptionUtils.getRootCause(ex);
@@ -823,8 +828,14 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
         }
 
-        final Vertex v = client.rebind("g1").submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", v.value("name"));
+        // keep the testing here until "rebind" is completely removed
+        final Client clientLegacy = client.rebind("g1");
+        final Vertex vLegacy = clientLegacy.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client clientAliased = client.alias("g1");
+        final Vertex v = clientAliased.submit("g.addV('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
 
         cluster.close();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index a56b9cf..f46f022 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -61,8 +61,8 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
         switch (nameOfTest) {
             case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResult":
             case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResult":
-            case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndRebinding":
-            case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndRebinding":
+            case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases":
+            case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases":
                 settings.scriptEngines.get("gremlin-groovy").scripts = Arrays.asList("scripts/generate-classic.groovy");
                 break;
             case "should200OnPOSTTransactionalGraph":
@@ -253,9 +253,21 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
-    public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndRebinding() throws Exception {
+    public void should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases() throws Exception {
+        // we can remove this first test when rebindings are completely removed
+        final CloseableHttpClient httpclientLegacy = HttpClients.createDefault();
+        final HttpGet httpgetLegacy = new HttpGet("http://localhost:8182?gremlin=g1.V()&rebindings.g1=g");
+
+        try (final CloseableHttpResponse response = httpclientLegacy.execute(httpgetLegacy)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode node = mapper.readTree(json);
+            assertEquals(6, node.get("result").get("data").size());
+        }
+
         final CloseableHttpClient httpclient = HttpClients.createDefault();
-        final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=g1.V()&rebindings.g1=g");
+        final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=g1.V()&aliases.g1=g");
 
         try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
             assertEquals(200, response.getStatusLine().getStatusCode());
@@ -411,11 +423,25 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
-    public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndRebinding() throws Exception {
+    public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases() throws Exception {
+        // we can remove this first test when rebindings are completely removed
+        final CloseableHttpClient httpclientLegacy = HttpClients.createDefault();
+        final HttpPost httppostLegacy = new HttpPost("http://localhost:8182");
+        httppostLegacy.addHeader("Content-Type", "application/json");
+        httppostLegacy.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"g\"}}", Consts.UTF_8));
+
+        try (final CloseableHttpResponse response = httpclientLegacy.execute(httppostLegacy)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode node = mapper.readTree(json);
+            assertEquals(6, node.get("result").get("data").size());
+        }
+
         final CloseableHttpClient httpclient = HttpClients.createDefault();
         final HttpPost httppost = new HttpPost("http://localhost:8182");
         httppost.addHeader("Content-Type", "application/json");
-        httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"rebindings\":{\"g1\":\"g\"}}", Consts.UTF_8));
+        httppost.setEntity(new StringEntity("{\"gremlin\":\"g1.V()\",\"aliases\":{\"g1\":\"g\"}}", Consts.UTF_8));
 
         try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
             assertEquals(200, response.getStatusLine().getStatusCode());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bdf05534/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index 0b4f7cd..6977100 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.server.channel.NioChannelizer;
 import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
 import org.junit.After;
 import org.junit.Before;
@@ -44,6 +45,7 @@ import org.junit.Test;
 import java.nio.channels.ClosedChannelException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
@@ -660,6 +662,29 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         
         assertTrue("Transaction should still be closed", !isStillOpen.get());
     }
- 
+
+    @Test
+    public void shouldStillSupportDeprecatedRebindingsParameterOnServer() throws Exception {
+        // this test can be removed when the rebindings arg is removed
+        try (SimpleClient client = new WebSocketClient()) {
+            final Map<String,String> rebindings = new HashMap<>();
+            rebindings.put("xyz", "graph");
+            final RequestMessage request = RequestMessage.build(Tokens.OPS_EVAL)
+                    .addArg(Tokens.ARGS_GREMLIN, "xyz.addVertex('name','jason')")
+                    .addArg(Tokens.ARGS_REBINDINGS, rebindings).create();
+            final CountDownLatch latch = new CountDownLatch(1);
+            final AtomicBoolean pass = new AtomicBoolean(false);
+            client.submit(request, result -> {
+                final List<Object> results = (List<Object>) result.getResult().getData();
+                final DetachedVertex v = (DetachedVertex) results.get(0);
+                pass.set(ResponseStatusCode.SUCCESS == result.getStatus().getCode() && v.value("name").equals("jason"));
+                latch.countDown();
+            });
+
+            if (!latch.await(300, TimeUnit.MILLISECONDS)) fail("Request should have returned a response");
+
+            assertTrue(pass.get());
+        }
+    }
     
 }


[03/12] incubator-tinkerpop git commit: Merge branch 'TINKERPOP3-913' of https://git-wip-us.apache.org/repos/asf/incubator-tinkerpop into TINKERPOP3-913

Posted by sp...@apache.org.
Merge branch 'TINKERPOP3-913' of https://git-wip-us.apache.org/repos/asf/incubator-tinkerpop into TINKERPOP3-913


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

Branch: refs/heads/TINKERPOP3-923
Commit: 986bc7017bb12a7f609afece4f36f10881f10fd3
Parents: bdf0553 180a6cb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 4 13:12:43 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Nov 4 13:12:43 2015 -0500

----------------------------------------------------------------------

----------------------------------------------------------------------



[05/12] incubator-tinkerpop git commit: added Gremlin Gym to the images. @spmallette -- please feel free to connect to the 5, 15, 30 minute tutorial.

Posted by sp...@apache.org.
added Gremlin Gym to the images. @spmallette -- please feel free to connect to the 5, 15, 30 minute tutorial.


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

Branch: refs/heads/TINKERPOP3-923
Commit: 407103d34f62a29fc0a7ffcd98b3f7e839003fa1
Parents: 4cb087d
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Nov 4 17:55:58 2015 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Nov 4 17:56:12 2015 -0700

----------------------------------------------------------------------
 docs/static/images/gremlin-gym.png | Bin 0 -> 273111 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/407103d3/docs/static/images/gremlin-gym.png
----------------------------------------------------------------------
diff --git a/docs/static/images/gremlin-gym.png b/docs/static/images/gremlin-gym.png
new file mode 100644
index 0000000..6214b10
Binary files /dev/null and b/docs/static/images/gremlin-gym.png differ


[10/12] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP3-913'

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP3-913'


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

Branch: refs/heads/TINKERPOP3-923
Commit: c2c58a749de0383b4695559e2b77cd11300b07d3
Parents: e30b70e 986bc70
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 5 12:03:28 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 5 12:03:28 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/gremlin-applications.asciidoc          | 18 ++---
 .../upgrade-release-3.1.x-incubating.asciidoc   | 14 +++-
 .../apache/tinkerpop/gremlin/driver/Client.java | 71 ++++++++++++++++++--
 .../apache/tinkerpop/gremlin/driver/Tokens.java |  6 ++
 .../handler/HttpGremlinEndpointHandler.java     | 47 ++++++++++---
 .../server/op/standard/StandardOpProcessor.java | 20 ++++--
 .../server/GremlinDriverIntegrateTest.java      | 29 +++++---
 .../server/GremlinServerHttpIntegrateTest.java  | 38 +++++++++--
 .../server/GremlinServerIntegrateTest.java      | 27 +++++++-
 10 files changed, 224 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c2c58a74/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 9f0e18e,b91ac0c..010142e
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -29,8 -28,8 +29,9 @@@ TinkerPop 3.1.0 (NOT OFFICIALLY RELEASE
  * Integrated `NumberHelper` in `SumStep`, `MinStep`, `MaxStep` and `MeanStep` (local and global step variants).
  * `CountMatchAlgorithm`, in OLAP, now biases traversal selection towards those traversals that start at the current traverser location to reduce message passing.
  * Fixed a file stream bug in Hadoop OLTP that showed up if the streamed file was more than 2G of data.
 +* Added the ability to set thread local properties in `SparkGraphComputer` when using a persistent context.
  * Bumped to Neo4j 2.3.0.
+ * Deprecated "rebindings" as an argument to Gremlin Server and replaced it with "aliases".
  * Added `PersistedInputRDD` and `PersistedOutputRDD` which enables `SparkGraphComputer` to store the graph RDD in the context between jobs (no HDFS serialization required).
  * Renamed the `public static String` configuration variable names of TinkerGraph (deprecated old variables).
  * Added `GraphComputer.configure(key,value)` to allow engine-specific configurations.


[07/12] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/master'

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/TINKERPOP3-923
Commit: db11a1e7334be8283ca37eda78f6a75adc38b9c5
Parents: ebfd5bd 407103d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 4 20:58:05 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Nov 4 20:58:05 2015 -0500

----------------------------------------------------------------------
 docs/static/images/gremlin-gym.png | Bin 0 -> 273111 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------



[06/12] incubator-tinkerpop git commit: TINKERPOP3-931 modified the scopes of OpProcessor

Posted by sp...@apache.org.
TINKERPOP3-931 modified the scopes of OpProcessor

increases scope of various OpProcessor implementation to make them more extensible. Added javadoc.


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

Branch: refs/heads/TINKERPOP3-923
Commit: ebfd5bdbcf4b16569778493644ad29ca9b12c623
Parents: 4cb087d
Author: Nghia Tran <ng...@gmail.com>
Authored: Wed Nov 4 17:50:40 2015 -0800
Committer: Nghia Tran <ng...@gmail.com>
Committed: Wed Nov 4 17:50:40 2015 -0800

----------------------------------------------------------------------
 .../gremlin/server/op/AbstractEvalOpProcessor.java          | 2 +-
 .../gremlin/server/op/session/SessionOpProcessor.java       | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ebfd5bdb/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
index cd502e3..9c5c9c9 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
@@ -59,7 +59,7 @@ import static com.codahale.metrics.MetricRegistry.name;
  */
 public abstract class AbstractEvalOpProcessor implements OpProcessor {
     private static final Logger logger = LoggerFactory.getLogger(AbstractEvalOpProcessor.class);
-    private static final Timer evalOpTimer = MetricManager.INSTANCE.getTimer(name(GremlinServer.class, "op", "eval"));
+    public static final Timer evalOpTimer = MetricManager.INSTANCE.getTimer(name(GremlinServer.class, "op", "eval"));
 
     /**
      * This may or may not be the full set of invalid binding keys.  It is dependent on the static imports made to

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ebfd5bdb/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
index 8a31fe9..8441464 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
@@ -56,7 +56,7 @@ public class SessionOpProcessor extends AbstractEvalOpProcessor {
     /**
      * Script engines are evaluated in a per session context where imports/scripts are isolated per session.
      */
-    private static ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
+    protected static ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
 
     static {
         MetricManager.INSTANCE.getGuage(sessions::size, name(GremlinServer.class, "sessions"));
@@ -159,8 +159,11 @@ public class SessionOpProcessor extends AbstractEvalOpProcessor {
         });
     }
 
-
-    private static Session getSession(final Context context, final RequestMessage msg) {
+    /**
+     * Examines the {@link RequestMessage} and extracts the session token. The session is then either found or a new
+     * one is created.
+     */
+    protected static Session getSession(final Context context, final RequestMessage msg) {
         final String sessionId = (String) msg.getArgs().get(Tokens.ARGS_SESSION);
 
         logger.debug("In-session request {} for eval for session {} in thread {}",


[08/12] incubator-tinkerpop git commit: Make test execution order-independent to stabilize builds. Invoking CTR.

Posted by sp...@apache.org.
Make test execution order-independent to stabilize builds. Invoking CTR.

Added @Ignore on one test, which is waiting on a Groovy release containing fix
for GROOVY-7649.


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

Branch: refs/heads/TINKERPOP3-923
Commit: 71e72db4b018cdb61b5675a656f2bd1996efc986
Parents: db11a1e
Author: Jason Plurad <pl...@apache.org>
Authored: Thu Nov 5 00:48:11 2015 -0500
Committer: Jason Plurad <pl...@apache.org>
Committed: Thu Nov 5 00:51:40 2015 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/71e72db4/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
index 95e4c9c..7b1ddc1 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
@@ -23,6 +23,7 @@ import java.io.File;
 import org.apache.commons.io.FileUtils;
 import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact;
 import org.junit.AfterClass;
+import org.junit.Ignore;
 import org.junit.Test;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -41,7 +42,7 @@ public class DependencyGrabberTest {
     }
 
     @Test
-    public void should0_InstallAndUninstallDependencies() {
+    public void shouldInstallAndUninstallDependencies() {
         final String pkg = "org.apache.tinkerpop";
         final String name = "tinkergraph-gremlin";
         final String ver = "3.0.1-incubating";
@@ -58,7 +59,7 @@ public class DependencyGrabberTest {
     }
 
     @Test(expected=IllegalStateException.class)
-    public void should1_ThrowIllegalStateException() {
+    public void shouldThrowIllegalStateException() {
         final String pkg = "org.apache.tinkerpop";
         final String name = "gremlin-groovy";
         final String ver = "3.0.1-incubating";
@@ -81,7 +82,8 @@ public class DependencyGrabberTest {
     }
 
     @Test(expected=RuntimeException.class)
-    public void should2_ThrowRuntimeException() {
+    @Ignore
+    public void shouldThrowRuntimeException() {
         final String pkg = "org.apache.tinkerpop";
         final String name = "gremlin-bogus";
         final String ver = "3.0.1-incubating";


[09/12] incubator-tinkerpop git commit: added Gremlin Gym vectorized image. CTR.

Posted by sp...@apache.org.
added Gremlin Gym vectorized image. CTR.


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

Branch: refs/heads/TINKERPOP3-923
Commit: e30b70e1a23013425369e431533907125b47a906
Parents: 71e72db
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Nov 5 07:08:13 2015 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Nov 5 07:08:28 2015 -0700

----------------------------------------------------------------------
 docs/static/images/gremlin-gym.pdf | Bin 0 -> 963978 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e30b70e1/docs/static/images/gremlin-gym.pdf
----------------------------------------------------------------------
diff --git a/docs/static/images/gremlin-gym.pdf b/docs/static/images/gremlin-gym.pdf
new file mode 100644
index 0000000..d7af4fa
Binary files /dev/null and b/docs/static/images/gremlin-gym.pdf differ


[11/12] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/master' into TINKERPOP3-923

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/master' into TINKERPOP3-923


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

Branch: refs/heads/TINKERPOP3-923
Commit: dde1dca256d2c1e7b8909be019599a44bd06ae39
Parents: 7e9aef4 c2c58a7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 5 12:13:42 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 5 12:13:42 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 docs/src/gremlin-applications.asciidoc          |  18 ++---
 .../upgrade-release-3.1.x-incubating.asciidoc   |  14 +++-
 docs/static/images/gremlin-gym.pdf              | Bin 0 -> 963978 bytes
 docs/static/images/gremlin-gym.png              | Bin 0 -> 273111 bytes
 .../apache/tinkerpop/gremlin/driver/Client.java |  71 +++++++++++++++++--
 .../apache/tinkerpop/gremlin/driver/Tokens.java |   6 ++
 .../groovy/util/DependencyGrabberTest.java      |   8 ++-
 .../handler/HttpGremlinEndpointHandler.java     |  47 +++++++++---
 .../server/op/AbstractEvalOpProcessor.java      |   2 +-
 .../server/op/session/SessionOpProcessor.java   |   9 ++-
 .../server/op/standard/StandardOpProcessor.java |  20 ++++--
 .../server/GremlinDriverIntegrateTest.java      |  29 +++++---
 .../server/GremlinServerAuthIntegrateTest.java  |  35 +++++++++
 .../server/GremlinServerHttpIntegrateTest.java  |  38 ++++++++--
 .../server/GremlinServerIntegrateTest.java      |  27 ++++++-
 16 files changed, 271 insertions(+), 54 deletions(-)
----------------------------------------------------------------------



[04/12] incubator-tinkerpop git commit: added two tests to cover some driver failure situations. The issue at hand is related to a combination of gremlin-server secure configuration and session requests with variables.

Posted by sp...@apache.org.
added two tests to cover some driver failure situations. The issue at hand is related to a combination of gremlin-server secure configuration and session requests with variables.


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

Branch: refs/heads/TINKERPOP3-923
Commit: 4cb087d039990f643494146e48ab95264cc99805
Parents: 151f64b
Author: Dylan Millikin <dm...@apache.org>
Authored: Wed Nov 4 22:12:37 2015 +0100
Committer: Dylan Millikin <dm...@apache.org>
Committed: Wed Nov 4 22:12:37 2015 +0100

----------------------------------------------------------------------
 .../server/GremlinServerAuthIntegrateTest.java  | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4cb087d0/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
index 2cfa2fe..c4743dd 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
@@ -28,6 +28,7 @@ import org.ietf.jgss.GSSException;
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeoutException;
 
@@ -196,4 +197,38 @@ public class GremlinServerAuthIntegrateTest extends AbstractGremlinServerIntegra
             cluster.close();
         }
     }
+    
+    @Test
+    public void shouldAuthenticateAndWorkWithVariablesOverJsonSerialization() throws Exception {
+        final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON).credentials("stephen", "password").create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        try {
+            Map vertex = (Map) client.submit("v=graph.addVertex(\"name\", \"stephen\")").all().get().get(0).getObject();
+            Map<String, List<Map>> properties = (Map) vertex.get("properties");
+            assertEquals("stephen", properties.get("name").get(0).get("value"));
+            
+            final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
+            assertEquals("stephen", vpName.get("value"));
+        } finally {
+            cluster.close();
+        }
+    }
+    
+    @Test
+    public void shouldAuthenticateAndWorkWithVariablesOverGraphSONSerialization() throws Exception {
+        final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON_V1D0).credentials("stephen", "password").create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        try {
+            Map vertex = (Map) client.submit("v=graph.addVertex('name', 'stephen')").all().get().get(0).getObject();
+            Map<String, List<Map>> properties = (Map) vertex.get("properties");
+            assertEquals("stephen", properties.get("name").get(0).get("value"));
+            
+            final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
+            assertEquals("stephen", vpName.get("value"));
+        } finally {
+            cluster.close();
+        }
+    }
 }