You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/12/16 15:55:02 UTC

[01/50] tinkerpop git commit: TINKERPOP-1562 Abstracted groovysh/io to GremlinShellEnvironment [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1490 2cb737ef8 -> 79dac23b2 (forced update)


TINKERPOP-1562 Abstracted groovysh/io to GremlinShellEnvironment

The GremlinShellEnvironment provides a way to abstract groovysh and io classes (i.e. groovy specific classes) so that plugins don't need to depend on gremlin-groovy at all.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 2efa2e4b75ea8032355677165097b492f2979aa8
Parents: 35c8fcd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 23 17:10:13 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../console/jsr223/GephiRemoteAcceptor.groovy   | 15 ++++----
 .../console/plugin/GephiRemoteAcceptor.groovy   |  2 ++
 .../gremlin/console/plugin/PluggedIn.groovy     | 26 +++++++++++++-
 .../console/jsr223/DriverGremlinPlugin.java     |  8 ++---
 .../console/jsr223/DriverRemoteAcceptor.java    | 16 ++++-----
 .../console/jsr223/GephiGremlinPlugin.java      | 10 ++----
 .../jsr223/console/ConsoleCustomizer.java       |  7 +---
 .../jsr223/console/GremlinShellEnvironment.java | 37 ++++++++++++++++++++
 .../hadoop/jsr223/HadoopGremlinPlugin.java      |  7 ++--
 .../hadoop/jsr223/HadoopRemoteAcceptor.java     | 22 ++++++------
 10 files changed, 99 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
index dbc1156..4e41fa4 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
@@ -29,14 +29,13 @@ import org.apache.http.impl.client.CloseableHttpClient
 import org.apache.http.impl.client.HttpClients
 import org.apache.http.util.EntityUtils
 import org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 import org.apache.tinkerpop.gremlin.structure.Edge
 import org.apache.tinkerpop.gremlin.structure.Graph
 import org.apache.tinkerpop.gremlin.structure.Vertex
-import org.codehaus.groovy.tools.shell.Groovysh
-import org.codehaus.groovy.tools.shell.IO
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -48,8 +47,7 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
     private int port = 8080
     private String workspace = "workspace1"
 
-    private final Groovysh shell
-    private final IO io
+    private final GremlinShellEnvironment shell
 
     private final Random rand = new Random();
     boolean traversalSubmittedForViz = false
@@ -64,9 +62,8 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
 
     private CloseableHttpClient httpclient = HttpClients.createDefault();
 
-    public GephiRemoteAcceptor(final Groovysh shell, final IO io) {
+    public GephiRemoteAcceptor(final GremlinShellEnvironment shell) {
         this.shell = shell
-        this.io = io
 
         // traversal visualization defaults
         vizStepDelay = 1000;                 // 1 second pause between viz of steps
@@ -129,13 +126,13 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
         else if (args[0] == "startSize")
             parseVizStartSize(args[1])
         else if (args[0] == "visualTraversal") {
-            def graphVar = shell.interp.context.getVariable(args[1])
+            def graphVar = shell.getVariable(args[1])
             if (!(graphVar instanceof Graph))
                 throw new RemoteException("Invalid argument to 'visualTraversal' - first parameter must be a Graph instance")
 
             def gVar = args.size() == 3 ? args[2] : "vg"
             def theG = GraphTraversalSource.build().with(new GephiTraversalVisualizationStrategy(this)).create(graphVar)
-            shell.interp.context.setVariable(gVar, theG)
+            shell.setVariable(gVar, theG)
         } else
             throw new RemoteException("Invalid config arguments - check syntax")
 
@@ -151,7 +148,7 @@ class GephiRemoteAcceptor implements RemoteAcceptor {
         final String line = String.join(" ", args)
         if (line.trim() == "clear") {
             clearGraph()
-            io.out.println("Gephi workspace cleared")
+            shell.println("Gephi workspace cleared")
             return
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
index 4198444..902a479 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
@@ -40,7 +40,9 @@ import org.codehaus.groovy.tools.shell.IO
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  * @author Randall Barnhart (randompi@gmail.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.GephiRemoteAcceptor}
  */
+@Deprecated
 class GephiRemoteAcceptor implements RemoteAcceptor {
 
     private String host = "localhost"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
index 7a08a9d..364e6ef 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment
 import org.codehaus.groovy.tools.shell.Groovysh
 import org.codehaus.groovy.tools.shell.IO
 
@@ -111,7 +112,30 @@ class PluggedIn {
                 return Optional.empty()
 
             ConsoleCustomizer customizer = (ConsoleCustomizer) corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof ConsoleCustomizer }
-            return Optional.of(new RemoteAcceptorAdapter(customizer.getRemoteAcceptor([(ConsoleCustomizer.ENV_CONSOLE_SHELL): shell, (ConsoleCustomizer.ENV_CONSOLE_IO): io])))
+            return Optional.of(new RemoteAcceptorAdapter(customizer.getRemoteAcceptor(new GroovyGremlinShellEnvironment())))
+        }
+
+        public class GroovyGremlinShellEnvironment implements GremlinShellEnvironment {
+
+            @Override
+            def <T> T getVariable(final String variableName) {
+                return (T) shell.interp.context.getVariable(variableName)
+            }
+
+            @Override
+            def <T> void setVariable(final String variableName, final T variableValue) {
+                shell.interp.context.setVariable(variableName, variableValue)
+            }
+
+            @Override
+            void println(final String line) {
+                io.println(line)
+            }
+
+            @Override
+            def <T> T execute(final String line) {
+                return (T) shell.execute(line)
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
index 89cec10..fb78ee9 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
@@ -51,9 +51,7 @@ import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
-import org.codehaus.groovy.tools.shell.Groovysh;
-
-import java.util.Map;
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -99,8 +97,8 @@ public class DriverGremlinPlugin extends AbstractGremlinPlugin {
 
     private static class DriverConsoleCustomizer implements ConsoleCustomizer {
         @Override
-        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
-            return new DriverRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL));
+        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment environment) {
+            return new DriverRemoteAcceptor(environment);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
index 93ac184..aa02606 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
@@ -25,10 +25,10 @@ import org.apache.tinkerpop.gremlin.driver.Result;
 import org.apache.tinkerpop.gremlin.driver.ResultSet;
 import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment;
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.codehaus.groovy.tools.shell.Groovysh;
 
 import javax.security.sasl.SaslException;
 import java.io.FileNotFoundException;
@@ -75,10 +75,10 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
     private static final String TOKEN_SESSION_MANAGED = "session-managed";
     private static final List<String> POSSIBLE_TOKENS = Arrays.asList(TOKEN_TIMEOUT, TOKEN_ALIAS);
 
-    private final Groovysh shell;
+    private final GremlinShellEnvironment shellEnvironment;
 
-    public DriverRemoteAcceptor(final Groovysh shell) {
-        this.shell = shell;
+    public DriverRemoteAcceptor(final GremlinShellEnvironment shellEnvironment) {
+        this.shellEnvironment = shellEnvironment;
     }
 
     @Override
@@ -152,11 +152,11 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
 
     @Override
     public Object submit(final List<String> args) throws RemoteException {
-        final String line = getScript(String.join(" ", args), this.shell);
+        final String line = getScript(String.join(" ", args), this.shellEnvironment);
 
         try {
             final List<Result> resultSet = send(line);
-            this.shell.getInterp().getContext().setProperty(RESULT, resultSet);
+            this.shellEnvironment.setVariable(RESULT, resultSet);
             return resultSet.stream().map(result -> result.getObject()).iterator();
         } catch (SaslException sasl) {
             throw new RemoteException("Security error - check username/password and related settings", sasl);
@@ -232,7 +232,7 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
     /**
      * Retrieve a script as defined in the shell context.  This allows for multi-line scripts to be submitted.
      */
-    public static String getScript(final String submittedScript, final Groovysh shell) {
-        return submittedScript.startsWith("@") ? shell.getInterp().getContext().getProperty(submittedScript.substring(1)).toString() : submittedScript;
+    public static String getScript(final String submittedScript, final GremlinShellEnvironment shellEnvironment) {
+        return submittedScript.startsWith("@") ? shellEnvironment.getVariable(submittedScript.substring(1)).toString() : submittedScript;
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
index 7698112..c30f864 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
@@ -20,10 +20,7 @@ package org.apache.tinkerpop.gremlin.console.jsr223;
 
 import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
-import org.codehaus.groovy.tools.shell.Groovysh;
-import org.codehaus.groovy.tools.shell.IO;
-
-import java.util.Map;
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -37,9 +34,8 @@ public class GephiGremlinPlugin extends AbstractGremlinPlugin {
 
     private static class GephiConsoleCustomizer implements ConsoleCustomizer {
         @Override
-        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
-            return new GephiRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL),
-                    (IO) environment.get(ConsoleCustomizer.ENV_CONSOLE_IO));
+        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment gremlinShellEnvironment) {
+            return new GephiRemoteAcceptor(gremlinShellEnvironment);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
index 7b3d788..9204488 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
@@ -20,19 +20,14 @@ package org.apache.tinkerpop.gremlin.jsr223.console;
 
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 
-import java.util.Map;
-
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface ConsoleCustomizer extends Customizer {
-    public static final String ENV_CONSOLE_IO = "ConsolePluginAcceptor.io";
-    public static final String ENV_CONSOLE_SHELL = "ConsolePluginAcceptor.shell";
-
     /**
      * Allows a plugin to utilize features of the {@code :remote} and {@code :submit} commands of the Gremlin Console.
      * This method does not need to be implemented if the plugin is not meant for the Console for some reason or
      * if it does not intend to take advantage of those commands.
      */
-    public RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment);
+    public RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment environment);
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/GremlinShellEnvironment.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/GremlinShellEnvironment.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/GremlinShellEnvironment.java
new file mode 100644
index 0000000..6fc1363
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/GremlinShellEnvironment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223.console;
+
+/**
+ * Provides an abstraction over a "Gremlin Shell" (i.e. the core of a console), enabling the plugin to not have to
+ * be hardcoded specifically to any particular shell, like the Gremlin Groovy Console, and thus allowing it to
+ * not have to depend on the gremlin-groovy module itself.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface GremlinShellEnvironment {
+
+    public <T> T getVariable(final String variableName);
+
+    public <T> void setVariable(final String variableName, final T variableValue);
+
+    public void println(final String line);
+
+    public <T> T execute(final String line);
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
index 5e21027..b7403b6 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
@@ -53,14 +53,13 @@ import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.LazyBindingsCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment;
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
-import org.codehaus.groovy.tools.shell.Groovysh;
 
 import javax.script.Bindings;
 import javax.script.SimpleBindings;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 
@@ -147,8 +146,8 @@ public final class HadoopGremlinPlugin extends AbstractGremlinPlugin {
 
     private static class HadoopConsoleCustomizer implements ConsoleCustomizer {
         @Override
-        public RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
-            return new HadoopRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL));
+        public RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment environment) {
+            return new HadoopRemoteAcceptor(environment);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2efa2e4b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
index f2367bd..1fcdab1 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.hadoop.jsr223;
 
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
 import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph;
+import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment;
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
 import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException;
 import org.apache.tinkerpop.gremlin.process.computer.ComputerResult;
@@ -30,7 +31,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
-import org.codehaus.groovy.tools.shell.Groovysh;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -47,12 +47,12 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
     private static final String SPACE = " ";
 
     private HadoopGraph hadoopGraph;
-    private Groovysh shell;
+    private GremlinShellEnvironment shellEnvironment;
     private boolean useSugar = false;
     private TraversalSource traversalSource;
 
-    public HadoopRemoteAcceptor(final Groovysh shell) {
-        this.shell = shell;
+    public HadoopRemoteAcceptor(final GremlinShellEnvironment shellEnvironment) {
+        this.shellEnvironment = shellEnvironment;
     }
 
     @Override
@@ -60,9 +60,9 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
         if (args.size() != 1 && args.size() != 2) {
             throw new IllegalArgumentException("Usage: :remote connect " + HadoopGremlinPlugin.NAME + " <variable name of graph> <optional variable name of traversal source>");
         }
-        this.hadoopGraph = (HadoopGraph) this.shell.getInterp().getContext().getVariable(args.get(0));
+        this.hadoopGraph = this.shellEnvironment.getVariable(args.get(0));
         if (args.size() == 2)
-            this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(1)));
+            this.traversalSource = this.shellEnvironment.getVariable(args.get(1));
         else
             this.traversalSource = this.hadoopGraph.traversal();
         ///
@@ -78,7 +78,7 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
             if (args.get(i).equals(USE_SUGAR))
                 this.useSugar = Boolean.valueOf(args.get(i + 1));
             else if (args.get(i).equals(USE_TRAVERSAL_SOURCE)) {
-                this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(i + 1)));
+                this.traversalSource = this.shellEnvironment.getVariable(args.get(i + 1));
             } else
                 throw new IllegalArgumentException("The provided configuration is unknown: " + args.get(i) + ":" + args.get(i + 1));
         }
@@ -92,12 +92,12 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
     @Override
     public Object submit(final List<String> args) throws RemoteException {
         try {
-            String script = getScript(String.join(SPACE, args), this.shell);
+            String script = getScript(String.join(SPACE, args), this.shellEnvironment);
             if (this.useSugar)
                 script = SugarLoader.class.getCanonicalName() + ".load()\n" + script;
             final TraversalVertexProgram program = TraversalVertexProgram.build().traversal(this.traversalSource, "gremlin-groovy", script).create(this.hadoopGraph);
             final ComputerResult computerResult = VertexProgramStrategy.getComputer(this.traversalSource.getStrategies()).get().apply(this.hadoopGraph).program(program).submit().get();
-            this.shell.getInterp().getContext().setVariable(RESULT, computerResult);
+            this.shellEnvironment.setVariable(RESULT, computerResult);
             ///
             final Traversal.Admin<ComputerResult, ?> traversal = new DefaultTraversal<>(computerResult.graph());
             traversal.addStep(new ComputerResultStep<>(traversal));
@@ -121,7 +121,7 @@ public final class HadoopRemoteAcceptor implements RemoteAcceptor {
     /**
      * Retrieve a script as defined in the shell context.  This allows for multi-line scripts to be submitted.
      */
-    public static String getScript(final String submittedScript, final Groovysh shell) {
-        return submittedScript.startsWith("@") ? shell.getInterp().getContext().getProperty(submittedScript.substring(1)).toString() : submittedScript;
+    public static String getScript(final String submittedScript, final GremlinShellEnvironment shell) {
+        return submittedScript.startsWith("@") ? shell.getVariable(submittedScript.substring(1)).toString() : submittedScript;
     }
 }


[06/50] tinkerpop git commit: TINKERPOP-1562 Added more tests for plugins/customizers

Posted by sp...@apache.org.
TINKERPOP-1562 Added more tests for plugins/customizers


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

Branch: refs/heads/TINKERPOP-1490
Commit: 33460fc159249a503a3ffa9439d0d8c3c72ef0cf
Parents: 03e931d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 23 14:37:26 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../CachedGremlinScriptEngineManager.java       |  1 +
 .../gremlin/jsr223/DefaultImportCustomizer.java |  2 -
 .../gremlin/jsr223/LazyBindingsCustomizer.java  |  2 -
 .../SingleGremlinScriptEngineManager.java       |  2 +-
 .../jsr223/DefaultImportCustomizerTest.java     | 76 ++++++++++++++++++++
 .../jsr223/DefaultScriptCustomizerTest.java     | 56 +++++++++++++++
 .../jsr223/ScriptFileGremlinPluginTest.java     | 61 ++++++++++++++++
 .../jsr223/SingleScriptEngineManagerTest.java   | 45 ++++++++++++
 .../gremlin/jsr223/script-customizer-1.groovy   |  3 +
 .../gremlin/jsr223/script-customizer-2.groovy   |  2 +
 pom.xml                                         |  3 +-
 11 files changed, 247 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CachedGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CachedGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CachedGremlinScriptEngineManager.java
index 9839b1b..5798e1c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CachedGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CachedGremlinScriptEngineManager.java
@@ -92,6 +92,7 @@ public class CachedGremlinScriptEngineManager extends DefaultGremlinScriptEngine
     }
 
     private void registerLookUpInfo(final GremlinScriptEngine engine, final String shortName) {
+        if (null == engine) throw new IllegalArgumentException(String.format("%s is not an available GremlinScriptEngine", shortName));
         cache.putIfAbsent(shortName, engine);
         engine.getFactory().getExtensions().forEach(ext -> extensionToName.putIfAbsent(ext, shortName));
         engine.getFactory().getMimeTypes().forEach(mime -> mimeToName.putIfAbsent(mime, shortName));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
index fa0965d..3642f97 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.CoreImports;
-
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
index 4117ae5..01ae662 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
-
 import javax.script.Bindings;
 import java.util.function.Supplier;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
index 9474368..f9022dc 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
@@ -23,7 +23,7 @@ package org.apache.tinkerpop.gremlin.jsr223;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class SingleGremlinScriptEngineManager {
+public final class SingleGremlinScriptEngineManager {
     private static final GremlinScriptEngineManager cached = new CachedGremlinScriptEngineManager();
 
     private SingleGremlinScriptEngineManager() {}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizerTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizerTest.java
new file mode 100644
index 0000000..c010aa5
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizerTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.time.DayOfWeek;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsCollectionContaining.hasItems;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DefaultImportCustomizerTest {
+    @Test
+    public void shouldReturnAssignedImports() throws Exception {
+        final Method abs = Math.class.getMethod("abs", double.class);
+        final Enum dayOfWeekEnum = DayOfWeek.SATURDAY;
+        final Enum tEnum = T.id;
+        final ImportCustomizer imports = DefaultImportCustomizer.build()
+                .addClassImports(java.awt.Color.class, java.awt.AlphaComposite.class)
+                .addMethodImports(abs)
+                .addEnumImports(dayOfWeekEnum, tEnum).create();
+
+        assertEquals(2, imports.getClassImports().size());
+        assertThat(imports.getClassImports(), hasItems(java.awt.Color.class, java.awt.AlphaComposite.class));
+
+        assertEquals(1, imports.getMethodImports().size());
+        assertThat(imports.getMethodImports(), hasItems(abs));
+
+        assertEquals(2, imports.getEnumImports().size());
+        assertThat(imports.getEnumImports(), hasItems(dayOfWeekEnum, tEnum));
+    }
+
+    @Test
+    public void shouldReturnAssignedImportsWhenBuiltViaCollections() throws Exception {
+        final Method abs = Math.class.getMethod("abs", double.class);
+        final Enum dayOfWeekEnum = DayOfWeek.SATURDAY;
+        final Enum tEnum = T.id;
+        final ImportCustomizer imports = DefaultImportCustomizer.build()
+                .addClassImports(Arrays.asList(java.awt.Color.class, java.awt.AlphaComposite.class))
+                .addMethodImports(Collections.singletonList(abs))
+                .addEnumImports(Arrays.asList(dayOfWeekEnum, tEnum)).create();
+
+        assertEquals(2, imports.getClassImports().size());
+        assertThat(imports.getClassImports(), hasItems(java.awt.Color.class, java.awt.AlphaComposite.class));
+
+        assertEquals(1, imports.getMethodImports().size());
+        assertThat(imports.getMethodImports(), hasItems(abs));
+
+        assertEquals(2, imports.getEnumImports().size());
+        assertThat(imports.getEnumImports(), hasItems(dayOfWeekEnum, tEnum));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
new file mode 100644
index 0000000..3e4da13
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DefaultScriptCustomizerTest {
+
+    @Test
+    public void shouldOpenViaPropertiesFileConfig() throws IOException {
+        final File scriptFile1 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-1.groovy", ".groovy");
+        final File scriptFile2 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-2.groovy", ".groovy");
+        final Set<File> files = new HashSet<>();
+        files.add(scriptFile1);
+        files.add(scriptFile2);
+        final ScriptCustomizer scripts = new DefaultScriptCustomizer(files);
+
+        final Collection<List<String>> linesInFiles = scripts.getScripts();
+        final String scriptCombined = linesInFiles.stream().flatMap(Collection::stream).map(s -> s + System.lineSeparator()).reduce("", String::concat);
+        assertEquals("x = 1 + 1" +  System.lineSeparator() +
+                     "y = 10 * x" +   System.lineSeparator() +
+                     "z = 1 + x + y" +  System.lineSeparator() +
+                     "l = g.V(z).out()" +  System.lineSeparator() +
+                     "        .group().by('name')" + System.lineSeparator(), scriptCombined);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
new file mode 100644
index 0000000..81cf9e6
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ScriptFileGremlinPluginTest {
+    @Test
+    public void shouldOpenViaPropertiesFileConfig() throws IOException {
+        final File scriptFile1 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-1.groovy", ".groovy");
+        final File scriptFile2 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-2.groovy", ".groovy");
+        final Set<String> files = new HashSet<>();
+        files.add(scriptFile1.getAbsolutePath());
+        files.add(scriptFile2.getAbsolutePath());
+        final GremlinPlugin plugin = ScriptFileGremlinPlugin.build().files(files).create();
+
+        assertThat(plugin.getCustomizers().isPresent(), is(true));
+        assertThat(plugin.getCustomizers().get()[0], instanceOf(ScriptCustomizer.class));
+        final ScriptCustomizer customizer = (ScriptCustomizer) plugin.getCustomizers().get()[0];
+        final Collection<List<String>> linesInFiles = customizer.getScripts();
+        final String scriptCombined = linesInFiles.stream().flatMap(Collection::stream).map(s -> s + System.lineSeparator()).reduce("", String::concat);
+        assertEquals("x = 1 + 1" +  System.lineSeparator() +
+                "y = 10 * x" +   System.lineSeparator() +
+                "z = 1 + x + y" +  System.lineSeparator() +
+                "l = g.V(z).out()" +  System.lineSeparator() +
+                "        .group().by('name')" + System.lineSeparator(), scriptCombined);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/SingleScriptEngineManagerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/SingleScriptEngineManagerTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/SingleScriptEngineManagerTest.java
new file mode 100644
index 0000000..6765c94
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/SingleScriptEngineManagerTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class SingleScriptEngineManagerTest {
+    private static final GremlinScriptEngineManager mgr = SingleGremlinScriptEngineManager.instance();
+
+    @Test
+    public void shouldGetSameInstance() {
+        assertSame(mgr, SingleGremlinScriptEngineManager.instance());
+        assertSame(mgr, SingleGremlinScriptEngineManager.instance());
+        assertSame(mgr, SingleGremlinScriptEngineManager.instance());
+        assertSame(mgr, SingleGremlinScriptEngineManager.instance());
+        assertSame(mgr, SingleGremlinScriptEngineManager.instance());
+        assertSame(mgr, SingleGremlinScriptEngineManager.getInstance());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shouldNotGetGremlinScriptEngineAsItIsNotRegistered() {
+        mgr.getEngineByName("gremlin-groovy");
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-1.groovy
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-1.groovy b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-1.groovy
new file mode 100644
index 0000000..c2cc784
--- /dev/null
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-1.groovy
@@ -0,0 +1,3 @@
+x = 1 + 1
+y = 10 * x
+z = 1 + x + y
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-2.groovy
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-2.groovy b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-2.groovy
new file mode 100644
index 0000000..1a4f9a9
--- /dev/null
+++ b/gremlin-core/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-2.groovy
@@ -0,0 +1,2 @@
+l = g.V(z).out()
+        .group().by('name')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/33460fc1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e4d1ba7..0bff1e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -285,9 +285,10 @@ limitations under the License.
                         <exclude>**/*.xml</exclude>
                         <exclude>**/*.ldjson</exclude>
                         <exclude>**/goal.txt</exclude>
-                        <exclude>**/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/*.txt</exclude>
                         <exclude>**/src/main/resources/META-INF/services/**</exclude>
                         <exclude>**/src/test/resources/META-INF/services/**</exclude>
+                        <exclude>**/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-*.groovy</exclude>
+                        <exclude>**/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/*.txt</exclude>
                         <exclude>**/src/main/ext/**</exclude>
                         <exclude>**/src/main/static/**</exclude>
                         <exclude>**/_bsp/**</exclude>


[34/50] tinkerpop git commit: Update CHANGELOG - CTR

Posted by sp...@apache.org.
Update CHANGELOG - CTR


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

Branch: refs/heads/TINKERPOP-1490
Commit: b88b00cdef12b031957eccb40e42b54c3696a1f4
Parents: 25f8298
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 9 07:22:44 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 9 07:23:48 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b88b00cd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index c7841a4..a8bf5c5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -52,6 +52,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Added `choose(predicate,traversal)` and `choose(traversal,traversal)` to effect if/then-semantics (no else). Equivalent to `choose(x,y,identity())`.
 * Removed `ImmutablePath.TailPath` as it is no longer required with new recursion model.
 * Removed call stack recursion in `ImmutablePath`.
+* Gremlin-Python serializes `Bytecode` as an object (instead of a JSON string) when submit over the `RemoteConnection`.
 * Fixed the handling of the `DriverRemoteConnection` pass-through configurations to the driver.
 * `IncidentToAdjacentStrategy` now uses a hidden label marker model to avoid repeated recursion for invalidating steps.
 * `PathProcessorStrategy` can inline certain `where(traversal)`-steps in order to increase the likelihood of star-local children.


[33/50] tinkerpop git commit: Merge branch 'pr-513' into tp32

Posted by sp...@apache.org.
Merge branch 'pr-513' into tp32


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

Branch: refs/heads/TINKERPOP-1490
Commit: 25f829858cc23100f0ff0aec18ce3c700e68c1f3
Parents: 966df98 0b74ea4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 9 07:15:28 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 9 07:15:28 2016 -0500

----------------------------------------------------------------------
 .../main/jython/gremlin_python/driver/driver_remote_connection.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[22/50] tinkerpop git commit: TINKERPOP-1562 Adapted CompilerCustomizerProvider to Customizer

Posted by sp...@apache.org.
TINKERPOP-1562 Adapted CompilerCustomizerProvider to Customizer

This hooks up all the groovy-specific configurations to the GremlinGroovyScriptEngine.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 8dc9b1fbb3e0a6504b3d5d217dbb144031b30aab
Parents: 6439d70
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 16:15:12 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../jsr223/CustomizerProviderCustomizer.java    |  40 ++++++
 .../jsr223/GremlinGroovyScriptEngine.java       |  20 ++-
 .../jsr223/GroovyCompilerGremlinPlugin.java     | 138 +++++++++++++++++++
 .../groovy/jsr223/SugarGremlinPlugin.java       |   8 +-
 .../CompileStaticCustomizerProvider.java        |   1 +
 .../ConfigurationCustomizerProvider.java        |   1 +
 .../InterpreterModeCustomizerProvider.java      |   1 +
 .../ThreadInterruptCustomizerProvider.java      |   1 +
 .../TimedInterruptCustomizerProvider.java       |   1 +
 .../TypeCheckedCustomizerProvider.java          |   1 +
 ...mlinGroovyScriptEngineCompileStaticTest.java |  72 +++++++++-
 .../GremlinGroovyScriptEngineConfigTest.java    |  14 +-
 .../jsr223/GremlinGroovyScriptEngineTest.java   |  50 ++++++-
 ...inGroovyScriptEngineThreadInterruptTest.java |  23 +++-
 ...linGroovyScriptEngineTimedInterruptTest.java |  69 +++++++++-
 ...remlinGroovyScriptEngineTypeCheckedTest.java |  72 +++++++++-
 .../jsr223/GroovyCompilerGremlinPluginTest.java | 128 +++++++++++++++++
 17 files changed, 617 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
new file mode 100644
index 0000000..73614a1
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+
+/**
+ * An adapter that allows existing {@link CompilerCustomizerProvider} instances to behave as a {#link Customizer}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class CustomizerProviderCustomizer implements Customizer {
+
+    private final CompilerCustomizerProvider customizerProvider;
+
+    CustomizerProviderCustomizer(final CompilerCustomizerProvider customizerProvider) {
+        this.customizerProvider = customizerProvider;
+    }
+
+    CompilerCustomizerProvider getCustomizerProvider() {
+        return customizerProvider;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index 264587a..2996792 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -70,7 +70,6 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -233,16 +232,31 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
             importCustomizerProvider = new EmptyImportCustomizerProvider(imports, staticImports);
         }
 
-        interpreterModeEnabled = false;
+        // this is a bit temporary - until CompilerCustomizerProvider is gone
+        final List<CompilerCustomizerProvider> customizerProviderCustomizer = listOfCustomizers.stream()
+                .filter(p -> p instanceof CustomizerProviderCustomizer)
+                .map(p -> ((CustomizerProviderCustomizer) p).getCustomizerProvider())
+                .collect(Collectors.toList());
 
-        customizerProviders = Collections.emptyList();
+        // determine if interpreter mode should be enabled
+        interpreterModeEnabled = customizerProviderCustomizer.stream()
+                .anyMatch(p -> p.getClass().equals(InterpreterModeCustomizerProvider.class));
+
+        // remove used providers as the rest will be applied directly
+        customizerProviders = customizerProviderCustomizer.stream()
+                .filter(p -> p != null &&
+                        !((p instanceof ImportCustomizerProvider)))
+                .collect(Collectors.toList());
 
         createClassLoader();
     }
 
     /**
      * Creates a new instance with the specified {@link CompilerCustomizerProvider} objects.
+     *
+     * @deprecated As of release 3.2.4, replaced by {@link #GremlinGroovyScriptEngine(Customizer...)}.
      */
+    @Deprecated
     public GremlinGroovyScriptEngine(final CompilerCustomizerProvider... compilerCustomizerProviders) {
         final List<CompilerCustomizerProvider> providers = Arrays.asList(compilerCustomizerProviders);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
new file mode 100644
index 0000000..0d2e9c6
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A {@link GremlinPlugin} that provides access to low-level configuration options of the {@code GroovyScriptEngine}
+ * itself.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GroovyCompilerGremlinPlugin extends AbstractGremlinPlugin {
+
+    public enum Compilation {
+        COMPILE_STATIC,
+        TYPE_CHECKED,
+        NONE
+    }
+
+    private static final String NAME = "tinkerpop.groovy";
+
+    private GroovyCompilerGremlinPlugin(final Builder builder) {
+        super(NAME, new HashSet<>(Collections.singletonList("gremlin-groovy")), builder.asCustomizers());
+    }
+
+    public static Builder build() {
+        return new Builder();
+    }
+
+    public static final class Builder {
+
+        private boolean interpreterMode;
+        private boolean threadInterrupt;
+        private long timeInMillis = 0;
+        private Compilation compilation = Compilation.NONE;
+        private String extensions = null;
+
+        private Map<String,Object> keyValues = Collections.emptyMap();
+
+        public Builder enableInterpreterMode(final boolean interpreterMode) {
+            this.interpreterMode = interpreterMode;
+            return this;
+        }
+
+        public Builder compilerConfigurationOptions(final Map<String,Object> keyValues) {
+            this.keyValues = keyValues;
+            return this;
+        }
+
+        public Builder enableThreadInterrupt(final boolean threadInterrupt) {
+            this.threadInterrupt = threadInterrupt;
+            return this;
+        }
+
+        public Builder timedInterrupt(final long timeInMillis) {
+            this.timeInMillis = timeInMillis;
+            return this;
+        }
+
+        public Builder compilation(final Compilation compilation) {
+            this.compilation = compilation;
+            return this;
+        }
+
+        public Builder compilation(final String compilation) {
+            return compilation(Compilation.valueOf(compilation));
+        }
+
+        public Builder extensions(final String extensions) {
+            this.extensions = extensions;
+            return this;
+        }
+
+        Customizer[] asCustomizers() {
+            final List<Customizer> list = new ArrayList<>();
+
+            if (interpreterMode)
+                list.add(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+
+            if (!keyValues.isEmpty())
+                list.add(new CustomizerProviderCustomizer(new ConfigurationCustomizerProvider(keyValues)));
+
+            if (threadInterrupt)
+                list.add(new CustomizerProviderCustomizer(new ThreadInterruptCustomizerProvider()));
+
+            if (timeInMillis > 0)
+                list.add(new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(timeInMillis)));
+
+            if (compilation == Compilation.COMPILE_STATIC)
+                list.add(new CustomizerProviderCustomizer(new CompileStaticCustomizerProvider(extensions)));
+            else if (compilation == Compilation.TYPE_CHECKED)
+                list.add(new CustomizerProviderCustomizer(new TypeCheckedCustomizerProvider(extensions)));
+            else if (compilation != Compilation.NONE)
+                throw new IllegalStateException("Use of unknown compilation type: " + compilation);
+
+            if (list.isEmpty()) throw new IllegalStateException("No customizer options have been selected for this plugin");
+
+            final Customizer[] customizers = new Customizer[list.size()];
+            list.toArray(customizers);
+            return customizers;
+        }
+
+        public GroovyCompilerGremlinPlugin create() {
+            return new GroovyCompilerGremlinPlugin(this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
index 95c610f..82fbc8e 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.DefaultScriptCustomizer;
 
 import java.util.Collections;
+import java.util.HashSet;
 
 /**
  * A plugin implementation which allows for the usage of Gremlin Groovy's syntactic sugar.
@@ -34,12 +35,7 @@ public class SugarGremlinPlugin extends AbstractGremlinPlugin {
     private static final String NAME = "tinkerpop.sugar";
 
     public SugarGremlinPlugin() {
-        super(NAME, new DefaultScriptCustomizer(Collections.singletonList(
+        super(NAME, new HashSet<>(Collections.singletonList("gremlin-groovy")), new DefaultScriptCustomizer(Collections.singletonList(
                 Collections.singletonList(SugarLoader.class.getPackage().getName() + "." + SugarLoader.class.getSimpleName() + ".load()"))));
     }
-
-    @Override
-    public String getName() {
-        return "tinkerpop.sugar";
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
index 65e1224..ab0bff5 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import groovy.transform.CompileStatic;
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
index ba9855c..78357cb 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
index e3f95f4..013ba8b 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.ast.InterpreterMode;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
index 8c942c6..e46e9b7 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import groovy.transform.ThreadInterrupt;
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
index e4bdc62..9913088 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import groovy.transform.TimedInterrupt;
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.codehaus.groovy.ast.tools.GeneralUtils;
 import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
index f0bc791..cf9147b 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer;
 
 import groovy.transform.TypeChecked;
 import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
 import org.codehaus.groovy.control.customizers.CompilationCustomizer;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
index 3ba3e0b..b62f3f3 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
@@ -35,7 +35,7 @@ import static org.junit.Assert.fail;
  */
 public class GremlinGroovyScriptEngineCompileStaticTest {
     @Test
-    public void shouldCompileStatic() throws Exception {
+    public void shouldCompileStaticDeprecated() throws Exception {
         // with no type checking this should pass
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
             assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
@@ -53,7 +53,25 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
     }
 
     @Test
-    public void shouldCompileStaticWithExtension() throws Exception {
+    public void shouldCompileStatic() throws Exception {
+        // with no type checking this should pass
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
+            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
+        }
+
+        final CompileStaticCustomizerProvider provider = new CompileStaticCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(provider))) {
+            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            final Throwable root = ExceptionUtils.getRootCause(se);
+            assertEquals(MultipleCompilationErrorsException.class, root.getClass());
+            assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists."));
+        }
+    }
+
+    @Test
+    public void shouldCompileStaticWithExtensionDeprecated() throws Exception {
         // with no type checking extension this should pass
         final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
@@ -72,7 +90,26 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
     }
 
     @Test
-    public void shouldCompileStaticWithMultipleExtension() throws Exception {
+    public void shouldCompileStaticWithExtension() throws Exception {
+        // with no type checking extension this should pass
+        final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+            assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
+        }
+
+        final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
+                PrecompiledExtensions.PreventColorUsageExtension.class.getName());
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+    }
+
+    @Test
+    public void shouldCompileStaticWithMultipleExtensionDeprecated() throws Exception {
         // with no type checking extension this should pass
         final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
@@ -99,4 +136,33 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
             assertThat(se.getMessage(), containsString("Method call is not allowed!"));
         }
     }
+
+    @Test
+    public void shouldCompileStaticWithMultipleExtension() throws Exception {
+        // with no type checking extension this should pass
+        final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+            assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
+            assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"));
+        }
+
+        final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
+                PrecompiledExtensions.PreventColorUsageExtension.class.getName() +
+                        "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName());
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
+            scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
index d354ffa..6b18ece 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
@@ -31,9 +31,19 @@ import static org.junit.Assert.assertEquals;
  */
 public class GremlinGroovyScriptEngineConfigTest {
     @Test
-    public void shouldAddBaseScriptClass() throws Exception {
+    public void shouldAddBaseScriptClassDeprecated() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new ConfigurationCustomizerProvider("ScriptBaseClass", BaseScriptForTesting.class.getName()), new DefaultImportCustomizerProvider());
+                new ConfigurationCustomizerProvider("ScriptBaseClass", BaseScriptForTesting.class.getName()),
+                new DefaultImportCustomizerProvider());
+
+        assertEquals("hello, stephen", engine.eval("hello('stephen')"));
+    }
+
+    @Test
+    public void shouldAddBaseScriptClass() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(
+                new ConfigurationCustomizerProvider("ScriptBaseClass", BaseScriptForTesting.class.getName())),
+                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
 
         assertEquals("hello, stephen", engine.eval("hello('stephen')"));
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index b18c020..65dc56e 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -99,7 +99,7 @@ public class GremlinGroovyScriptEngineTest {
     }
 
     @Test
-    public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception {
+    public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindingsDeprecated() throws Exception {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider());
         engine.eval("def addItUp = { x, y -> x + y }");
         assertEquals(3, engine.eval("int xxx = 1 + 2"));
@@ -121,7 +121,29 @@ public class GremlinGroovyScriptEngineTest {
     }
 
     @Test
-    public void shouldPromoteDefinedVarsInInterpreterModeWithBindings() throws Exception {
+    public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception {
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+        engine.eval("def addItUp = { x, y -> x + y }");
+        assertEquals(3, engine.eval("int xxx = 1 + 2"));
+        assertEquals(4, engine.eval("yyy = xxx + 1"));
+        assertEquals(7, engine.eval("def zzz = yyy + xxx"));
+        assertEquals(4, engine.eval("zzz - xxx"));
+        assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer"));
+        assertEquals("accessible-globally", engine.eval("outer"));
+
+        try {
+            engine.eval("inner");
+            fail("Should not have been able to access 'inner'");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(MissingPropertyException.class));
+        }
+
+        assertEquals(10, engine.eval("addItUp(zzz,xxx)"));
+    }
+
+    @Test
+    public void shouldPromoteDefinedVarsInInterpreterModeWithBindingsDeprecated() throws Exception {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider());
         final Bindings b = new SimpleBindings();
         b.put("x", 2);
@@ -145,6 +167,30 @@ public class GremlinGroovyScriptEngineTest {
     }
 
     @Test
+    public void shouldPromoteDefinedVarsInInterpreterModeWithBindings() throws Exception {
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+        final Bindings b = new SimpleBindings();
+        b.put("x", 2);
+        engine.eval("def addItUp = { x, y -> x + y }", b);
+        assertEquals(3, engine.eval("int xxx = 1 + x", b));
+        assertEquals(4, engine.eval("yyy = xxx + 1", b));
+        assertEquals(7, engine.eval("def zzz = yyy + xxx", b));
+        assertEquals(4, engine.eval("zzz - xxx", b));
+        assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer", b));
+        assertEquals("accessible-globally", engine.eval("outer", b));
+
+        try {
+            engine.eval("inner", b);
+            fail("Should not have been able to access 'inner'");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(MissingPropertyException.class));
+        }
+
+        assertEquals(10, engine.eval("addItUp(zzz,xxx)", b));
+    }
+
+    @Test
     public void shouldEvalWithBindings() throws Exception {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
         final Bindings b = new SimpleBindings();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
index c002939..ea778c6 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
  */
 public class GremlinGroovyScriptEngineThreadInterruptTest {
     @Test
-    public void shouldInterruptWhile() throws Exception {
+    public void shouldInterruptWhileDeprecated() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(new ThreadInterruptCustomizerProvider());
         final AtomicBoolean asserted = new AtomicBoolean(false);
 
@@ -54,6 +54,27 @@ public class GremlinGroovyScriptEngineThreadInterruptTest {
     }
 
     @Test
+    public void shouldInterruptWhile() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new ThreadInterruptCustomizerProvider()));
+        final AtomicBoolean asserted = new AtomicBoolean(false);
+
+        final Thread t = new Thread(() -> {
+            try {
+                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
+            } catch (ScriptException se) {
+                asserted.set(se.getCause().getCause() instanceof InterruptedException);
+            }
+        });
+
+        t.start();
+        Thread.sleep(100);
+        t.interrupt();
+        while(t.isAlive()) {}
+
+        assertTrue(asserted.get());
+    }
+
+    @Test
     public void shouldNotInterruptWhile() throws Exception {
         // companion to shouldInterruptWhile                                 t
         final ScriptEngine engine = new GremlinGroovyScriptEngine();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
index c465732..fa8d4ef 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
@@ -36,21 +36,51 @@ import static org.junit.Assert.fail;
 public class GremlinGroovyScriptEngineTimedInterruptTest {
 
     @Test
+    public void shouldTimeoutScriptOnTimedWhileDeprecated() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(
+                new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider());
+        try {
+            engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
+            fail("This should have timed out");
+        } catch (ScriptException se) {
+            assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+        }
+    }
+
+    @Test
     public void shouldTimeoutScriptOnTimedWhile() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
+                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
+                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        try {
+            engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
+            fail("This should have timed out");
+        } catch (ScriptException se) {
+            assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+        }
+    }
+
+    @Test
+    public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTimeoutDeprecated() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(
                 new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider());
+        Thread.sleep(2000);
         try {
             engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
             fail("This should have timed out");
         } catch (ScriptException se) {
             assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
         }
+
+        assertEquals(2, engine.eval("1+1"));
     }
 
+
     @Test
     public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTimeout() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider());
+                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
+                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
         Thread.sleep(2000);
         try {
             engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
@@ -63,7 +93,7 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
     }
 
     @Test
-    public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception {
+    public void shouldContinueToEvalScriptsEvenWithTimedInterruptDeprecated() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
                 new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider());
 
@@ -84,7 +114,29 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
     }
 
     @Test
-    public void shouldNotTimeoutStandaloneFunction() throws Exception {
+    public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception {
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(
+                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
+                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+
+        for (int ix = 0; ix < 5; ix++) {
+            try {
+                // this script takes 1000 ms longer than the interruptionTimeout
+                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {}");
+                fail("This should have timed out");
+            } catch (ScriptException se) {
+                assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+            }
+
+            // this script takes 500 ms less than the interruptionTimeout
+            assertEquals("test", engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 500) {};'test'"));
+        }
+
+        assertEquals(2, engine.eval("1+1"));
+    }
+
+    @Test
+    public void shouldNotTimeoutStandaloneFunctionDeprecated() throws Exception {
         // use a super fast timeout which should not prevent the call of a cached function
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
                 new TimedInterruptCustomizerProvider(1), new DefaultImportCustomizerProvider());
@@ -92,4 +144,15 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
 
         assertEquals(3, engine.eval("addItUp(1,2)"));
     }
+
+    @Test
+    public void shouldNotTimeoutStandaloneFunction() throws Exception {
+        // use a super fast timeout which should not prevent the call of a cached function
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(
+                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1)),
+                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        engine.eval("def addItUp(x,y) { x + y }");
+
+        assertEquals(3, engine.eval("addItUp(1,2)"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
index a9062a8..0ca12d7 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
@@ -36,7 +36,7 @@ import static org.junit.Assert.fail;
  */
 public class GremlinGroovyScriptEngineTypeCheckedTest {
     @Test
-    public void shouldTypeCheck() throws Exception {
+    public void shouldTypeCheckDeprecated() throws Exception {
         // with no type checking this should pass
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
             assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
@@ -54,7 +54,25 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
     }
 
     @Test
-    public void shouldTypeCheckWithExtension() throws Exception {
+    public void shouldTypeCheck() throws Exception {
+        // with no type checking this should pass
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
+            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
+        }
+
+        final TypeCheckedCustomizerProvider provider = new TypeCheckedCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(provider))) {
+            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            final Throwable root = ExceptionUtils.getRootCause(se);
+            assertEquals(MultipleCompilationErrorsException.class, root.getClass());
+            assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists."));
+        }
+    }
+
+    @Test
+    public void shouldTypeCheckWithExtensionDeprecated() throws Exception {
         // with no type checking extension this should pass
         final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
@@ -73,7 +91,26 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
     }
 
     @Test
-    public void shouldTypeCheckWithMultipleExtension() throws Exception {
+    public void shouldTypeCheckWithExtension() throws Exception {
+        // with no type checking extension this should pass
+        final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+            assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
+        }
+
+        final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
+                PrecompiledExtensions.PreventColorUsageExtension.class.getName());
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+    }
+
+    @Test
+    public void shouldTypeCheckWithMultipleExtensionDeprecated() throws Exception {
         // with no type checking extension this should pass
         final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
@@ -100,4 +137,33 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
             assertThat(se.getMessage(), containsString("Method call is not allowed!"));
         }
     }
+
+    @Test
+    public void shouldTypeCheckWithMultipleExtension() throws Exception {
+        // with no type checking extension this should pass
+        final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+            assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
+            assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"));
+        }
+
+        final TypeCheckedCustomizerProvider providerWithExtension = new TypeCheckedCustomizerProvider(
+                PrecompiledExtensions.PreventColorUsageExtension.class.getName() +
+                        "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName());
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
+            scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8dc9b1fb/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
new file mode 100644
index 0000000..8d2178f
--- /dev/null
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.codehaus.groovy.control.CompilerConfiguration;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GroovyCompilerGremlinPluginTest {
+
+    @Test
+    public void shouldConfigureForGroovyOnly() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                compilation(Compilation.COMPILE_STATIC).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-not-real");
+        assertThat(customizers.isPresent(), is(false));
+    }
+
+    @Test
+    public void shouldConfigureWithCompileStatic() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                compilation(Compilation.COMPILE_STATIC).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(CompileStaticCustomizerProvider.class));
+    }
+
+    @Test
+    public void shouldConfigureWithTypeChecked() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                compilation(Compilation.TYPE_CHECKED).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(TypeCheckedCustomizerProvider.class));
+    }
+
+    @Test
+    public void shouldConfigureWithCustomCompilerConfigurations() {
+        final Map<String,Object> conf = new HashMap<>();
+        conf.put("Debug", true);
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                compilerConfigurationOptions(conf).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(ConfigurationCustomizerProvider.class));
+
+        final CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
+        assertThat(compilerConfiguration.getDebug(), is(false));
+
+        final ConfigurationCustomizerProvider provider = (ConfigurationCustomizerProvider) ((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider();
+        provider.applyCustomization(compilerConfiguration);
+
+        assertThat(compilerConfiguration.getDebug(), is(true));
+    }
+
+    @Test
+    public void shouldConfigureWithInterpreterMode() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                enableInterpreterMode(true).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(InterpreterModeCustomizerProvider.class));
+    }
+
+    @Test
+    public void shouldConfigureWithThreadInterrupt() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                enableThreadInterrupt(true).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(ThreadInterruptCustomizerProvider.class));
+    }
+
+    @Test
+    public void shouldConfigureWithTimedInterrupt() {
+        final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build().
+                timedInterrupt(60000).create();
+        final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
+        assertThat(customizers.isPresent(), is(true));
+        assertEquals(1, customizers.get().length);
+        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(TimedInterruptCustomizerProvider.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldNotConfigureIfNoSettingsAreSupplied() {
+        GroovyCompilerGremlinPlugin.build().create();
+    }
+}


[17/50] tinkerpop git commit: TINKERPOP-1562 Change Set to List to preserve order in script execution.

Posted by sp...@apache.org.
TINKERPOP-1562 Change Set to List to preserve order in script execution.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 873ac619e935e226505f75bd6caacd76d820531b
Parents: 2d49710
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 16:42:46 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java  | 2 +-
 .../tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java     | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/873ac619/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
index 93ad9d8..0131ca2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
@@ -60,7 +60,7 @@ public final class ScriptFileGremlinPlugin extends AbstractGremlinPlugin {
             return this;
         }
 
-        public Builder files(final Set<String> files) {
+        public Builder files(final List<String> files) {
             for (String f : files) {
                 final File file = new File(f);
                 if (!file.exists()) throw new IllegalArgumentException(new FileNotFoundException(f));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/873ac619/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
index 81cf9e6..681d2ac 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPluginTest.java
@@ -23,6 +23,7 @@ import org.junit.Test;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -41,7 +42,7 @@ public class ScriptFileGremlinPluginTest {
     public void shouldOpenViaPropertiesFileConfig() throws IOException {
         final File scriptFile1 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-1.groovy", ".groovy");
         final File scriptFile2 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-2.groovy", ".groovy");
-        final Set<String> files = new HashSet<>();
+        final List<String> files = new ArrayList<>();
         files.add(scriptFile1.getAbsolutePath());
         files.add(scriptFile2.getAbsolutePath());
         final GremlinPlugin plugin = ScriptFileGremlinPlugin.build().files(files).create();


[07/50] tinkerpop git commit: TINKERPOP-1562 Minor changes to javadocs.

Posted by sp...@apache.org.
TINKERPOP-1562 Minor changes to javadocs.

Also, moved a public static field back to ImportCustomizer (after it became a interface).


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

Branch: refs/heads/TINKERPOP-1490
Commit: 03e931d151684e2186ae9b8b1f7887b93817157f
Parents: a91fb80
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 23 11:31:06 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java |  7 ++++---
 .../gremlin/jsr223/DefaultImportCustomizer.java     |  8 --------
 .../tinkerpop/gremlin/jsr223/ImportCustomizer.java  | 10 ++++++++++
 .../gremlin/jsr223/ImportGremlinPlugin.java         |  7 ++++---
 .../gremlin/jsr223/ScriptFileGremlinPlugin.java     | 16 ++++++++++------
 5 files changed, 28 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/03e931d1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
index 410b222..d579691 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
@@ -23,13 +23,14 @@ import org.apache.tinkerpop.gremlin.util.CoreImports;
 import java.util.Optional;
 
 /**
- * This module is required for a {@code ScriptEngine} to be Gremlin-enabled.
+ * This module is required for a {@code ScriptEngine} to be Gremlin-enabled. This {@link GremlinPlugin} is not enabled
+ * for the {@code ServiceLoader}. It is designed to be instantiated manually.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class CoreGremlinPlugin implements GremlinPlugin {
 
-    private static final String MODULE_NAME = "tinkerpop.core";
+    private static final String NAME = "tinkerpop.core";
 
     private static final ImportCustomizer gremlinCore = DefaultImportCustomizer.build()
             .addClassImports(CoreImports.getClassImports())
@@ -57,6 +58,6 @@ public final class CoreGremlinPlugin implements GremlinPlugin {
 
     @Override
     public String getName() {
-        return MODULE_NAME;
+        return NAME;
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/03e931d1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
index 85d6531..fa0965d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
@@ -33,14 +33,6 @@ import java.util.Set;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class DefaultImportCustomizer implements ImportCustomizer {
-    /**
-     * @deprecated As of release 3.2.4, not replaced.
-     */
-    @Deprecated
-    public static final ImportCustomizer GREMLIN_CORE = DefaultImportCustomizer.build()
-            .addClassImports(CoreImports.getClassImports())
-            .addEnumImports(CoreImports.getEnumImports())
-            .addMethodImports(CoreImports.getMethodImports()).create();
 
     private final Set<Class> classImports;
     private final Set<Method> methodImports;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/03e931d1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
index 7eced82..7b056ff 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
+import org.apache.tinkerpop.gremlin.util.CoreImports;
+
 import java.lang.reflect.Method;
 import java.util.Set;
 
@@ -27,6 +29,14 @@ import java.util.Set;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface ImportCustomizer extends Customizer {
+    /**
+     * @deprecated As of release 3.2.4, not replaced.
+     */
+    @Deprecated
+    public static final ImportCustomizer GREMLIN_CORE = DefaultImportCustomizer.build()
+            .addClassImports(CoreImports.getClassImports())
+            .addEnumImports(CoreImports.getEnumImports())
+            .addMethodImports(CoreImports.getMethodImports()).create();
 
     public Set<Class> getClassImports();
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/03e931d1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java
index 26290d3..0d446c0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java
@@ -33,15 +33,16 @@ import java.util.stream.Stream;
 /**
  * A module that allows custom class, static method and enum imports (i.e. those that are statically defined by a
  * module within itself). A user might utilize this class to supply their own imports. This module is not specific
- * to any {@link GremlinScriptEngine} - the imports are supplied to all engines.
+ * to any {@link GremlinScriptEngine} - the imports are supplied to all engines. This {@link GremlinPlugin} is not
+ * enabled for the {@code ServiceLoader}. It is designed to be instantiated manually.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class ImportGremlinPlugin extends AbstractGremlinPlugin {
-    private static final String MODULE_NAME = "tinkerpop.import";
+    private static final String NAME = "tinkerpop.import";
 
     private ImportGremlinPlugin(final Builder builder) {
-        super(MODULE_NAME, builder.appliesTo, DefaultImportCustomizer.build()
+        super(NAME, builder.appliesTo, DefaultImportCustomizer.build()
                                                 .addClassImports(builder.classImports)
                                                 .addEnumImports(builder.enumImports)
                                                 .addMethodImports(builder.methodImports).create());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/03e931d1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
index 3fd811a..757001c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
@@ -25,13 +25,16 @@ import java.util.HashSet;
 import java.util.Set;
 
 /**
+ * Loads scripts from one or more files into the {@link GremlinScriptEngine} at startup. This {@link GremlinPlugin} is
+ * not enabled for the {@code ServiceLoader}. It is designed to be instantiated manually.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class ScriptFileGremlinPlugin extends AbstractGremlinPlugin {
-    private static final String MODULE_NAME = "tinkerpop.script";
+    private static final String NAME = "tinkerpop.script";
 
-    public ScriptFileGremlinPlugin(final Builder builder) {
-        super(MODULE_NAME, builder.appliesTo, new DefaultScriptCustomizer(builder.files));
+    private ScriptFileGremlinPlugin(final Builder builder) {
+        super(NAME, builder.appliesTo, new DefaultScriptCustomizer(builder.files));
     }
 
     public static Builder build() {
@@ -47,10 +50,11 @@ public final class ScriptFileGremlinPlugin extends AbstractGremlinPlugin {
 
         /**
          * The name of the {@link GremlinScriptEngine} that this module will apply to. Setting no values here will
-         * make the module available to all the engines.
+         * make the module available to all the engines. Typically, this value should be set as a script's syntax will
+         * be bound to the {@link GremlinScriptEngine} language.
          */
-        public Builder appliesTo(final Collection<String> scriptEngineName) {
-            this.appliesTo.addAll(scriptEngineName);
+        public Builder appliesTo(final Collection<String> scriptEngineNames) {
+            this.appliesTo.addAll(scriptEngineNames);
             return this;
         }
 


[14/50] tinkerpop git commit: TINKERPOP=1562 Loaded "gremlin" imports in the scriptengines

Posted by sp...@apache.org.
TINKERPOP=1562 Loaded "gremlin" imports in the scriptengines

Rather than load them in the DefaultGremlinScriptEngineManager it seemed better to get them loaded in the engines themselves that way if someone opted to construct the GremlinScriptEngine directly the imports would be present.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 80f79bcc4d296662faf0e5296607f274ac9e3ab5
Parents: 9f33bee
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 28 16:51:12 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java      |  3 ++-
 .../jsr223/DefaultGremlinScriptEngineManager.java        |  3 ---
 .../gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java |  8 ++++++--
 .../gremlin/python/jsr223/GremlinJythonScriptEngine.java | 11 ++++++-----
 .../gremlin/jsr223/GremlinEnabledScriptEngineTest.java   |  5 ++---
 5 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80f79bcc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
index d579691..a3063cf 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
@@ -24,7 +24,8 @@ import java.util.Optional;
 
 /**
  * This module is required for a {@code ScriptEngine} to be Gremlin-enabled. This {@link GremlinPlugin} is not enabled
- * for the {@code ServiceLoader}. It is designed to be instantiated manually.
+ * for the {@code ServiceLoader}. It is designed to be instantiated manually and compliant {@link GremlinScriptEngine}
+ * instances will automatically install it by default when created.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80f79bcc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
index 1484f90..34ef995 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
@@ -404,9 +404,6 @@ public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineMan
     }
 
     private void initEngines(final ClassLoader loader) {
-        // always need this module for a scriptengine to be "Gremlin-enabled"
-        plugins.add(CoreGremlinPlugin.instance());
-
         Iterator<GremlinScriptEngineFactory> itty;
         try {
             final ServiceLoader<GremlinScriptEngineFactory> sl = AccessController.doPrivileged(

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80f79bcc/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index 3ce400e..264587a 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -38,6 +38,7 @@ import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader;
 import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact;
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin;
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPluginException;
+import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
@@ -184,7 +185,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
      * Creates a new instance using the {@link DefaultImportCustomizerProvider}.
      */
     public GremlinGroovyScriptEngine() {
-        this((CompilerCustomizerProvider) new DefaultImportCustomizerProvider());
+        this(new Customizer[0]);
     }
 
     /**
@@ -196,7 +197,10 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
     }
 
     public GremlinGroovyScriptEngine(final Customizer... customizers) {
-        final List<Customizer> listOfCustomizers = Arrays.asList(customizers);
+        final List<Customizer> listOfCustomizers = new ArrayList<>(Arrays.asList(customizers));
+
+        // always need this plugin for a scriptengine to be "Gremlin-enabled"
+        CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").ifPresent(c -> listOfCustomizers.addAll(Arrays.asList(c)));
 
         GremlinLoader.load();
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80f79bcc/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
index 1b95a02..1a4b57a 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -19,6 +19,7 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
+import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
@@ -27,7 +28,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.util.CoreImports;
 import org.python.jsr223.PyScriptEngine;
 import org.python.jsr223.PyScriptEngineFactory;
@@ -37,12 +37,10 @@ import javax.script.ScriptContext;
 import javax.script.ScriptException;
 import java.io.Reader;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -82,7 +80,10 @@ public class GremlinJythonScriptEngine implements GremlinScriptEngine {
 
     public GremlinJythonScriptEngine(final Customizer... customizers) {
         this.pyScriptEngine = (PyScriptEngine) new PyScriptEngineFactory().getScriptEngine();
-        final List<Customizer> listOfCustomizers = Arrays.asList(customizers);
+        final List<Customizer> listOfCustomizers = new ArrayList<>(Arrays.asList(customizers));
+
+        // always need this plugin for a scriptengine to be "Gremlin-enabled"
+        CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").ifPresent(c -> listOfCustomizers.addAll(Arrays.asList(c)));
 
         final List<ImportCustomizer> importCustomizers = listOfCustomizers.stream()
                 .filter(p -> p instanceof ImportCustomizer)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80f79bcc/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
index 8fa70b0..5a880f8 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
@@ -82,12 +82,11 @@ public class GremlinEnabledScriptEngineTest {
     }
 
     @Test
-    public void shouldReturnOneCustomizers() {
-        // just returns the core plugin as the other assigned plugin doesn't match the tested engine
+    public void shouldReturnNoCustomizers() {
         final GremlinScriptEngineManager mgr = new DefaultGremlinScriptEngineManager();
         mgr.addPlugin(ImportGremlinPlugin.build()
                 .classImports(java.awt.Color.class)
                 .appliesTo(Collections.singletonList("fake-script-engine")).create());
-        assertEquals(1, mgr.getCustomizers(ENGINE_TO_TEST).size());
+        assertEquals(0, mgr.getCustomizers(ENGINE_TO_TEST).size());
     }
 }


[02/50] tinkerpop git commit: TINKERPOP-1562 Added new plugins for gremlin-groovy to replace deprecated ones.

Posted by sp...@apache.org.
TINKERPOP-1562 Added new plugins for gremlin-groovy to replace deprecated ones.

Specifically did SugarGremlinPlugin and CredentialsGrpahGremlinPlugin.


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

Branch: refs/heads/TINKERPOP-1490
Commit: bb5b47dd98aa936673b1588202dbcc378a83b718
Parents: d0c941e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 22 14:20:11 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../jsr223/ScriptEnginePluginAcceptor.java      |  2 +
 .../groovy/jsr223/SugarGremlinPlugin.java       | 45 ++++++++++++++++
 .../groovy/plugin/SugarGremlinPlugin.java       |  2 +
 .../CredentialGraphGremlinPlugin.java           |  2 +
 .../jsr223/CredentialGraphGremlinPlugin.java    | 55 ++++++++++++++++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |  2 +
 6 files changed, 108 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java
index 0bd51c2..5832e0b 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java
@@ -34,7 +34,9 @@ import java.util.Set;
  * interact with them on initialization.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 public class ScriptEnginePluginAcceptor implements PluginAcceptor {
     private final ScriptEngine scriptEngine;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
new file mode 100644
index 0000000..95c610f
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/SugarGremlinPlugin.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultScriptCustomizer;
+
+import java.util.Collections;
+
+/**
+ * A plugin implementation which allows for the usage of Gremlin Groovy's syntactic sugar.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class SugarGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.sugar";
+
+    public SugarGremlinPlugin() {
+        super(NAME, new DefaultScriptCustomizer(Collections.singletonList(
+                Collections.singletonList(SugarLoader.class.getPackage().getName() + "." + SugarLoader.class.getSimpleName() + ".load()"))));
+    }
+
+    @Override
+    public String getName() {
+        return "tinkerpop.sugar";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java
index 845ffc6..0666d71 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java
@@ -24,7 +24,9 @@ import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
  * A plugin implementation which allows for the usage of Gremlin Groovy's syntactic sugar.
  *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.SugarGremlinPlugin}.
  */
+@Deprecated
 public class SugarGremlinPlugin extends AbstractGremlinPlugin {
 
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java
index 8550615..72ca1d5 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java
@@ -30,7 +30,9 @@ import java.util.Set;
  * Plugin for the "credentials graph".  This plugin imports the {@link CredentialGraph} to its environment.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphGremlinPlugin}.
  */
+@Deprecated
 public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin {
 
     private static final Set<String> IMPORTS = new HashSet<String>() {{

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
new file mode 100644
index 0000000..761567b
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Plugin for the "credentials graph".  This plugin imports the {@link CredentialGraph} to its environment.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.credentials";
+
+    private static final ImportCustomizer imports;
+
+    static {
+        try {
+            imports = DefaultImportCustomizer.build()
+                    .addClassImports(CredentialGraph.class)
+                    .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class))
+                    .create();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public CredentialGraphGremlinPlugin() {
+        super(NAME, imports);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb5b47dd/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..0004a80
--- /dev/null
+++ b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1,2 @@
+org.apache.tinkerpop.gremlin.groovy.jsr223.SugarGremlinPlugin
+org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.jsr223.CredentialGraphGremlinPlugin
\ No newline at end of file


[43/50] tinkerpop git commit: TINKERPOP-1490 Restructured Traversal.promise()

Posted by sp...@apache.org.
TINKERPOP-1490 Restructured Traversal.promise()

No longer uses an ExecutorService and is only applicable to "remote" traversals. Moved the commons-lang dependency back to gremlin-groovy for now.


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

Branch: refs/heads/TINKERPOP-1490
Commit: ee6a35893661b015dbb827463f175ddcecf1bcb8
Parents: eb08976
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Nov 11 12:51:40 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 gremlin-core/pom.xml                            |   5 -
 .../process/remote/RemoteConnection.java        |  12 +-
 .../remote/traversal/RemoteTraversal.java       |   2 +-
 .../remote/traversal/step/map/RemoteStep.java   |  32 +++-
 .../gremlin/process/traversal/Traversal.java    |  57 ++------
 .../traversal/util/DefaultTraversal.java        |  37 -----
 .../process/traversal/TraversalTest.java        | 145 -------------------
 .../tinkerpop/gremlin/driver/Connection.java    |   6 +-
 .../driver/remote/DriverRemoteConnection.java   |  14 ++
 .../driver/remote/DriverRemoteTraversal.java    |  16 +-
 .../DriverRemoteTraversalSideEffects.java       |  22 ++-
 .../DriverRemoteTraversalSideEffectsTest.java   |  12 +-
 gremlin-groovy/pom.xml                          |   5 +
 .../server/GremlinServerIntegrateTest.java      |  25 ++++
 .../process/traversal/CoreTraversalTest.java    |  42 ------
 15 files changed, 131 insertions(+), 301 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index 0594448..e8f3a34 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -61,11 +61,6 @@ limitations under the License.
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.1</version>
-        </dependency>
         <!-- LOGGING -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
index 8506ad7..f4e3976 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 
 import java.util.Iterator;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * A simple abstraction of a "connection" to a "server" that is capable of processing a {@link Traversal} and
@@ -43,9 +44,16 @@ public interface RemoteConnection extends AutoCloseable {
     public <E> Iterator<Traverser.Admin<E>> submit(final Traversal<?, E> traversal) throws RemoteConnectionException;
 
     /**
-     * Submits {@link Traversal} {@link Bytecode} to a server and returns a {@link Traversal}.
-     * The {@link Traversal} is an abstraction over two types of results that can be returned as part of the
+     * Submits {@link Traversal} {@link Bytecode} to a server and returns a {@link RemoteTraversal}.
+     * The {@link RemoteTraversal} is an abstraction over two types of results that can be returned as part of the
      * response from the server: the results of the {@link Traversal} itself and the side-effects that it produced.
      */
     public <E> RemoteTraversal<?,E> submit(final Bytecode bytecode) throws RemoteConnectionException;
+
+    /**
+     * Submits {@link Traversal} {@link Bytecode} to a server and returns a promise of a {@link RemoteTraversal}.
+     * The {@link RemoteTraversal} is an abstraction over two types of results that can be returned as part of the
+     * response from the server: the results of the {@link Traversal} itself and the side-effects that it produced.
+     */
+    public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final Bytecode bytecode) throws RemoteConnectionException;
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
index 9c893c2..57b0cda 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
@@ -39,7 +39,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 public interface RemoteTraversal<S,E> extends Traversal.Admin<S,E> {
 
     /**
-     * Returns remote side-effects generated by the traversal so that they can accessible to the client. Note that
+     * Returns remote side-effects generated by the traversal so that they can be accessible to the client. Note that
      * "side-effect" refers to the value in "a" in the traversal {@code g.V().aggregate('a').values('name')}.
      */
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
index 6b2be96..3e19097 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
@@ -21,12 +21,17 @@ package org.apache.tinkerpop.gremlin.process.remote.traversal.step.map;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.RemoteTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.NoSuchElementException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Sends a {@link Traversal} to a {@link RemoteConnection} and iterates back the results.
@@ -38,6 +43,7 @@ public final class RemoteStep<S, E> extends AbstractStep<S, E> {
 
     private transient RemoteConnection remoteConnection;
     private RemoteTraversal<?, E> remoteTraversal;
+    private final AtomicReference<CompletableFuture<Traversal<?, E>>> traversalFuture = new AtomicReference<>(null);
 
     public RemoteStep(final Traversal.Admin traversal, final RemoteConnection remoteConnection) {
         super(traversal);
@@ -51,14 +57,26 @@ public final class RemoteStep<S, E> extends AbstractStep<S, E> {
 
     @Override
     protected Traverser.Admin<E> processNextStart() throws NoSuchElementException {
-        if (null == this.remoteTraversal) {
-            try {
-                this.remoteTraversal = this.remoteConnection.submit(this.traversal.getBytecode());
-                this.traversal.setSideEffects(this.remoteTraversal.getSideEffects());
-            } catch (final RemoteConnectionException sce) {
-                throw new IllegalStateException(sce);
+        if (null == this.remoteTraversal) promise().join();
+        return this.remoteTraversal.nextTraverser();
+    }
+
+    /**
+     * Submits the traversal asynchronously to a "remote" using {@link RemoteConnection#submitAsync(Bytecode)}.
+     */
+    public CompletableFuture<Traversal<?, E>> promise() {
+        try {
+            if (null == traversalFuture.get()) {
+                traversalFuture.set(this.remoteConnection.submitAsync(this.traversal.getBytecode()).<Traversal<?, E>>thenApply(t -> {
+                    this.remoteTraversal = (RemoteTraversal<?, E>) t;
+                    this.traversal.setSideEffects(this.remoteTraversal.getSideEffects());
+                    return traversal;
+                }));
             }
+
+            return traversalFuture.get();
+        } catch (RemoteConnectionException rce) {
+            throw new IllegalStateException(rce);
         }
-        return this.remoteTraversal.nextTraverser();
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
index e4ba5a6..04f5127 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
@@ -18,8 +18,9 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal;
 
-import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
@@ -43,11 +44,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.Spliterator;
 import java.util.Spliterators;
-import java.util.concurrent.CancellationException;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.stream.Stream;
@@ -148,39 +145,21 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
 
     /**
      * Starts a promise to execute a function on the current {@code Traversal} that will be completed in the future.
-     * This implementation uses {@link Admin#traversalExecutorService} to execute the supplied
-     * {@code traversalFunction}.
+     * Note that this method can only be used if the {@code Traversal} is constructed using
+     * {@link TraversalSource#withRemote(Configuration)}. Calling this method otherwise will yield an
+     * {@code IllegalStateException}.
      */
     public default <T> CompletableFuture<T> promise(final Function<Traversal, T> traversalFunction) {
-        return promise(traversalFunction, Admin.traversalExecutorService);
-    }
-
-    /**
-     * Starts a promise to execute a function on the current {@code Traversal} that will be completed in the future.
-     * This implementation uses the caller supplied {@code ExecutorService} to execute the {@code traversalFunction}.
-     */
-    public default <T> CompletableFuture<T> promise(final Function<Traversal, T> traversalFunction, final ExecutorService service) {
-        final CompletableFuture<T> promise = new CompletableFuture<>();
-        final Future iterationFuture = service.submit(() -> {
-            try {
-                promise.complete(traversalFunction.apply(this));
-            } catch (Exception ex) {
-                // the promise may have been cancelled by the caller, in which case, there is no need to attempt
-                // another write on completion
-                if (!promise.isDone()) promise.completeExceptionally(ex);
-            }
-        });
-
-        // if the user cancels the promise then attempt to kill the iteration.
-        promise.exceptionally(t -> {
-            if (t instanceof CancellationException) {
-                iterationFuture.cancel(true);
-            }
-
-            return null;
-        });
-
-        return promise;
+        // apply strategies to see if RemoteStrategy has any effect (i.e. add RemoteStep)
+        if (!this.asAdmin().isLocked()) this.asAdmin().applyStrategies();
+
+        // use the end step so the results are bulked
+        final Step<?, E> endStep = this.asAdmin().getEndStep();
+        if (endStep instanceof RemoteStep) {
+            return ((RemoteStep) endStep).promise().thenApply(traversalFunction);
+        } else {
+            throw new IllegalStateException("Only traversals created using withRemote() can be used in an async way");
+        }
     }
 
     /**
@@ -297,12 +276,6 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
     public interface Admin<S, E> extends Traversal<S, E> {
 
         /**
-         * Service that handles promises.
-         */
-        static final ExecutorService traversalExecutorService = Executors.newCachedThreadPool(
-                new BasicThreadFactory.Builder().namingPattern("traversal-executor-%d").build());
-
-        /**
          * Get the {@link Bytecode} associated with the construction of this traversal.
          *
          * @return the byte code representation of the traversal

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 6ce6dfe..3c21e37 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -43,9 +43,6 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Function;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -328,40 +325,6 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         this.graph = graph;
     }
 
-    /**
-     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions.
-     */
-    @Override
-    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction) {
-        return this.promise(traversalFunction, Traversal.Admin.traversalExecutorService);
-    }
-
-    /**
-     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions. In a transactional graph
-     * a promise represents the full scope of a transaction, even if the graph is only partially iterated.
-     */
-    @Override
-    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction, final ExecutorService service) {
-        if (graph != null && graph.features().graph().supportsTransactions()) {
-            final Function<Traversal, T2> transactionAware = traversal -> {
-
-                try {
-                    if (graph.tx().isOpen()) graph.tx().rollback();
-                    final T2 obj = traversalFunction.apply(traversal);
-                    if (graph.tx().isOpen()) graph.tx().commit();
-                    return obj;
-                } catch (Exception ex) {
-                    if (graph.tx().isOpen()) graph.tx().rollback();
-                    throw ex;
-                }
-            };
-
-            return Traversal.Admin.super.promise(transactionAware, service);
-        } else {
-            return Traversal.Admin.super.promise(traversalFunction, service);
-        }
-    }
-
     @Override
     public boolean equals(final Object other) {
         return other != null && other.getClass().equals(this.getClass()) && this.equals(((Traversal.Admin) other));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
index aa1b99b..c427d8e 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
@@ -30,34 +30,22 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.NoSuchElementException;
 import java.util.Optional;
-import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsCollectionContaining.hasItems;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class TraversalTest {
 
-    private final ExecutorService service = Executors.newFixedThreadPool(2);
-
     @Test
     public void shouldTryNext() {
         final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3);
@@ -117,139 +105,6 @@ public class TraversalTest {
     }
 
     @Test
-    public void shouldPromiseNextThreeUsingForkJoin() throws Exception {
-        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
-        final CompletableFuture<List<Integer>> promiseFirst = t.promise(traversal -> traversal.next(3));
-        final List<Integer> listFirst = promiseFirst.get();
-        assertEquals(3, listFirst.size());
-        assertThat(listFirst, hasItems(1 ,2, 3));
-        assertThat(t.hasNext(), is(true));
-        assertThat(promiseFirst.isDone(), is(true));
-
-        final CompletableFuture<List<Integer>> promiseSecond = t.promise(traversal -> traversal.next(3));
-        final List<Integer> listSecond = promiseSecond.get();
-        assertEquals(3, listSecond.size());
-        assertThat(listSecond, hasItems(4, 5, 6));
-        assertThat(t.hasNext(), is(true));
-        assertThat(promiseSecond.isDone(), is(true));
-
-        final CompletableFuture<List<Integer>> promiseThird = t.promise(traversal -> traversal.next(3));
-        final List<Integer> listThird = promiseThird.get();
-        assertEquals(1, listThird.size());
-        assertThat(listThird, hasItems(7));
-        assertThat(t.hasNext(), is(false));
-        assertThat(promiseThird.isDone(), is(true));
-
-        final CompletableFuture<Integer> promiseDead = t.promise(traversal -> (Integer) traversal.next());
-        final AtomicBoolean dead = new AtomicBoolean(false);
-        promiseDead.exceptionally(tossed -> {
-            dead.set(tossed instanceof NoSuchElementException);
-            return null;
-        });
-
-        try {
-            promiseDead.get(10000, TimeUnit.MILLISECONDS);
-            fail("Should have gotten an exception");
-        } catch (Exception ex) {
-            if (ex instanceof TimeoutException) {
-                fail("This should not have timed out but should have gotten an exception caught above in the exceptionally() clause");
-            }
-
-            assertThat(ex.getCause(), instanceOf(NoSuchElementException.class));
-        }
-
-        assertThat(dead.get(), is(true));
-        assertThat(t.hasNext(), is(false));
-        assertThat(promiseDead.isDone(), is(true));
-    }
-
-    @Test
-    public void shouldPromiseNextThreeUsingSpecificExecutor() throws Exception {
-        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
-        final CompletableFuture<List<Integer>> promiseFirst = t.promise(traversal -> traversal.next(3), service);
-        final List<Integer> listFirst = promiseFirst.get();
-        assertEquals(3, listFirst.size());
-        assertThat(listFirst, hasItems(1 ,2, 3));
-        assertThat(t.hasNext(), is(true));
-        assertThat(promiseFirst.isDone(), is(true));
-
-        final CompletableFuture<List<Integer>> promiseSecond = t.promise(traversal -> traversal.next(3), service);
-        final List<Integer> listSecond = promiseSecond.get();
-        assertEquals(3, listSecond.size());
-        assertThat(listSecond, hasItems(4, 5, 6));
-        assertThat(t.hasNext(), is(true));
-        assertThat(promiseSecond.isDone(), is(true));
-
-        final CompletableFuture<List<Integer>> promiseThird = t.promise(traversal -> traversal.next(3), service);
-        final List<Integer> listThird = promiseThird.get();
-        assertEquals(1, listThird.size());
-        assertThat(listThird, hasItems(7));
-        assertThat(t.hasNext(), is(false));
-        assertThat(promiseThird.isDone(), is(true));
-
-        final CompletableFuture<Integer> promiseDead = t.promise(traversal -> (Integer) traversal.next(), service);
-        final AtomicBoolean dead = new AtomicBoolean(false);
-        promiseDead.exceptionally(tossed -> {
-            dead.set(tossed instanceof NoSuchElementException);
-            return null;
-        });
-
-        try {
-            promiseDead.get(10000, TimeUnit.MILLISECONDS);
-            fail("Should have gotten an exception");
-        } catch (Exception ex) {
-            if (ex instanceof TimeoutException) {
-                fail("This should not have timed out but should have gotten an exception caught above in the exceptionally() clause");
-            }
-
-            assertThat(ex.getCause(), instanceOf(NoSuchElementException.class));
-        }
-
-        assertThat(dead.get(), is(true));
-        assertThat(t.hasNext(), is(false));
-        assertThat(promiseDead.isDone(), is(true));
-    }
-
-    @Test
-    public void shouldInterruptTraversalFunction() throws Exception {
-        final Random rand = new Random(1234567890);
-
-        // infinite traversal
-        final MockTraversal<Integer> t = new MockTraversal<>(IntStream.generate(rand::nextInt).iterator());
-
-        // iterate a bunch of it
-        final CompletableFuture<List<Integer>> promise10 = t.promise(traversal -> traversal.next(10), service);
-        assertEquals(10, promise10.get(10000, TimeUnit.MILLISECONDS).size());
-        final CompletableFuture<List<Integer>> promise100 = t.promise(traversal -> traversal.next(100), service);
-        assertEquals(100, promise100.get(10000, TimeUnit.MILLISECONDS).size());
-        final CompletableFuture<List<Integer>> promise1000 = t.promise(traversal -> traversal.next(1000), service);
-        assertEquals(1000, promise1000.get(10000, TimeUnit.MILLISECONDS).size());
-
-        // this is endless, so let's cancel
-        final CompletableFuture<List<Integer>> promiseForevers = t.promise(traversal -> traversal.next(Integer.MAX_VALUE), service);
-
-        // specify what to do on exception
-        final AtomicBoolean failed = new AtomicBoolean(false);
-        promiseForevers.exceptionally(ex -> {
-            failed.set(true);
-            return null;
-        });
-
-        try {
-            // let it actually iterate a moment
-            promiseForevers.get(500, TimeUnit.MILLISECONDS);
-            fail("This should have timed out because the traversal has infinite items in it");
-        } catch (TimeoutException tex) {
-
-        }
-
-        assertThat(promiseForevers.isDone(), is(false));
-        promiseForevers.cancel(true);
-        assertThat(failed.get(), is(true));
-        assertThat(promiseForevers.isDone(), is(true));
-    }
-
-    @Test
     public void shouldIterate() {
         final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
         assertThat(t.hasNext(), is(true));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
index 972e838..9a2180e 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
@@ -208,7 +208,7 @@ final class Connection {
                             logger.debug(String.format("Write on connection %s failed", thisConnection.getConnectionInfo()), f.cause());
                         thisConnection.isDead = true;
                         thisConnection.returnToPool();
-                        future.completeExceptionally(f.cause());
+                        cluster.executor().submit(() -> future.completeExceptionally(f.cause()));
                     } else {
                         final LinkedBlockingQueue<Result> resultLinkedBlockingQueue = new LinkedBlockingQueue<>();
                         final CompletableFuture<Void> readCompleted = new CompletableFuture<>();
@@ -250,8 +250,8 @@ final class Connection {
 
                         final ResultQueue handler = new ResultQueue(resultLinkedBlockingQueue, readCompleted);
                         pending.put(requestMessage.getRequestId(), handler);
-                        future.complete(new ResultSet(handler, cluster.executor(), readCompleted,
-                                requestMessage, pool.host));
+                        cluster.executor().submit(() -> future.complete(
+                                new ResultSet(handler, cluster.executor(), readCompleted, requestMessage, pool.host)));
                     }
                 });
         channel.writeAndFlush(requestMessage, requestPromise);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index bb2d33d..be3fa28 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -37,6 +37,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Iterator;
 import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
 import java.util.function.Supplier;
 
 /**
@@ -163,6 +164,10 @@ public class DriverRemoteConnection implements RemoteConnection {
         }
     }
 
+    /**
+     * @deprecated As of release 3.2.2, replaced by {@link #submit(Bytecode)}.
+     */
+    @Deprecated
     @Override
     public <E> Iterator<Traverser.Admin<E>> submit(final Traversal<?, E> t) throws RemoteConnectionException {
         try {
@@ -189,6 +194,15 @@ public class DriverRemoteConnection implements RemoteConnection {
     }
 
     @Override
+    public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final Bytecode bytecode) throws RemoteConnectionException {
+        try {
+            return client.submitAsync(bytecode).thenApply(rs -> new DriverRemoteTraversal<>(rs, client, attachElements, conf));
+        } catch (Exception ex) {
+            throw new RemoteConnectionException(ex);
+        }
+    }
+
+    @Override
     public void close() throws Exception {
         try {
             client.close();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
index 88ee794..d3f290c 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
@@ -66,28 +66,18 @@ public class DriverRemoteTraversal<S, E> extends AbstractRemoteTraversal<S, E> {
         }
 
         this.rs = rs;
-        this.sideEffects = new DriverRemoteTraversalSideEffects(
-                client,
+        this.sideEffects = new DriverRemoteTraversalSideEffects(client,
                 rs.getOriginalRequestMessage().getRequestId(),
-                rs.getHost());
+                rs.getHost(), rs.allItemsAvailableAsync());
     }
 
     /**
      * Gets a side-effect from the server. Do not call this method prior to completing the iteration of the
-     * {@link DriverRemoteTraversal} that spawned this as the side-effect will not be ready. If this method is called
-     * prior to iteration being complete, then it will block until the traversal notifies it of completion. Generally
+     * {@link DriverRemoteTraversal} that spawned this as the side-effect will not be ready. Generally
      * speaking, the common user would not get side-effects this way - they would use a call to {@code cap()}.
      */
     @Override
     public RemoteTraversalSideEffects getSideEffects() {
-        // wait for the read to complete (i.e. iteration on the server) before allowing the caller to get the
-        // side-effect. calling prior to this will result in the side-effect not being found. of course, the
-        // bad part here is that the method blocks indefinitely waiting for the result, but it prevents the
-        // test failure problems that happen on slower systems. in practice, it's unlikely that a user would
-        // try to get a side-effect prior to iteration, but since the API allows it, this at least prevents
-        // the error.
-        rs.allItemsAvailableAsync().join();
-
         return this.sideEffects;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
index 8d6fa98..4305567 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
@@ -33,6 +33,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * Java driver implementation of {@link TraversalSideEffects}. This class is not thread safe.
@@ -50,15 +51,26 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
 
     private boolean closed = false;
     private boolean retrievedAllKeys = false;
+    private final CompletableFuture<Void> ready;
 
-    public DriverRemoteTraversalSideEffects(final Client client, final UUID serverSideEffect, final Host host) {
+    public DriverRemoteTraversalSideEffects(final Client client, final UUID serverSideEffect, final Host host,
+                                            final CompletableFuture<Void> ready) {
         this.client = client;
         this.serverSideEffect = serverSideEffect;
         this.host = host;
+        this.ready = ready;
     }
 
     @Override
     public <V> V get(final String key) throws IllegalArgumentException {
+        // wait for the read to complete (i.e. iteration on the server) before allowing the caller to get the
+        // side-effect. calling prior to this will result in the side-effect not being found. of course, the
+        // bad part here is that the method blocks indefinitely waiting for the result, but it prevents the
+        // test failure problems that happen on slower systems. in practice, it's unlikely that a user would
+        // try to get a side-effect prior to iteration, but since the API allows it, this at least prevents
+        // the error.
+        ready.join();
+
         if (!keys().contains(key)) throw TraversalSideEffects.Exceptions.sideEffectKeyDoesNotExist(key);
 
         if (!sideEffects.containsKey(key)) {
@@ -91,6 +103,14 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
 
     @Override
     public Set<String> keys() {
+        // wait for the read to complete (i.e. iteration on the server) before allowing the caller to get the
+        // side-effect. calling prior to this will result in the side-effect not being found. of course, the
+        // bad part here is that the method blocks indefinitely waiting for the result, but it prevents the
+        // test failure problems that happen on slower systems. in practice, it's unlikely that a user would
+        // try to get a side-effect prior to iteration, but since the API allows it, this at least prevents
+        // the error.
+        ready.join();
+
         if (closed && !retrievedAllKeys) throw new IllegalStateException("Traversal has been closed - side-effect keys cannot be retrieved");
 
         if (!retrievedAllKeys) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
index 27d0079..4e6df93 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
@@ -52,7 +52,9 @@ public class DriverRemoteTraversalSideEffectsTest extends AbstractResultQueueTes
         mockClientForCall(client);
 
         final UUID sideEffectKey = UUID.fromString("31dec2c6-b214-4a6f-a68b-996608dce0d9");
-        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null);
+        final CompletableFuture<Void> ready = new CompletableFuture<>();
+        ready.complete(null);
+        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null, ready);
 
         assertEquals(1, sideEffects.keys().size());
         sideEffects.close();
@@ -73,7 +75,9 @@ public class DriverRemoteTraversalSideEffectsTest extends AbstractResultQueueTes
         mockClientForCall(client);
         mockClientForCall(client);
         final UUID sideEffectKey = UUID.fromString("31dec2c6-b214-4a6f-a68b-996608dce0d9");
-        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null);
+        final CompletableFuture<Void> ready = new CompletableFuture<>();
+        ready.complete(null);
+        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null, ready);
 
         assertNotNull(sideEffects.get("test-0"));
         sideEffects.close();
@@ -93,7 +97,9 @@ public class DriverRemoteTraversalSideEffectsTest extends AbstractResultQueueTes
         mockClientForCall(client);
 
         final UUID sideEffectKey = UUID.fromString("31dec2c6-b214-4a6f-a68b-996608dce0d9");
-        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null);
+        final CompletableFuture<Void> ready = new CompletableFuture<>();
+        ready.complete(null);
+        final TraversalSideEffects sideEffects = new DriverRemoteTraversalSideEffects(client, sideEffectKey, null, ready);
 
         sideEffects.close();
         sideEffects.close();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-groovy/pom.xml b/gremlin-groovy/pom.xml
index dae5e8a..b82c986 100644
--- a/gremlin-groovy/pom.xml
+++ b/gremlin-groovy/pom.xml
@@ -65,6 +65,11 @@ limitations under the License.
             <artifactId>jBCrypt</artifactId>
             <version>jbcrypt-0.4</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
+        </dependency>
         <!-- TEST -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/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 b3dbe29..420bd05 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
@@ -46,12 +46,14 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCust
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.server.channel.NioChannelizer;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
 import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
@@ -76,6 +78,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
@@ -990,4 +993,26 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         final BulkSet localBSideEffects = se.get("b");
         assertThat(localBSideEffects.isEmpty(), is(false));
     }
+
+    @Test
+    public void shouldDoNonBlockingPromiseWithRemote() throws Exception {
+        final Graph graph = EmptyGraph.instance();
+        final GraphTraversalSource g = graph.traversal().withRemote(conf);
+        g.addV("person").property("age", 20).promise(Traversal::iterate).join();
+        g.addV("person").property("age", 10).promise(Traversal::iterate).join();
+        assertEquals(50L, g.V().hasLabel("person").map(Lambda.function("it.get().value('age') + 10")).sum().promise(t -> t.next()).join());
+        g.addV("person").property("age", 20).promise(Traversal::iterate).join();
+
+        final Traversal traversal = g.V().hasLabel("person").has("age", 20).values("age");
+        assertEquals(20, traversal.promise(t -> ((Traversal) t).next(1).get(0)).join());
+        assertEquals(20, traversal.next());
+        assertThat(traversal.hasNext(), is(false));
+
+        final Traversal traversalCloned = g.V().hasLabel("person").has("age", 20).values("age");
+        assertEquals(20, traversalCloned.next());
+        assertEquals(20, traversalCloned.promise(t -> ((Traversal) t).next(1).get(0)).join());
+        assertThat(traversalCloned.promise(t -> ((Traversal) t).hasNext()).join(), is(false));
+
+        assertEquals(3, g.V().promise(Traversal::toList).join().size());
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee6a3589/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
index 050f9de..68f8217 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
@@ -20,7 +20,6 @@ package org.apache.tinkerpop.gremlin.process.traversal;
 
 import org.apache.tinkerpop.gremlin.ExceptionCoverage;
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
-import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -41,9 +40,6 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
@@ -311,42 +307,4 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest {
         }
 
     }
-
-    @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
-    public void shouldUsePromiseAndControlTransactionsIfAvailable() throws Exception {
-        // this test will validate that transactional graphs can properly open/close transactions within a promise.
-        // as there is a feature check, non-transactional graphs can use this to simply exercise the promise API
-        final Vertex vAdded = g.addV("person").property("name", "stephen").promise(t -> (Vertex) t.next()).get(10000, TimeUnit.MILLISECONDS);
-        final Vertex vRead = g.V().has("name", "stephen").next();
-        assertEquals(vAdded.id(), vRead.id());
-
-        // transaction should have been committed at this point so test the count in this thread to validate persistence
-        assertVertexEdgeCounts(graph, 1, 0);
-
-        // cancel a promise and ensure the transaction ended in failure. hold the traversal in park until it can be
-        // interrupted, then the promise will have to rollback the transaction.
-        final CompletableFuture promiseToCancel = g.addV("person").property("name", "marko").sideEffect(traverser -> {
-            try {
-                Thread.sleep(100000);
-            } catch (Exception ignored) {
-
-            }
-        }).promise(t -> (Vertex) t.next());
-
-        try {
-            promiseToCancel.get(500, TimeUnit.MILLISECONDS);
-            fail("Should have timed out");
-        } catch (TimeoutException te) {
-
-        }
-
-        promiseToCancel.cancel(true);
-
-        // graphs that support transactions will rollback the transaction
-        if (graph.features().graph().supportsTransactions())
-            assertVertexEdgeCounts(graph, 1, 0);
-        else
-            assertVertexEdgeCounts(graph, 2, 0);
-    }
 }


[18/50] tinkerpop git commit: TINKERPOP-1562 Deprecated the CredentialGraph

Posted by sp...@apache.org.
TINKERPOP-1562 Deprecated the CredentialGraph

and moved it to a new home so tht the "plugin" package can go away completely.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 6439d709c60a107b3e6a3b79231344f8a2ce2e7a
Parents: 39e3965
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 10:13:04 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../dsl/credential/CredentialGraphTest.java     | 121 +++++++++++++++++++
 .../dsl/credential/CredentialGraphTest.java     |   2 +-
 .../groovy/util/DependencyGrabber.groovy        |  14 +++
 .../jsr223/dsl/credential/CredentialGraph.java  | 121 +++++++++++++++++++
 .../CredentialGraphGremlinPlugin.java           |  51 ++++++++
 .../dsl/credential/CredentialGraphTokens.java   |  31 +++++
 .../plugin/dsl/credential/CredentialGraph.java  |   2 +
 .../dsl/credential/CredentialGraphTokens.java   |   2 +
 .../jsr223/CredentialGraphGremlinPlugin.java    |  55 ---------
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   2 +-
 10 files changed, 344 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
new file mode 100644
index 0000000..e3a713d
--- /dev/null
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
+
+import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
+import org.apache.tinkerpop.gremlin.FeatureRequirement;
+import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.hamcrest.MatcherAssert;
+import org.junit.Test;
+
+import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph.credentials;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class CredentialGraphTest extends AbstractGremlinTest {
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldCreateUser() {
+        final Vertex v = credentials(graph).createUser("stephen", "secret");
+        assertEquals("stephen", v.value("username"));
+        assertEquals("user", v.label());
+        assertNotEquals("secret", v.value("password"));  // hashed to something
+        assertThat(v.value("password").toString().length(), greaterThan(0));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES)
+    public void shouldRemoveUser() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("stephen", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertEquals(1, credentials(graph).removeUser("stephen"));
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldNotRemoveUser() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("stephen", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertEquals(0, credentials(graph).removeUser("stephanie"));
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldFindUser() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("marko", "secret");
+        final Vertex stephen = credentials(graph).createUser("stephen", "secret");
+        credentials(graph).createUser("daniel", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertEquals(stephen, credentials(graph).findUser("stephen"));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldNotFindUser() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("marko", "secret");
+        credentials(graph).createUser("stephen", "secret");
+        credentials(graph).createUser("daniel", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertNull(credentials(graph).findUser("stephanie"));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldCountUsers() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("marko", "secret");
+        credentials(graph).createUser("stephen", "secret");
+        credentials(graph).createUser("daniel", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertEquals(3, credentials(graph).countUsers());
+    }
+
+    @Test(expected = IllegalStateException.class)
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldThrowIfFindingMultipleUsers() {
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
+        credentials(graph).createUser("stephen", "secret");
+        credentials(graph).createUser("stephen", "secret");
+        MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
+
+        assertNull(credentials(graph).findUser("stephen"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java
index d7d7f9d..7cdf329 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java
@@ -26,7 +26,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
-import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph.*;
+import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph.credentials;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.greaterThan;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
index f2bfe5c..4f895c8 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
@@ -50,6 +50,13 @@ class DependencyGrabber {
         this.extensionDirectory = extensionDirectory
     }
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #deleteDependenciesFromPath(Artifact)}
+     */
+    def String deleteDependenciesFromPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) {
+        deleteDependenciesFromPath(new Artifact(artifact.group, artifact.artifact, artifact.version))
+    }
+
     def String deleteDependenciesFromPath(final Artifact artifact) {
         final def dep = makeDepsMap(artifact)
         final String extClassPath = getPathFromDependency(dep)
@@ -63,6 +70,13 @@ class DependencyGrabber {
         }
     }
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #copyDependenciesToPath(Artifact)}
+     */
+    def String copyDependenciesToPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) {
+        copyDependenciesToPath(new Artifact(artifact.group, artifact.artifact, artifact.version))
+    }
+
     def Set<String> copyDependenciesToPath(final Artifact artifact) {
         final def dep = makeDepsMap(artifact)
         final String extClassPath = getPathFromDependency(dep)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
new file mode 100644
index 0000000..707e816
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.mindrot.BCrypt;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.drop;
+
+/**
+ * A DSL for managing a "credentials graph" used by Gremlin Server for simple authentication functions.  If the
+ * {@link Graph} is transactional, new transactions will be started for each method call.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class CredentialGraph {
+
+    private final int BCRYPT_ROUNDS = 4;
+    private final Graph graph;
+    private final GraphTraversalSource g;
+    private final boolean supportsTransactions;
+
+    public CredentialGraph(final Graph graph) {
+        this.graph = graph;
+        g = graph.traversal();
+        supportsTransactions = graph.features().graph().supportsTransactions();
+    }
+
+    /**
+     * Finds a user by username and return {@code null} if one could not be found.
+     *
+     * @throws IllegalStateException if there is more than one user with a particular username.
+     */
+    public Vertex findUser(final String username) {
+        if (supportsTransactions) g.tx().rollback();
+        final GraphTraversal<Vertex,Vertex> t = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username);
+        final Vertex v = t.hasNext() ? t.next() : null;
+        if (t.hasNext()) throw new IllegalStateException(String.format("Multiple users with username %s", username));
+        return v;
+    }
+
+    /**
+     * Creates a new user.
+     *
+     * @return the newly created user vertex
+     */
+    public Vertex createUser(final String username, final String password) {
+        if (findUser(username) != null) throw new IllegalStateException("User with this name already exists");
+        if (supportsTransactions) graph.tx().rollback();
+
+        try {
+            final Vertex v =  graph.addVertex(T.label, CredentialGraphTokens.VERTEX_LABEL_USER,
+                                              CredentialGraphTokens.PROPERTY_USERNAME, username,
+                                              CredentialGraphTokens.PROPERTY_PASSWORD, BCrypt.hashpw(password, BCrypt.gensalt(BCRYPT_ROUNDS)));
+            if (supportsTransactions) graph.tx().commit();
+            return v;
+        } catch (Exception ex) {
+            if (supportsTransactions) graph.tx().rollback();
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Removes a user by name.
+     *
+     * @return the number of users removed (which should be one or zero)
+     */
+    public long removeUser(final String username) {
+        if (supportsTransactions) graph.tx().rollback();
+        try {
+            final long count = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username).sideEffect(drop()).count().next();
+            if (supportsTransactions) graph.tx().commit();
+            return count;
+        } catch (Exception ex) {
+            if (supportsTransactions) graph.tx().rollback();
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Get a count of the number of users in the database.
+     */
+    public long countUsers() {
+        if (supportsTransactions) graph.tx().rollback();
+        return g.V().hasLabel(CredentialGraphTokens.VERTEX_LABEL_USER).count().next();
+    }
+
+    @Override
+    public String toString() {
+        return "CredentialGraph{" +
+                "graph=" + graph +
+                '}';
+    }
+
+    /**
+     * Wrap up any {@link Graph} instance in the {@code CredentialGraph} DSL.
+     */
+    public static CredentialGraph credentials(final Graph graph) {
+        return new CredentialGraph(graph);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
new file mode 100644
index 0000000..7b6bd64
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
+
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+/**
+ * Plugin for the "credentials graph".  This plugin imports the {@link CredentialGraph} to its environment.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.credentials";
+
+    private static final ImportCustomizer imports;
+
+    static {
+        try {
+            imports = DefaultImportCustomizer.build()
+                    .addClassImports(CredentialGraph.class)
+                    .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class))
+                    .create();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public CredentialGraphGremlinPlugin() {
+        super(NAME, imports);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java
new file mode 100644
index 0000000..ac16302
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class CredentialGraphTokens {
+    public static final String PROPERTY_USERNAME = "username";
+    public static final String PROPERTY_PASSWORD = "password";
+
+    public static final String VERTEX_LABEL_USER = "user";
+
+    private CredentialGraphTokens() {}
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java
index 8c0277c..6a90587 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java
@@ -32,7 +32,9 @@ import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.drop;
  * {@link Graph} is transactional, new transactions will be started for each method call.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph}.
  */
+@Deprecated
 public class CredentialGraph {
 
     private final int BCRYPT_ROUNDS = 4;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java
index 0cb2543..1f0d8cf 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java
@@ -20,7 +20,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens}.
  */
+@Deprecated
 public final class CredentialGraphTokens {
     public static final String PROPERTY_USERNAME = "username";
     public static final String PROPERTY_PASSWORD = "password";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
deleted file mode 100644
index 761567b..0000000
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java
+++ /dev/null
@@ -1,55 +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.
- */
-package org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.jsr223;
-
-import org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph;
-import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
-import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
-import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Plugin for the "credentials graph".  This plugin imports the {@link CredentialGraph} to its environment.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin {
-
-    private static final String NAME = "tinkerpop.credentials";
-
-    private static final ImportCustomizer imports;
-
-    static {
-        try {
-            imports = DefaultImportCustomizer.build()
-                    .addClassImports(CredentialGraph.class)
-                    .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class))
-                    .create();
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    public CredentialGraphGremlinPlugin() {
-        super(NAME, imports);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
index 0004a80..251250b 100644
--- a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
+++ b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -1,2 +1,2 @@
 org.apache.tinkerpop.gremlin.groovy.jsr223.SugarGremlinPlugin
-org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.jsr223.CredentialGraphGremlinPlugin
\ No newline at end of file
+org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphGremlinPlugin
\ No newline at end of file


[49/50] tinkerpop git commit: TINKERPOP-1490 Deprecated the old RemoteConnection submit method.

Posted by sp...@apache.org.
TINKERPOP-1490 Deprecated the old RemoteConnection submit method.

That method isn't called at all anymore - needs to be removed completely for 3.3.x.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 21663f400e9a808b136ef6384a2ad694c20f5da4
Parents: f4bc29c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 14 10:08:48 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:14:20 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21663f40/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index ef3a0a9..d6415de 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -165,7 +165,7 @@ public class DriverRemoteConnection implements RemoteConnection {
     }
 
     /**
-     * @deprecated As of release 3.2.2, replaced by {@link #submit(Bytecode)}.
+     * @deprecated As of release 3.2.2, replaced by {@link #submitAsync(Bytecode)}.
      */
     @Deprecated
     @Override


[27/50] tinkerpop git commit: TINKERPOP-1562 Moved CoreImports to jsr223 package.

Posted by sp...@apache.org.
TINKERPOP-1562 Moved CoreImports to jsr223 package.


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

Branch: refs/heads/TINKERPOP-1490
Commit: c2e71dc06279bb708111c264f33507f927f06b4d
Parents: a82c56f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 1 06:40:59 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 .../gremlin/jsr223/CoreGremlinModule.java       |   2 -
 .../gremlin/jsr223/CoreGremlinPlugin.java       |   2 -
 .../tinkerpop/gremlin/jsr223/CoreImports.java   | 250 +++++++++++++++++++
 .../DefaultGremlinScriptEngineManager.java      |   2 -
 .../gremlin/jsr223/ImportCustomizer.java        |   2 -
 .../tinkerpop/gremlin/util/CoreImports.java     |   1 +
 .../python/TraversalSourceGenerator.groovy      |   2 +-
 .../jsr223/GremlinJythonScriptEngine.java       |   2 +-
 8 files changed, 253 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
index d398f89..369e171 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.CoreImports;
-
 import java.util.Optional;
 
 /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
index a3063cf..8882e36 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinPlugin.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.CoreImports;
-
 import java.util.Optional;
 
 /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
new file mode 100644
index 0000000..2244ae9
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
@@ -0,0 +1,250 @@
+/*
+ *  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.
+ */
+
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.computer.ComputerResult;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkDumperVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.bulkloading.BulkLoaderVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.optimization.GraphFilterStrategy;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.Bindings;
+import org.apache.tinkerpop.gremlin.process.traversal.Operator;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Pop;
+import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Translator;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConnectiveStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.MatchPredicateStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.OrderLimitStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RangeByIsCountStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
+import org.apache.tinkerpop.gremlin.structure.Column;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.Io;
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.structure.io.Storage;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.apache.tinkerpop.gremlin.util.Gremlin;
+import org.apache.tinkerpop.gremlin.util.TimeUtil;
+import org.javatuples.Pair;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Stream;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class CoreImports {
+
+    private final static Set<Class> CLASS_IMPORTS = new HashSet<>();
+    private final static Set<Method> METHOD_IMPORTS = new HashSet<>();
+    private final static Set<Enum> ENUM_IMPORTS = new HashSet<>();
+
+    static {
+        /////////////
+        // CLASSES //
+        /////////////
+
+        // graph
+        CLASS_IMPORTS.add(Edge.class);
+        CLASS_IMPORTS.add(Element.class);
+        CLASS_IMPORTS.add(Graph.class);
+        CLASS_IMPORTS.add(Property.class);
+        CLASS_IMPORTS.add(Transaction.class);
+        CLASS_IMPORTS.add(Vertex.class);
+        CLASS_IMPORTS.add(VertexProperty.class);
+        // tokens
+        CLASS_IMPORTS.add(SackFunctions.class);
+        CLASS_IMPORTS.add(SackFunctions.Barrier.class);
+        CLASS_IMPORTS.add(VertexProperty.Cardinality.class);
+        CLASS_IMPORTS.add(Column.class);
+        CLASS_IMPORTS.add(Direction.class);
+        CLASS_IMPORTS.add(Operator.class);
+        CLASS_IMPORTS.add(Order.class);
+        CLASS_IMPORTS.add(Pop.class);
+        CLASS_IMPORTS.add(Scope.class);
+        CLASS_IMPORTS.add(T.class);
+        CLASS_IMPORTS.add(TraversalOptionParent.class);
+        CLASS_IMPORTS.add(TraversalOptionParent.Pick.class);
+        CLASS_IMPORTS.add(P.class);
+        // remote
+        CLASS_IMPORTS.add(RemoteConnection.class);
+        CLASS_IMPORTS.add(RemoteGraph.class);
+        CLASS_IMPORTS.add(EmptyGraph.class);
+        // io
+        CLASS_IMPORTS.add(GraphReader.class);
+        CLASS_IMPORTS.add(GraphWriter.class);
+        CLASS_IMPORTS.add(Io.class);
+        CLASS_IMPORTS.add(IoCore.class);
+        CLASS_IMPORTS.add(Storage.class);
+        CLASS_IMPORTS.add(Configuration.class);
+        // strategies
+        CLASS_IMPORTS.add(ConnectiveStrategy.class);
+        CLASS_IMPORTS.add(ElementIdStrategy.class);
+        CLASS_IMPORTS.add(EventStrategy.class);
+        CLASS_IMPORTS.add(HaltedTraverserStrategy.class);
+        CLASS_IMPORTS.add(PartitionStrategy.class);
+        CLASS_IMPORTS.add(SubgraphStrategy.class);
+        CLASS_IMPORTS.add(LazyBarrierStrategy.class);
+        CLASS_IMPORTS.add(MatchAlgorithmStrategy.class);
+        CLASS_IMPORTS.add(ProfileStrategy.class);
+        CLASS_IMPORTS.add(AdjacentToIncidentStrategy.class);
+        CLASS_IMPORTS.add(FilterRankingStrategy.class);
+        CLASS_IMPORTS.add(IdentityRemovalStrategy.class);
+        CLASS_IMPORTS.add(IncidentToAdjacentStrategy.class);
+        CLASS_IMPORTS.add(MatchPredicateStrategy.class);
+        CLASS_IMPORTS.add(OrderLimitStrategy.class);
+        CLASS_IMPORTS.add(PathProcessorStrategy.class);
+        CLASS_IMPORTS.add(RangeByIsCountStrategy.class);
+        CLASS_IMPORTS.add(ComputerVerificationStrategy.class);
+        CLASS_IMPORTS.add(LambdaRestrictionStrategy.class);
+        CLASS_IMPORTS.add(ReadOnlyStrategy.class);
+        CLASS_IMPORTS.add(StandardVerificationStrategy.class);
+        // graph traversal
+        CLASS_IMPORTS.add(__.class);
+        CLASS_IMPORTS.add(GraphTraversal.class);
+        CLASS_IMPORTS.add(GraphTraversalSource.class);
+        CLASS_IMPORTS.add(TraversalMetrics.class);
+        CLASS_IMPORTS.add(Translator.class);
+        CLASS_IMPORTS.add(Bindings.class);
+        // graph computer
+        CLASS_IMPORTS.add(Computer.class);
+        CLASS_IMPORTS.add(ComputerResult.class);
+        CLASS_IMPORTS.add(GraphComputer.class);
+        CLASS_IMPORTS.add(Memory.class);
+        CLASS_IMPORTS.add(VertexProgram.class);
+        CLASS_IMPORTS.add(BulkDumperVertexProgram.class);
+        CLASS_IMPORTS.add(BulkLoaderVertexProgram.class);
+        CLASS_IMPORTS.add(PeerPressureVertexProgram.class);
+        CLASS_IMPORTS.add(PageRankVertexProgram.class);
+        CLASS_IMPORTS.add(GraphFilterStrategy.class);
+        CLASS_IMPORTS.add(VertexProgramStrategy.class);
+        // utils
+        CLASS_IMPORTS.add(Gremlin.class);
+        CLASS_IMPORTS.add(TimeUtil.class);
+
+        /////////////
+        // METHODS //
+        /////////////
+
+        uniqueMethods(IoCore.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(P.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(__.class).filter(m -> !m.getName().equals("__")).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(Computer.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(TimeUtil.class).forEach(METHOD_IMPORTS::add);
+
+        ///////////
+        // ENUMS //
+        ///////////
+
+        Collections.addAll(ENUM_IMPORTS, SackFunctions.Barrier.values());
+        Collections.addAll(ENUM_IMPORTS, VertexProperty.Cardinality.values());
+        Collections.addAll(ENUM_IMPORTS, Column.values());
+        Collections.addAll(ENUM_IMPORTS, Direction.values());
+        Collections.addAll(ENUM_IMPORTS, Operator.values());
+        Collections.addAll(ENUM_IMPORTS, Order.values());
+        Collections.addAll(ENUM_IMPORTS, Pop.values());
+        Collections.addAll(ENUM_IMPORTS, Scope.values());
+        Collections.addAll(ENUM_IMPORTS, T.values());
+        Collections.addAll(ENUM_IMPORTS, TraversalOptionParent.Pick.values());
+    }
+
+    private CoreImports() {
+        // static methods only, do not instantiate class
+    }
+
+    public static Set<Class> getClassImports() {
+        return Collections.unmodifiableSet(CLASS_IMPORTS);
+    }
+
+    public static Set<Method> getMethodImports() {
+        return Collections.unmodifiableSet(METHOD_IMPORTS);
+    }
+
+    public static Set<Enum> getEnumImports() {
+        return Collections.unmodifiableSet(ENUM_IMPORTS);
+    }
+
+    /**
+     * Filters to unique method names on each class.
+     */
+    private static Stream<Method> uniqueMethods(final Class<?> clazz) {
+        final Set<String> unique = new HashSet<>();
+        return Stream.of(clazz.getMethods())
+                .filter(m -> Modifier.isStatic(m.getModifiers()))
+                .map(m -> Pair.with(generateMethodDescriptor(m), m))
+                .filter(p -> {
+                    final boolean exists = unique.contains(p.getValue0());
+                    if (!exists) unique.add(p.getValue0());
+                    return !exists;
+                })
+                .map(Pair::getValue1);
+    }
+
+    private static String generateMethodDescriptor(final Method m) {
+        return m.getDeclaringClass().getCanonicalName() + "." + m.getName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
index 34ef995..86b72f2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.CoreImports;
-
 import javax.script.Bindings;
 import javax.script.ScriptContext;
 import java.security.AccessController;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
index 7b056ff..54c5d0c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.CoreImports;
-
 import java.lang.reflect.Method;
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
index 1c6a6e6..d5ec418 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
@@ -96,6 +96,7 @@ import java.util.stream.Stream;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.CoreImports}.
  */
 public final class CoreImports {
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index b6f25e3..73ffcb6 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -19,9 +19,9 @@
 
 package org.apache.tinkerpop.gremlin.python
 
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports
 import org.apache.tinkerpop.gremlin.process.traversal.P
 import org.apache.tinkerpop.gremlin.python.jsr223.SymbolHelper
-import org.apache.tinkerpop.gremlin.util.CoreImports
 
 import java.lang.reflect.Modifier
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c2e71dc0/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
index 1a4b57a..f6ada6e 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -20,6 +20,7 @@
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
 import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports;
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
@@ -28,7 +29,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.util.CoreImports;
 import org.python.jsr223.PyScriptEngine;
 import org.python.jsr223.PyScriptEngineFactory;
 


[26/50] tinkerpop git commit: TINKERPOP-1562 Moved ScriptEngineCache to jsr223 package.

Posted by sp...@apache.org.
TINKERPOP-1562 Moved ScriptEngineCache to jsr223 package.


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

Branch: refs/heads/TINKERPOP-1490
Commit: ae45eca70de741a1a1872117e9f4f7dc3ddd6245
Parents: c2e71dc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 1 06:48:22 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 .../gremlin/jsr223/ScriptEngineCache.java       | 54 ++++++++++++++++++++
 .../gremlin/util/ScriptEngineCache.java         |  4 +-
 .../gremlin/jsr223/ScriptEngineCacheTest.java   | 46 +++++++++++++++++
 .../python/jsr223/JythonScriptEngineSetup.java  |  2 +-
 .../python/jsr223/JythonTranslatorTest.java     | 10 ----
 .../jsr223/PythonGraphSONJavaTranslator.java    |  2 +-
 .../gremlin/python/jsr223/PythonProvider.java   |  5 +-
 7 files changed, 106 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCache.java
new file mode 100644
index 0000000..9d2848d
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCache.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A cache of standard {@code ScriptEngine} instances, instantiated by the standard {@code ScriptEngineManager}.
+ * These instances are NOT "Gremlin-enabled". See {@link SingleGremlinScriptEngineManager} for the analogous class
+ * that loads {@link GremlinScriptEngine} instances.
+ *
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class ScriptEngineCache {
+
+    private ScriptEngineCache() {}
+
+    public final static String DEFAULT_SCRIPT_ENGINE = "gremlin-groovy";
+
+    private final static ScriptEngineManager SCRIPT_ENGINE_MANAGER = new ScriptEngineManager();
+    private final static Map<String, ScriptEngine> CACHED_ENGINES = new ConcurrentHashMap<>();
+
+    public static ScriptEngine get(final String engineName) {
+        return CACHED_ENGINES.compute(engineName, (key, engine) -> {
+            if (null == engine) {
+                engine = SCRIPT_ENGINE_MANAGER.getEngineByName(engineName);
+                if (null == engine) {
+                    throw new IllegalArgumentException("There is no script engine with provided name: " + engineName);
+                }
+            }
+            return engine;
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/ScriptEngineCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/ScriptEngineCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/ScriptEngineCache.java
index 1ce7d05..dc4aeb7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/ScriptEngineCache.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/ScriptEngineCache.java
@@ -28,12 +28,14 @@ import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * A cache of standard {@code ScriptEngine} instances, instantiated by the standard {@code ScriptEngineManager}.
- * These instances are not "Gremlin-enabled". See {@link SingleGremlinScriptEngineManager} for the analogous class
+ * These instances are NOT "Gremlin-enabled". See {@link SingleGremlinScriptEngineManager} for the analogous class
  * that loads {@link GremlinScriptEngine} instances.
  *
  * @author Daniel Kuppitz (http://gremlin.guru)
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.ScriptEngineCache}.
  */
+@Deprecated
 public final class ScriptEngineCache {
 
     private ScriptEngineCache() {}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCacheTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCacheTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCacheTest.java
new file mode 100644
index 0000000..7cdbdc2
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/ScriptEngineCacheTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.junit.Test;
+
+import static org.junit.Assert.assertSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ScriptEngineCacheTest {
+
+    @Test
+    public void shouldBeUtilityClass() throws Exception {
+        TestHelper.assertIsUtilityClass(ScriptEngineCache.class);
+    }
+
+    @Test
+    public void shouldGetEngineFromCache() {
+        assertSame(ScriptEngineCache.get("nashorn"), ScriptEngineCache.get("nashorn"));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shouldThrowWhenScripEngineDoesNotExist() {
+        ScriptEngineCache.get("junk-that-no-one-would-ever-call-a-script-engine-83939473298432");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
index a16ce30..a4fe1ed 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
@@ -19,7 +19,7 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptEngineCache;
 import org.python.jsr223.PyScriptEngine;
 
 import javax.script.ScriptException;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonTranslatorTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonTranslatorTest.java
index 8bd3265..5a6e30d 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonTranslatorTest.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonTranslatorTest.java
@@ -19,26 +19,16 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
-import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
 import org.apache.tinkerpop.gremlin.util.function.Lambda;
 import org.junit.Test;
 
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
index cdeb407..740fe1f 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
@@ -20,6 +20,7 @@
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
 import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptEngineCache;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Translator;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
@@ -28,7 +29,6 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV2d0;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
 
 import javax.script.Bindings;
 import javax.script.ScriptContext;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae45eca7/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index fe04156..9e03884 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -23,12 +23,10 @@ import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.AbstractGraphProvider;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptEngineCache;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.PageRankTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.PeerPressureTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
@@ -42,7 +40,6 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
 
 import javax.script.ScriptException;
 import java.util.Arrays;


[41/50] tinkerpop git commit: TINKERPOP-1490 Cleaned up documentation based on latest changes to promise API

Posted by sp...@apache.org.
TINKERPOP-1490 Cleaned up documentation based on latest changes to promise API


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

Branch: refs/heads/TINKERPOP-1490
Commit: 81fa7e0e19ad337d764f6bcb7c36c286ca33396d
Parents: 42e8588
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 14 06:38:18 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                 | 2 +-
 docs/src/upgrade/release-3.2.x-incubating.asciidoc | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81fa7e0e/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 24c75a7..b637552 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -52,7 +52,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Factored `GremlinPlugin` functionality out of gremlin-groovy and into gremlin-core - related classes were deprecated.
 * Added a `force` option for killing sessions without waiting for transaction close or timeout of a currently running job or multiple jobs.
 * Deprecated `Session.kill()` and `Session.manualKill()`.
-* Added `Traversal.promise()` methods to allow for asynchronous traversal processing.
+* Added `Traversal.promise()` method to allow for asynchronous traversal processing on "remote" traversals.
 * Added `choose(predicate,traversal)` and `choose(traversal,traversal)` to effect if/then-semantics (no else). Equivalent to `choose(x,y,identity())`.
 * Removed `ImmutablePath.TailPath` as it is no longer required with new recursion model.
 * Removed call stack recursion in `ImmutablePath`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81fa7e0e/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 34ff427..428b0c6 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -35,7 +35,7 @@ Upgrading for Users
 Traversal Promises
 ^^^^^^^^^^^^^^^^^^
 
-The `Traversal` API now has two `promise()` method overloads. These methods return a promise in the form of a
+The `Traversal` API now has a new `promise()` method. These methods return a promise in the form of a
 `CompleteableFuture`. Usage is as follows:
 
 [source,groovy]
@@ -50,6 +50,8 @@ gremlin> g.V().out().promise{it.toList()}.thenApply{it.size()}.get()
 ==>6
 ----
 
+At this time, this method is only used for traversals that are configured using `withRemote()`.
+
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1490[TINKERPOP-1490]
 
 If/Then-Semantics with Choose Step


[12/50] tinkerpop git commit: TINKERPOP-1562 Fixed a bad javadoc link

Posted by sp...@apache.org.
TINKERPOP-1562 Fixed a bad javadoc link


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

Branch: refs/heads/TINKERPOP-1490
Commit: 6d1b97e0bb3f5567900124d3a549c066b7ff3605
Parents: 9218e8a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 30 06:37:14 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d1b97e0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
index ab4c81d..9571b2c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
@@ -28,8 +28,9 @@ import java.util.Map;
  * A "remote connection" does not necessarily have to be a remote server.  It simply refers to a resource that is
  * external to the console.
  * <p/>
- * By implementing this interface and returning an instance of it through {@link ConsoleCustomizer#getRemoteAcceptor(Map)}
- * a plugin can hook into those commands and provide remoting features.
+ * By implementing this interface and returning an instance of it through
+ * {@link ConsoleCustomizer#getRemoteAcceptor(GremlinShellEnvironment)} a plugin can hook into those commands and
+ * provide remoting features.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */


[24/50] tinkerpop git commit: TINKERPOP-1562 Deprecated GremlinGroovyScriptEngine.close()

Posted by sp...@apache.org.
TINKERPOP-1562 Deprecated GremlinGroovyScriptEngine.close()

In the future GremlinGroovyScriptEngine will not implement AutoCloseable - there was never really a need for that.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 338002ab79b7f651885ffd950f64f5d34655f0ef
Parents: d68f693
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 1 10:15:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 .../gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java        | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/338002ab/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index 0f36dbf..1fb2efc 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -384,7 +384,12 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
         return (Traversal.Admin) this.eval(GroovyTranslator.of(traversalSource).translate(bytecode), bindings);
     }
 
+    /**
+     * @deprecated As of release 3.2.4, not replaced as this class will not implement {@code AutoCloseable} in the
+     * future.
+     */
     @Override
+    @Deprecated
     public void close() throws Exception {
     }
 


[03/50] tinkerpop git commit: TINKERPOP-1562 Add new HadoopGremlinPlugin and deprecated the old.

Posted by sp...@apache.org.
TINKERPOP-1562 Add new HadoopGremlinPlugin and deprecated the old.

Had to add some capabilities to plugin system to allow for passing of console environment bits (like groovysh for example).


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

Branch: refs/heads/TINKERPOP-1490
Commit: d0c941e86ccd561576552cdda9c58424462def9d
Parents: 2e65a11
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 22 13:41:58 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../gremlin/console/plugin/PluggedIn.groovy     |   2 +-
 .../gremlin/jsr223/LazyBindingsCustomizer.java  |  41 +++++
 .../jsr223/console/ConsoleCustomizer.java       |   7 +-
 .../jsr223/console/LazyBindingsCustomizer.java  |  41 -----
 .../gremlin/jsr223/console/RemoteAcceptor.java  |   3 +-
 .../gremlin/groovy/plugin/PluginAcceptor.java   |   2 +-
 .../groovy/plugin/HadoopGremlinPlugin.java      |   2 +
 .../groovy/plugin/HadoopRemoteAcceptor.java     |   2 +
 .../hadoop/jsr223/HadoopGremlinPlugin.java      | 154 +++++++++++++++++++
 .../hadoop/jsr223/HadoopRemoteAcceptor.java     | 127 +++++++++++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   1 +
 .../neo4j/groovy/plugin/Neo4jGremlinPlugin.java |   1 +
 .../spark/jsr223/SparkGremlinPlugin.java        |   2 +-
 13 files changed, 339 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
index b707226..dc63a2f 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
@@ -90,7 +90,7 @@ class PluggedIn {
                 } else if (it instanceof ScriptCustomizer) {
                     it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { pluginAcceptor.eval(it) }
                 } else if (it instanceof BindingsCustomizer) {
-                    it.bindings.entrySet().each { k, v -> pluginAcceptor.addBinding(k,v) }
+                    it.bindings.entrySet().each { kv -> pluginAcceptor.addBinding(kv.key, kv.value) }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
new file mode 100644
index 0000000..4117ae5
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/LazyBindingsCustomizer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
+
+import javax.script.Bindings;
+import java.util.function.Supplier;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class LazyBindingsCustomizer implements BindingsCustomizer {
+
+    private final Supplier<Bindings> bindingsSupplier;
+
+    public LazyBindingsCustomizer(final Supplier<Bindings> bindingsSupplier) {
+        this.bindingsSupplier = bindingsSupplier;
+    }
+
+    @Override
+    public Bindings getBindings() {
+        return bindingsSupplier.get();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
index 47771bc..7b3d788 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
@@ -20,14 +20,19 @@ package org.apache.tinkerpop.gremlin.jsr223.console;
 
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 
+import java.util.Map;
+
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface ConsoleCustomizer extends Customizer {
+    public static final String ENV_CONSOLE_IO = "ConsolePluginAcceptor.io";
+    public static final String ENV_CONSOLE_SHELL = "ConsolePluginAcceptor.shell";
+
     /**
      * Allows a plugin to utilize features of the {@code :remote} and {@code :submit} commands of the Gremlin Console.
      * This method does not need to be implemented if the plugin is not meant for the Console for some reason or
      * if it does not intend to take advantage of those commands.
      */
-    public RemoteAcceptor getRemoteAcceptor();
+    public RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment);
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java
deleted file mode 100644
index f21a2ab..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java
+++ /dev/null
@@ -1,41 +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.
- */
-package org.apache.tinkerpop.gremlin.jsr223.console;
-
-import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
-
-import javax.script.Bindings;
-import java.util.function.Supplier;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class LazyBindingsCustomizer implements BindingsCustomizer {
-
-    private final Supplier<Bindings> bindingsSupplier;
-
-    public LazyBindingsCustomizer(final Supplier<Bindings> bindingsSupplier) {
-        this.bindingsSupplier = bindingsSupplier;
-    }
-
-    @Override
-    public Bindings getBindings() {
-        return bindingsSupplier.get();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
index aee77ae..ab4c81d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.jsr223.console;
 
 import java.io.Closeable;
 import java.util.List;
+import java.util.Map;
 
 /**
  * The Gremlin Console supports the {@code :remote} and {@code :submit} commands which provide standardized ways
@@ -27,7 +28,7 @@ import java.util.List;
  * A "remote connection" does not necessarily have to be a remote server.  It simply refers to a resource that is
  * external to the console.
  * <p/>
- * By implementing this interface and returning an instance of it through {@link ConsoleCustomizer#getRemoteAcceptor()}
+ * By implementing this interface and returning an instance of it through {@link ConsoleCustomizer#getRemoteAcceptor(Map)}
  * a plugin can hook into those commands and provide remoting features.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java
index 9571381..9165237 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java
@@ -31,7 +31,7 @@ import java.util.Set;
  * and provides the abstractions required for a plugin to work regardless of the environmental implementations.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.PluginAcceptor}.
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor}.
  */
 @Deprecated
 public interface PluginAcceptor {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
index 021f9d3..ca446ef 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
@@ -43,7 +43,9 @@ import java.util.Set;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPlugin}.
  */
+@Deprecated
 public final class HadoopGremlinPlugin extends AbstractGremlinPlugin {
 
     protected static String NAME = "tinkerpop.hadoop";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
index 558376e..acae442 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java
@@ -39,7 +39,9 @@ import java.util.List;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopRemoteAcceptor}.
  */
+@Deprecated
 public final class HadoopRemoteAcceptor implements RemoteAcceptor {
 
     private static final String USE_SUGAR = "useSugar";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
new file mode 100644
index 0000000..5e21027
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.hadoop.jsr223;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.io.compress.CodecPool;
+import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.mapreduce.MapReduceGraphComputer;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopConfiguration;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopEdge;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopElement;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopProperty;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopVertex;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopVertexProperty;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorage;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONRecordReader;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONRecordWriter;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoRecordReader;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoRecordWriter;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.LazyBindingsCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
+import org.codehaus.groovy.tools.shell.Groovysh;
+
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HadoopGremlinPlugin extends AbstractGremlinPlugin {
+
+    protected static String NAME = "tinkerpop.hadoop";
+
+    private static final BindingsCustomizer bindings;
+
+    private static final ImportCustomizer imports;
+
+    private static final Set<String> appliesTo = new HashSet<>(Collections.singletonList("gremlin-groovy"));
+
+    static {
+        try {
+            // TODO: most of the imports here were wildcarded, but we dont' allow that anymore - needs review
+            imports = DefaultImportCustomizer.build()
+                    .addClassImports(
+                            Configuration.class,
+                            org.apache.hadoop.hdfs.DFSClient.class,
+                            FileSystem.class,
+                            ToolRunner.class,
+                            IOUtils.class,
+                            CodecPool.class,
+                            SequenceFileInputFormat.class,
+                            SequenceFileOutputFormat.class,
+                            Constants.class,
+                            HadoopConfiguration.class,
+                            HadoopEdge.class,
+                            HadoopElement.class,
+                            HadoopGraph.class,
+                            HadoopProperty.class,
+                            HadoopVertex.class,
+                            HadoopVertexProperty.class,
+                            ConfUtil.class,
+                            VertexWritable.class,
+                            GraphSONInputFormat.class,
+                            GraphSONOutputFormat.class,
+                            GraphSONRecordReader.class,
+                            GraphSONRecordWriter.class,
+                            GryoInputFormat.class,
+                            GryoOutputFormat.class,
+                            GryoRecordReader.class,
+                            GryoRecordWriter.class,
+                            ScriptInputFormat.class,
+                            MapReduceGraphComputer.class).create();
+
+            bindings = new LazyBindingsCustomizer(() -> {
+                try {
+                    final Bindings bindings = new SimpleBindings();
+                    bindings.put("hdfs", FileSystemStorage.open(FileSystem.get(new Configuration())));
+                    bindings.put("fs", FileSystemStorage.open(FileSystem.getLocal(new Configuration())));
+                    return bindings;
+                } catch (Exception ex) {
+                    throw new RuntimeException(ex);
+                }
+            });
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public HadoopGremlinPlugin() {
+        super(NAME, appliesTo, imports, bindings, new HadoopConsoleCustomizer());
+    }
+
+    @Override
+    public Optional<Customizer[]> getCustomizers(final String scriptEngineName) {
+        if (null == System.getenv(Constants.HADOOP_GREMLIN_LIBS))
+            HadoopGraph.LOGGER.warn("Be sure to set the environmental variable: " + Constants.HADOOP_GREMLIN_LIBS);
+        else
+            HadoopGraph.LOGGER.info(Constants.HADOOP_GREMLIN_LIBS + " is set to: " + System.getenv(Constants.HADOOP_GREMLIN_LIBS));
+
+        return super.getCustomizers(scriptEngineName);
+    }
+
+    @Override
+    public boolean requireRestart() {
+        return true;
+    }
+
+    private static class HadoopConsoleCustomizer implements ConsoleCustomizer {
+        @Override
+        public RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
+            return new HadoopRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
new file mode 100644
index 0000000..f2367bd
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopRemoteAcceptor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.hadoop.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
+import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph;
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException;
+import org.apache.tinkerpop.gremlin.process.computer.ComputerResult;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ComputerResultStep;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
+import org.codehaus.groovy.tools.shell.Groovysh;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HadoopRemoteAcceptor implements RemoteAcceptor {
+
+    private static final String USE_SUGAR = "useSugar";
+    private static final String USE_TRAVERSAL_SOURCE = "useTraversalSource";
+    private static final String SPACE = " ";
+
+    private HadoopGraph hadoopGraph;
+    private Groovysh shell;
+    private boolean useSugar = false;
+    private TraversalSource traversalSource;
+
+    public HadoopRemoteAcceptor(final Groovysh shell) {
+        this.shell = shell;
+    }
+
+    @Override
+    public Object connect(final List<String> args) throws RemoteException {
+        if (args.size() != 1 && args.size() != 2) {
+            throw new IllegalArgumentException("Usage: :remote connect " + HadoopGremlinPlugin.NAME + " <variable name of graph> <optional variable name of traversal source>");
+        }
+        this.hadoopGraph = (HadoopGraph) this.shell.getInterp().getContext().getVariable(args.get(0));
+        if (args.size() == 2)
+            this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(1)));
+        else
+            this.traversalSource = this.hadoopGraph.traversal();
+        ///
+        final HashMap<String, Object> configuration = new HashMap<>();
+        configuration.put(USE_SUGAR, this.useSugar);
+        configuration.put(USE_TRAVERSAL_SOURCE, this.traversalSource);
+        return Collections.unmodifiableMap(configuration);
+    }
+
+    @Override
+    public Object configure(final List<String> args) throws RemoteException {
+        for (int i = 0; i < args.size(); i = i + 2) {
+            if (args.get(i).equals(USE_SUGAR))
+                this.useSugar = Boolean.valueOf(args.get(i + 1));
+            else if (args.get(i).equals(USE_TRAVERSAL_SOURCE)) {
+                this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(i + 1)));
+            } else
+                throw new IllegalArgumentException("The provided configuration is unknown: " + args.get(i) + ":" + args.get(i + 1));
+        }
+        ///
+        final HashMap<String, Object> configuration = new HashMap<>();
+        configuration.put(USE_SUGAR, this.useSugar);
+        configuration.put(USE_TRAVERSAL_SOURCE, this.traversalSource);
+        return Collections.unmodifiableMap(configuration);
+    }
+
+    @Override
+    public Object submit(final List<String> args) throws RemoteException {
+        try {
+            String script = getScript(String.join(SPACE, args), this.shell);
+            if (this.useSugar)
+                script = SugarLoader.class.getCanonicalName() + ".load()\n" + script;
+            final TraversalVertexProgram program = TraversalVertexProgram.build().traversal(this.traversalSource, "gremlin-groovy", script).create(this.hadoopGraph);
+            final ComputerResult computerResult = VertexProgramStrategy.getComputer(this.traversalSource.getStrategies()).get().apply(this.hadoopGraph).program(program).submit().get();
+            this.shell.getInterp().getContext().setVariable(RESULT, computerResult);
+            ///
+            final Traversal.Admin<ComputerResult, ?> traversal = new DefaultTraversal<>(computerResult.graph());
+            traversal.addStep(new ComputerResultStep<>(traversal));
+            traversal.addStart(traversal.getTraverserGenerator().generate(computerResult, EmptyStep.instance(), 1l));
+            return traversal;
+        } catch (final Exception e) {
+            throw new RemoteException(e);
+        }
+    }
+
+    @Override
+    public boolean allowRemoteConsole() {
+        return true;
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.hadoopGraph.close();
+    }
+
+    /**
+     * Retrieve a script as defined in the shell context.  This allows for multi-line scripts to be submitted.
+     */
+    public static String getScript(final String submittedScript, final Groovysh shell) {
+        return submittedScript.startsWith("@") ? shell.getInterp().getContext().getProperty(submittedScript.substring(1)).toString() : submittedScript;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/hadoop-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/hadoop-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..07223dd
--- /dev/null
+++ b/hadoop-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1 @@
+org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPlugin
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
index 9053cf3..68c0016 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
@@ -32,6 +32,7 @@ import java.util.Set;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.neo4j.jsr223.Neo4jGremlinPlugin}.
  */
+@Deprecated
 public final class Neo4jGremlinPlugin extends AbstractGremlinPlugin {
 
     private static final Set<String> IMPORTS = new HashSet<String>() {{

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0c941e8/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java
index 840f593..9403fa4 100644
--- a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java
+++ b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
-import org.apache.tinkerpop.gremlin.jsr223.console.LazyBindingsCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.LazyBindingsCustomizer;
 import org.apache.tinkerpop.gremlin.spark.process.computer.CombineIterator;
 import org.apache.tinkerpop.gremlin.spark.process.computer.MapIterator;
 import org.apache.tinkerpop.gremlin.spark.process.computer.MemoryAccumulator;


[47/50] tinkerpop git commit: TINKERPOP-1490 Restructured Traversal.promise()

Posted by sp...@apache.org.
TINKERPOP-1490 Restructured Traversal.promise()

No longer uses an ExecutorService and is only applicable to "remote" traversals. Moved the commons-lang dependency back to gremlin-groovy for now.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 9bbf0252572201b305236b21f6d4fc60c4db2294
Parents: 6c4cbc8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Nov 11 12:51:40 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:12:08 2016 -0500

----------------------------------------------------------------------
 gremlin-core/pom.xml                            |  5 ---
 .../traversal/util/DefaultTraversal.java        | 37 -----------------
 .../driver/remote/DriverRemoteConnection.java   |  2 +-
 .../process/traversal/CoreTraversalTest.java    | 42 --------------------
 4 files changed, 1 insertion(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bbf0252/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index 0594448..e8f3a34 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -61,11 +61,6 @@ limitations under the License.
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.1</version>
-        </dependency>
         <!-- LOGGING -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bbf0252/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 6ce6dfe..3c21e37 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -43,9 +43,6 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Function;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -328,40 +325,6 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         this.graph = graph;
     }
 
-    /**
-     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions.
-     */
-    @Override
-    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction) {
-        return this.promise(traversalFunction, Traversal.Admin.traversalExecutorService);
-    }
-
-    /**
-     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions. In a transactional graph
-     * a promise represents the full scope of a transaction, even if the graph is only partially iterated.
-     */
-    @Override
-    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction, final ExecutorService service) {
-        if (graph != null && graph.features().graph().supportsTransactions()) {
-            final Function<Traversal, T2> transactionAware = traversal -> {
-
-                try {
-                    if (graph.tx().isOpen()) graph.tx().rollback();
-                    final T2 obj = traversalFunction.apply(traversal);
-                    if (graph.tx().isOpen()) graph.tx().commit();
-                    return obj;
-                } catch (Exception ex) {
-                    if (graph.tx().isOpen()) graph.tx().rollback();
-                    throw ex;
-                }
-            };
-
-            return Traversal.Admin.super.promise(transactionAware, service);
-        } else {
-            return Traversal.Admin.super.promise(traversalFunction, service);
-        }
-    }
-
     @Override
     public boolean equals(final Object other) {
         return other != null && other.getClass().equals(this.getClass()) && this.equals(((Traversal.Admin) other));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bbf0252/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index d6415de..ef3a0a9 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -165,7 +165,7 @@ public class DriverRemoteConnection implements RemoteConnection {
     }
 
     /**
-     * @deprecated As of release 3.2.2, replaced by {@link #submitAsync(Bytecode)}.
+     * @deprecated As of release 3.2.2, replaced by {@link #submit(Bytecode)}.
      */
     @Deprecated
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bbf0252/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
index 050f9de..68f8217 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
@@ -20,7 +20,6 @@ package org.apache.tinkerpop.gremlin.process.traversal;
 
 import org.apache.tinkerpop.gremlin.ExceptionCoverage;
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
-import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -41,9 +40,6 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
@@ -311,42 +307,4 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest {
         }
 
     }
-
-    @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
-    public void shouldUsePromiseAndControlTransactionsIfAvailable() throws Exception {
-        // this test will validate that transactional graphs can properly open/close transactions within a promise.
-        // as there is a feature check, non-transactional graphs can use this to simply exercise the promise API
-        final Vertex vAdded = g.addV("person").property("name", "stephen").promise(t -> (Vertex) t.next()).get(10000, TimeUnit.MILLISECONDS);
-        final Vertex vRead = g.V().has("name", "stephen").next();
-        assertEquals(vAdded.id(), vRead.id());
-
-        // transaction should have been committed at this point so test the count in this thread to validate persistence
-        assertVertexEdgeCounts(graph, 1, 0);
-
-        // cancel a promise and ensure the transaction ended in failure. hold the traversal in park until it can be
-        // interrupted, then the promise will have to rollback the transaction.
-        final CompletableFuture promiseToCancel = g.addV("person").property("name", "marko").sideEffect(traverser -> {
-            try {
-                Thread.sleep(100000);
-            } catch (Exception ignored) {
-
-            }
-        }).promise(t -> (Vertex) t.next());
-
-        try {
-            promiseToCancel.get(500, TimeUnit.MILLISECONDS);
-            fail("Should have timed out");
-        } catch (TimeoutException te) {
-
-        }
-
-        promiseToCancel.cancel(true);
-
-        // graphs that support transactions will rollback the transaction
-        if (graph.features().graph().supportsTransactions())
-            assertVertexEdgeCounts(graph, 1, 0);
-        else
-            assertVertexEdgeCounts(graph, 2, 0);
-    }
 }


[40/50] tinkerpop git commit: TINKERPOP-1490 Remove some dead tests from ignores.

Posted by sp...@apache.org.
TINKERPOP-1490 Remove some dead tests from ignores.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 42e858832c294e4cd38e15bdc7c43960217ae094
Parents: ee6a358
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Nov 11 13:39:40 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java  | 1 -
 .../process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java  | 1 -
 .../process/jsr223/TinkerGraphJavaTranslatorProvider.java           | 1 -
 3 files changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/42e85883/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index 5dd9c28..9e03884 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -69,7 +69,6 @@ public class PythonProvider extends AbstractGraphProvider {
             "shouldNeverPropagateANullValuedTraverser",
             "shouldHidePartitionKeyForValues",
             "g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/42e85883/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
index a595c34..dd118d7 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
@@ -51,7 +51,6 @@ public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider {
             "g_VX1X_out_injectXv2X_name",
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             GraphComputerTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/42e85883/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
index 15a6c0b..f40a8c7 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
@@ -49,7 +49,6 @@ public class TinkerGraphJavaTranslatorProvider extends TinkerGraphProvider {
             TraversalInterruptionComputerTest.class.getCanonicalName(),
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             ElementIdStrategyProcessTest.class.getCanonicalName(),
             EventStrategyProcessTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName()));


[30/50] tinkerpop git commit: TINKERPOP-1562 Add more imports on Hadoop plugin.

Posted by sp...@apache.org.
TINKERPOP-1562 Add more imports on Hadoop plugin.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 9f84ac43bb71aff47fe4cfbbd9be277361191359
Parents: aa4a70a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Dec 7 11:12:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Dec 7 11:12:49 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java   | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9f84ac43/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
index b7403b6..0c9c287 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java
@@ -45,6 +45,9 @@ import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoRecordReader;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoRecordWriter;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptRecordReader;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptRecordWriter;
 import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil;
 import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
@@ -108,6 +111,9 @@ public final class HadoopGremlinPlugin extends AbstractGremlinPlugin {
                             GryoRecordReader.class,
                             GryoRecordWriter.class,
                             ScriptInputFormat.class,
+                            ScriptOutputFormat.class,
+                            ScriptRecordReader.class,
+                            ScriptRecordWriter.class,
                             MapReduceGraphComputer.class).create();
 
             bindings = new LazyBindingsCustomizer(() -> {


[23/50] tinkerpop git commit: TINKERPOP-1562 Deprecated the DependencyManager.

Posted by sp...@apache.org.
TINKERPOP-1562 Deprecated the DependencyManager.

This interface really isn't useful anymore. It is bound to ScriptEngines class which is also deprecated. The new model of the GremlinScriptEngine in gremlin-core sorta makes this obsolete.


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

Branch: refs/heads/TINKERPOP-1490
Commit: aa4a70a47c9c7b400983fb2fd55730b686cceea9
Parents: 338002a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 1 10:19:40 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa4a70a4/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java
index 5c1b8fe..4f1384d 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.groovy.ImportCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin;
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPluginException;
 import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 
 import java.util.List;
 import java.util.Map;
@@ -33,7 +34,9 @@ import java.util.Set;
  * so this interface makes that possible to expose.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced - no longer needed under the new {@link GremlinScriptEngine} model.
  */
+@Deprecated
 public interface DependencyManager {
     /**
      * Take maven coordinates and load the classes into the classloader used by the ScriptEngine.  Those ScriptEngines


[11/50] tinkerpop git commit: TINKERPOP-1562 Added JSR-223 packages in gremin-core to core javadoc

Posted by sp...@apache.org.
TINKERPOP-1562 Added JSR-223 packages in gremin-core to core javadoc


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

Branch: refs/heads/TINKERPOP-1490
Commit: a2ac1f29613576b3bf409c0c766d3eae66d45780
Parents: 2efa2e4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 23 17:22:58 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:49 2016 -0500

----------------------------------------------------------------------
 pom.xml | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a2ac1f29/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 37c7c7e..3c5f8ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1060,7 +1060,7 @@ limitations under the License.
                                     <overview>${basedir}/docs/javadoc/overview.html</overview>
                                     <quiet>true</quiet>
                                     <sourcepath>
-                                        giraph-gremlin/src/main/java:gremlin-core/src/main/java:gremlin-driver/src/main/java:gremlin-groovy/src/main/java:gremlin-groovy-test/src/main/java:gremlin-server/src/main/java:gremlin-test/src/main/java:hadoop-gremlin/src/main/java:neo4j-gremlin/src/main/java:spark-gremlin/src/main/java:tinkergraph-gremlin/src/main/java
+                                        giraph-gremlin/src/main/java:gremlin-core/src/main/java:gremlin-driver/src/main/java:gremlin-groovy/src/main/java:gremlin-groovy-test/src/main/java:gremlin-python/src/main/java:gremlin-server/src/main/java:gremlin-test/src/main/java:hadoop-gremlin/src/main/java:neo4j-gremlin/src/main/java:spark-gremlin/src/main/java:tinkergraph-gremlin/src/main/java
                                     </sourcepath>
                                 </configuration>
                             </execution>
@@ -1080,11 +1080,20 @@ limitations under the License.
                                         gremlin-core/src/main/java:gremlin-driver/src/main/java
                                     </sourcepath>
                                     <sourceFileIncludes>
+                                        <!-- jsr223 -->
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/jsr223/*.java
+                                        </include>
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/jsr223/console/*.java
+                                        </include>
                                         <!-- structure -->
-                                        <include>org/apache/tinkerpop/gremlin/structure/*.java
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/structure/*.java
                                         </include>
                                         <!-- io -->
-                                        <include>org/apache/tinkerpop/gremlin/structure/io/*.java
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/structure/io/*.java
                                         </include>
                                         <include>
                                             org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
@@ -1105,7 +1114,8 @@ limitations under the License.
                                             org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
                                         </include>
                                         <!-- process -->
-                                        <include>org/apache/tinkerpop/gremlin/process/*.java
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/process/*.java
                                         </include>
                                         <!-- computer -->
                                         <include>org/apache/tinkerpop/gremlin/process/computer/*.java
@@ -1120,7 +1130,8 @@ limitations under the License.
                                             org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
                                         </include>
                                         <!-- traversal -->
-                                        <include>org/apache/tinkerpop/gremlin/process/traversal/*.java
+                                        <include>
+                                            org/apache/tinkerpop/gremlin/process/traversal/*.java
                                         </include>
                                         <include>
                                             org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java


[28/50] tinkerpop git commit: TINKERPOP-1562 Fixed the InstallCommand for new GremlinPlugin usage.

Posted by sp...@apache.org.
TINKERPOP-1562 Fixed the InstallCommand for new GremlinPlugin usage.

DependencyGrabber wasn't using the right Artifact implementation and wasn't taking into account -Dplugins=v3d3


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

Branch: refs/heads/TINKERPOP-1490
Commit: d68f69383464f8f54b98acecf99a39587f2e4839
Parents: ae45eca
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 1 08:25:19 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 .../gremlin/console/commands/InstallCommand.groovy    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d68f6938/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
index a680757..c8a49df 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
@@ -21,9 +21,9 @@ package org.apache.tinkerpop.gremlin.console.commands
 import org.apache.tinkerpop.gremlin.console.ConsoleFs
 import org.apache.tinkerpop.gremlin.console.Mediator
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn
-import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
 import groovy.grape.Grape
+import org.apache.tinkerpop.gremlin.groovy.util.Artifact
 import org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber
 import org.codehaus.groovy.tools.shell.CommandSupport
 import org.codehaus.groovy.tools.shell.Groovysh
@@ -64,9 +64,17 @@ class InstallCommand extends CommandSupport {
 
         // note that the service loader utilized the classloader from the groovy shell as shell class are available
         // from within there given loading through Grape.
-        ServiceLoader.load(GremlinPlugin.class, shell.getInterp().getClassLoader()).forEach { plugin ->
+        def pluginClass = mediator.useV3d3 ? org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin : GremlinPlugin
+        ServiceLoader.load(pluginClass, shell.getInterp().getClassLoader()).forEach { plugin ->
             if (!mediator.availablePlugins.containsKey(plugin.class.name)) {
-                mediator.availablePlugins.put(plugin.class.name, new PluggedIn(plugin, shell, io, false))
+
+                if (Mediator.useV3d3) {
+                    mediator.availablePlugins.put(plugin.class.name, new PluggedIn(new PluggedIn.GremlinPluginAdapter((org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin) plugin, shell, io), shell, io, false))
+                } else {
+                    mediator.availablePlugins.put(plugin.class.name, new PluggedIn((GremlinPlugin) plugin, shell, io, false))
+                }
+
+                //mediator.availablePlugins.put(plugin.class.name, new PluggedIn(plugin, shell, io, false))
                 if (plugin.requireRestart())
                     pluginsThatNeedRestart << plugin.name
             }


[39/50] tinkerpop git commit: TINKERPOP-1490 Implemented promise API for Traversal

Posted by sp...@apache.org.
TINKERPOP-1490 Implemented promise API for Traversal

Added two promise() methods that return CompletableFuture on Traversal. Provided an override on DefaultTraversal for those methods because the function that transforms the Traversal is executed in a different thread and therefore requires Graph transaction management (or else we would orphan transactions). Did not update gremlin-python with the promise API because it seemed to beg discussion on the "right" way to do that (i.e. what library to use to support promises?, just use futures from the core lib?, etc).


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

Branch: refs/heads/TINKERPOP-1490
Commit: eb089764acb91c24023353a2220e7c84febdec8d
Parents: 347a0a9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 1 09:30:28 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../upgrade/release-3.2.x-incubating.asciidoc   |  20 +
 gremlin-core/pom.xml                            |   5 +
 .../gremlin/process/traversal/Traversal.java    |  50 ++
 .../traversal/util/DefaultTraversal.java        |  37 ++
 .../process/traversal/TraversalTest.java        | 473 +++++++++++++++++++
 gremlin-groovy/pom.xml                          |   5 -
 .../gremlin/python/jsr223/PythonProvider.java   |   1 +
 .../process/traversal/CoreTraversalTest.java    |  42 ++
 .../TinkerGraphGroovyTranslatorProvider.java    |   1 +
 .../TinkerGraphJavaTranslatorProvider.java      |   1 +
 11 files changed, 631 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 8e01ce0..24c75a7 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -52,6 +52,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Factored `GremlinPlugin` functionality out of gremlin-groovy and into gremlin-core - related classes were deprecated.
 * Added a `force` option for killing sessions without waiting for transaction close or timeout of a currently running job or multiple jobs.
 * Deprecated `Session.kill()` and `Session.manualKill()`.
+* Added `Traversal.promise()` methods to allow for asynchronous traversal processing.
 * Added `choose(predicate,traversal)` and `choose(traversal,traversal)` to effect if/then-semantics (no else). Equivalent to `choose(x,y,identity())`.
 * Removed `ImmutablePath.TailPath` as it is no longer required with new recursion model.
 * Removed call stack recursion in `ImmutablePath`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 8a184b4..34ff427 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -32,6 +32,26 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.2.4/CHANGELOG.asc
 Upgrading for Users
 ~~~~~~~~~~~~~~~~~~~
 
+Traversal Promises
+^^^^^^^^^^^^^^^^^^
+
+The `Traversal` API now has two `promise()` method overloads. These methods return a promise in the form of a
+`CompleteableFuture`. Usage is as follows:
+
+[source,groovy]
+----
+gremlin> promise = g.V().out().promise{it.next()}
+==>java.util.concurrent.CompletableFuture@4aa3d36[Completed normally]
+gremlin> promise.join()
+==>v[3]
+gremlin> promise.isDone()
+==>true
+gremlin> g.V().out().promise{it.toList()}.thenApply{it.size()}.get()
+==>6
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1490[TINKERPOP-1490]
+
 If/Then-Semantics with Choose Step
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index e8f3a34..0594448 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -61,6 +61,11 @@ limitations under the License.
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
+        </dependency>
         <!-- LOGGING -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
index edc18e0..e4ba5a6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal;
 
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
@@ -42,7 +43,13 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.Spliterator;
 import java.util.Spliterators;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 import java.util.function.Consumer;
+import java.util.function.Function;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
@@ -140,6 +147,43 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
     }
 
     /**
+     * Starts a promise to execute a function on the current {@code Traversal} that will be completed in the future.
+     * This implementation uses {@link Admin#traversalExecutorService} to execute the supplied
+     * {@code traversalFunction}.
+     */
+    public default <T> CompletableFuture<T> promise(final Function<Traversal, T> traversalFunction) {
+        return promise(traversalFunction, Admin.traversalExecutorService);
+    }
+
+    /**
+     * Starts a promise to execute a function on the current {@code Traversal} that will be completed in the future.
+     * This implementation uses the caller supplied {@code ExecutorService} to execute the {@code traversalFunction}.
+     */
+    public default <T> CompletableFuture<T> promise(final Function<Traversal, T> traversalFunction, final ExecutorService service) {
+        final CompletableFuture<T> promise = new CompletableFuture<>();
+        final Future iterationFuture = service.submit(() -> {
+            try {
+                promise.complete(traversalFunction.apply(this));
+            } catch (Exception ex) {
+                // the promise may have been cancelled by the caller, in which case, there is no need to attempt
+                // another write on completion
+                if (!promise.isDone()) promise.completeExceptionally(ex);
+            }
+        });
+
+        // if the user cancels the promise then attempt to kill the iteration.
+        promise.exceptionally(t -> {
+            if (t instanceof CancellationException) {
+                iterationFuture.cancel(true);
+            }
+
+            return null;
+        });
+
+        return promise;
+    }
+
+    /**
      * Add all the results of the traversal to the provided collection.
      *
      * @param collection the collection to fill
@@ -253,6 +297,12 @@ public interface Traversal<S, E> extends Iterator<E>, Serializable, Cloneable, A
     public interface Admin<S, E> extends Traversal<S, E> {
 
         /**
+         * Service that handles promises.
+         */
+        static final ExecutorService traversalExecutorService = Executors.newCachedThreadPool(
+                new BasicThreadFactory.Builder().namingPattern("traversal-executor-%d").build());
+
+        /**
          * Get the {@link Bytecode} associated with the construction of this traversal.
          *
          * @return the byte code representation of the traversal

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 3c21e37..6ce6dfe 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -43,6 +43,9 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Function;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -325,6 +328,40 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         this.graph = graph;
     }
 
+    /**
+     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions.
+     */
+    @Override
+    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction) {
+        return this.promise(traversalFunction, Traversal.Admin.traversalExecutorService);
+    }
+
+    /**
+     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions. In a transactional graph
+     * a promise represents the full scope of a transaction, even if the graph is only partially iterated.
+     */
+    @Override
+    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction, final ExecutorService service) {
+        if (graph != null && graph.features().graph().supportsTransactions()) {
+            final Function<Traversal, T2> transactionAware = traversal -> {
+
+                try {
+                    if (graph.tx().isOpen()) graph.tx().rollback();
+                    final T2 obj = traversalFunction.apply(traversal);
+                    if (graph.tx().isOpen()) graph.tx().commit();
+                    return obj;
+                } catch (Exception ex) {
+                    if (graph.tx().isOpen()) graph.tx().rollback();
+                    throw ex;
+                }
+            };
+
+            return Traversal.Admin.super.promise(transactionAware, service);
+        } else {
+            return Traversal.Admin.super.promise(traversalFunction, service);
+        }
+    }
+
     @Override
     public boolean equals(final Object other) {
         return other != null && other.getClass().equals(this.getClass()) && this.equals(((Traversal.Admin) other));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
new file mode 100644
index 0000000..aa1b99b
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalTest.java
@@ -0,0 +1,473 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal;
+
+import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalInterruptedException;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsCollectionContaining.hasItems;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TraversalTest {
+
+    private final ExecutorService service = Executors.newFixedThreadPool(2);
+
+    @Test
+    public void shouldTryNext() {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3);
+        final Optional<Integer> optFirst = t.tryNext();
+        assertEquals(1, optFirst.get().intValue());
+        final Optional<Integer> optSecond = t.tryNext();
+        assertEquals(2, optSecond.get().intValue());
+        final Optional<Integer> optThird = t.tryNext();
+        assertEquals(3, optThird.get().intValue());
+
+        IntStream.range(0, 100).forEach(i -> {
+            assertThat(t.tryNext().isPresent(), is(false));
+        });
+    }
+
+    @Test
+    public void shouldGetTwoAtATime() {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        final List<Integer> batchOne = t.next(2);
+        assertEquals(2, batchOne.size());
+        assertThat(batchOne, hasItems(1 ,2));
+
+        final List<Integer> batchTwo = t.next(2);
+        assertEquals(2, batchTwo.size());
+        assertThat(batchTwo, hasItems(3 ,4));
+
+        final List<Integer> batchThree = t.next(2);
+        assertEquals(2, batchThree.size());
+        assertThat(batchThree, hasItems(5, 6));
+
+        final List<Integer> batchFour = t.next(2);
+        assertEquals(1, batchFour.size());
+        assertThat(batchFour, hasItems(7));
+
+        final List<Integer> batchFive = t.next(2);
+        assertEquals(0, batchFive.size());
+    }
+
+    @Test
+    public void shouldFillList() {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        final List<Integer> listToFill = new ArrayList<>();
+        final List<Integer> batch = t.fill(listToFill);
+        assertEquals(7, batch.size());
+        assertThat(batch, hasItems(1 ,2, 3, 4, 5, 6, 7));
+        assertThat(t.hasNext(), is(false));
+        assertSame(listToFill, batch);
+    }
+
+    @Test
+    public void shouldStream() {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        final List<Integer> batch = t.toStream().collect(Collectors.toList());
+        assertEquals(7, batch.size());
+        assertThat(batch, hasItems(1 ,2, 3, 4, 5, 6, 7));
+        assertThat(t.hasNext(), is(false));
+    }
+
+    @Test
+    public void shouldPromiseNextThreeUsingForkJoin() throws Exception {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        final CompletableFuture<List<Integer>> promiseFirst = t.promise(traversal -> traversal.next(3));
+        final List<Integer> listFirst = promiseFirst.get();
+        assertEquals(3, listFirst.size());
+        assertThat(listFirst, hasItems(1 ,2, 3));
+        assertThat(t.hasNext(), is(true));
+        assertThat(promiseFirst.isDone(), is(true));
+
+        final CompletableFuture<List<Integer>> promiseSecond = t.promise(traversal -> traversal.next(3));
+        final List<Integer> listSecond = promiseSecond.get();
+        assertEquals(3, listSecond.size());
+        assertThat(listSecond, hasItems(4, 5, 6));
+        assertThat(t.hasNext(), is(true));
+        assertThat(promiseSecond.isDone(), is(true));
+
+        final CompletableFuture<List<Integer>> promiseThird = t.promise(traversal -> traversal.next(3));
+        final List<Integer> listThird = promiseThird.get();
+        assertEquals(1, listThird.size());
+        assertThat(listThird, hasItems(7));
+        assertThat(t.hasNext(), is(false));
+        assertThat(promiseThird.isDone(), is(true));
+
+        final CompletableFuture<Integer> promiseDead = t.promise(traversal -> (Integer) traversal.next());
+        final AtomicBoolean dead = new AtomicBoolean(false);
+        promiseDead.exceptionally(tossed -> {
+            dead.set(tossed instanceof NoSuchElementException);
+            return null;
+        });
+
+        try {
+            promiseDead.get(10000, TimeUnit.MILLISECONDS);
+            fail("Should have gotten an exception");
+        } catch (Exception ex) {
+            if (ex instanceof TimeoutException) {
+                fail("This should not have timed out but should have gotten an exception caught above in the exceptionally() clause");
+            }
+
+            assertThat(ex.getCause(), instanceOf(NoSuchElementException.class));
+        }
+
+        assertThat(dead.get(), is(true));
+        assertThat(t.hasNext(), is(false));
+        assertThat(promiseDead.isDone(), is(true));
+    }
+
+    @Test
+    public void shouldPromiseNextThreeUsingSpecificExecutor() throws Exception {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        final CompletableFuture<List<Integer>> promiseFirst = t.promise(traversal -> traversal.next(3), service);
+        final List<Integer> listFirst = promiseFirst.get();
+        assertEquals(3, listFirst.size());
+        assertThat(listFirst, hasItems(1 ,2, 3));
+        assertThat(t.hasNext(), is(true));
+        assertThat(promiseFirst.isDone(), is(true));
+
+        final CompletableFuture<List<Integer>> promiseSecond = t.promise(traversal -> traversal.next(3), service);
+        final List<Integer> listSecond = promiseSecond.get();
+        assertEquals(3, listSecond.size());
+        assertThat(listSecond, hasItems(4, 5, 6));
+        assertThat(t.hasNext(), is(true));
+        assertThat(promiseSecond.isDone(), is(true));
+
+        final CompletableFuture<List<Integer>> promiseThird = t.promise(traversal -> traversal.next(3), service);
+        final List<Integer> listThird = promiseThird.get();
+        assertEquals(1, listThird.size());
+        assertThat(listThird, hasItems(7));
+        assertThat(t.hasNext(), is(false));
+        assertThat(promiseThird.isDone(), is(true));
+
+        final CompletableFuture<Integer> promiseDead = t.promise(traversal -> (Integer) traversal.next(), service);
+        final AtomicBoolean dead = new AtomicBoolean(false);
+        promiseDead.exceptionally(tossed -> {
+            dead.set(tossed instanceof NoSuchElementException);
+            return null;
+        });
+
+        try {
+            promiseDead.get(10000, TimeUnit.MILLISECONDS);
+            fail("Should have gotten an exception");
+        } catch (Exception ex) {
+            if (ex instanceof TimeoutException) {
+                fail("This should not have timed out but should have gotten an exception caught above in the exceptionally() clause");
+            }
+
+            assertThat(ex.getCause(), instanceOf(NoSuchElementException.class));
+        }
+
+        assertThat(dead.get(), is(true));
+        assertThat(t.hasNext(), is(false));
+        assertThat(promiseDead.isDone(), is(true));
+    }
+
+    @Test
+    public void shouldInterruptTraversalFunction() throws Exception {
+        final Random rand = new Random(1234567890);
+
+        // infinite traversal
+        final MockTraversal<Integer> t = new MockTraversal<>(IntStream.generate(rand::nextInt).iterator());
+
+        // iterate a bunch of it
+        final CompletableFuture<List<Integer>> promise10 = t.promise(traversal -> traversal.next(10), service);
+        assertEquals(10, promise10.get(10000, TimeUnit.MILLISECONDS).size());
+        final CompletableFuture<List<Integer>> promise100 = t.promise(traversal -> traversal.next(100), service);
+        assertEquals(100, promise100.get(10000, TimeUnit.MILLISECONDS).size());
+        final CompletableFuture<List<Integer>> promise1000 = t.promise(traversal -> traversal.next(1000), service);
+        assertEquals(1000, promise1000.get(10000, TimeUnit.MILLISECONDS).size());
+
+        // this is endless, so let's cancel
+        final CompletableFuture<List<Integer>> promiseForevers = t.promise(traversal -> traversal.next(Integer.MAX_VALUE), service);
+
+        // specify what to do on exception
+        final AtomicBoolean failed = new AtomicBoolean(false);
+        promiseForevers.exceptionally(ex -> {
+            failed.set(true);
+            return null;
+        });
+
+        try {
+            // let it actually iterate a moment
+            promiseForevers.get(500, TimeUnit.MILLISECONDS);
+            fail("This should have timed out because the traversal has infinite items in it");
+        } catch (TimeoutException tex) {
+
+        }
+
+        assertThat(promiseForevers.isDone(), is(false));
+        promiseForevers.cancel(true);
+        assertThat(failed.get(), is(true));
+        assertThat(promiseForevers.isDone(), is(true));
+    }
+
+    @Test
+    public void shouldIterate() {
+        final MockTraversal<Integer> t = new MockTraversal<>(1, 2, 3, 4, 5, 6, 7);
+        assertThat(t.hasNext(), is(true));
+        t.iterate();
+        assertThat(t.hasNext(), is(false));
+    }
+
+    private static class MockStep<E> implements Step<E,E> {
+
+        private final Iterator<E> itty;
+
+        MockStep(final Iterator<E> itty) {
+            this.itty = itty;
+        }
+
+        @Override
+        public void addStarts(final Iterator starts) {
+
+        }
+
+        @Override
+        public void addStart(final Traverser.Admin start) {
+
+        }
+
+        @Override
+        public void setPreviousStep(final Step step) {
+
+        }
+
+        @Override
+        public Step getPreviousStep() {
+            return null;
+        }
+
+        @Override
+        public void setNextStep(final Step step) {
+
+        }
+
+        @Override
+        public Step getNextStep() {
+            return null;
+        }
+
+        @Override
+        public Traversal.Admin getTraversal() {
+            return null;
+        }
+
+        @Override
+        public void setTraversal(final Traversal.Admin traversal) {
+
+        }
+
+        @Override
+        public void reset() {
+
+        }
+
+        @Override
+        public Step clone() {
+            return null;
+        }
+
+        @Override
+        public Set<String> getLabels() {
+            return null;
+        }
+
+        @Override
+        public void addLabel(final String label) {
+
+        }
+
+        @Override
+        public void removeLabel(final String label) {
+
+        }
+
+        @Override
+        public void setId(final String id) {
+
+        }
+
+        @Override
+        public String getId() {
+            return null;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return itty.hasNext();
+        }
+
+        @Override
+        public Traverser.Admin<E> next() {
+            return new DefaultRemoteTraverser<>(itty.next(), 1L);
+        }
+    }
+
+
+    private static class MockTraversal<T> implements Traversal.Admin<T,T> {
+
+        private Iterator<T> itty;
+
+        private Step mockEndStep;
+
+        private List<Step> steps;
+
+        MockTraversal(final T... objects) {
+            this(Arrays.asList(objects));
+        }
+
+        MockTraversal(final List<T> list) {
+            this(list.iterator());
+        }
+
+        MockTraversal(final Iterator<T> itty) {
+            this.itty = itty;
+            mockEndStep = new MockStep<>(itty);
+            steps = Collections.singletonList(mockEndStep);
+        }
+
+        @Override
+        public Bytecode getBytecode() {
+            return null;
+        }
+
+        @Override
+        public List<Step> getSteps() {
+            return steps;
+        }
+
+        @Override
+        public <S2, E2> Admin<S2, E2> addStep(final int index, final Step<?, ?> step) throws IllegalStateException {
+            return null;
+        }
+
+        @Override
+        public <S2, E2> Admin<S2, E2> removeStep(final int index) throws IllegalStateException {
+            return null;
+        }
+
+        @Override
+        public void applyStrategies() throws IllegalStateException {
+
+        }
+
+        @Override
+        public TraverserGenerator getTraverserGenerator() {
+            return null;
+        }
+
+        @Override
+        public Set<TraverserRequirement> getTraverserRequirements() {
+            return null;
+        }
+
+        @Override
+        public void setSideEffects(final TraversalSideEffects sideEffects) {
+
+        }
+
+        @Override
+        public TraversalSideEffects getSideEffects() {
+            return null;
+        }
+
+        @Override
+        public void setStrategies(final TraversalStrategies strategies) {
+
+        }
+
+        @Override
+        public TraversalStrategies getStrategies() {
+            return null;
+        }
+
+        @Override
+        public void setParent(final TraversalParent step) {
+
+        }
+
+        @Override
+        public TraversalParent getParent() {
+            return null;
+        }
+
+        @Override
+        public Admin<T, T> clone() {
+            return null;
+        }
+
+        @Override
+        public boolean isLocked() {
+            return false;
+        }
+
+        @Override
+        public Optional<Graph> getGraph() {
+            return null;
+        }
+
+        @Override
+        public void setGraph(final Graph graph) {
+
+        }
+
+        @Override
+        public boolean hasNext() {
+            return itty.hasNext();
+        }
+
+        @Override
+        public T next() {
+            if (Thread.interrupted()) throw new TraversalInterruptedException();
+            return itty.next();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-groovy/pom.xml b/gremlin-groovy/pom.xml
index acc51b7..dae5e8a 100644
--- a/gremlin-groovy/pom.xml
+++ b/gremlin-groovy/pom.xml
@@ -61,11 +61,6 @@ limitations under the License.
             <classifier>indy</classifier>
         </dependency>
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.1</version>
-        </dependency>
-        <dependency>
             <groupId>com.github.jeremyh</groupId>
             <artifactId>jBCrypt</artifactId>
             <version>jbcrypt-0.4</version>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index 9e03884..5dd9c28 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -69,6 +69,7 @@ public class PythonProvider extends AbstractGraphProvider {
             "shouldNeverPropagateANullValuedTraverser",
             "shouldHidePartitionKeyForValues",
             "g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
index 68f8217..050f9de 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.process.traversal;
 
 import org.apache.tinkerpop.gremlin.ExceptionCoverage;
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
+import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -40,6 +41,9 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
@@ -307,4 +311,42 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest {
         }
 
     }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void shouldUsePromiseAndControlTransactionsIfAvailable() throws Exception {
+        // this test will validate that transactional graphs can properly open/close transactions within a promise.
+        // as there is a feature check, non-transactional graphs can use this to simply exercise the promise API
+        final Vertex vAdded = g.addV("person").property("name", "stephen").promise(t -> (Vertex) t.next()).get(10000, TimeUnit.MILLISECONDS);
+        final Vertex vRead = g.V().has("name", "stephen").next();
+        assertEquals(vAdded.id(), vRead.id());
+
+        // transaction should have been committed at this point so test the count in this thread to validate persistence
+        assertVertexEdgeCounts(graph, 1, 0);
+
+        // cancel a promise and ensure the transaction ended in failure. hold the traversal in park until it can be
+        // interrupted, then the promise will have to rollback the transaction.
+        final CompletableFuture promiseToCancel = g.addV("person").property("name", "marko").sideEffect(traverser -> {
+            try {
+                Thread.sleep(100000);
+            } catch (Exception ignored) {
+
+            }
+        }).promise(t -> (Vertex) t.next());
+
+        try {
+            promiseToCancel.get(500, TimeUnit.MILLISECONDS);
+            fail("Should have timed out");
+        } catch (TimeoutException te) {
+
+        }
+
+        promiseToCancel.cancel(true);
+
+        // graphs that support transactions will rollback the transaction
+        if (graph.features().graph().supportsTransactions())
+            assertVertexEdgeCounts(graph, 1, 0);
+        else
+            assertVertexEdgeCounts(graph, 2, 0);
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
index dd118d7..a595c34 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
@@ -51,6 +51,7 @@ public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider {
             "g_VX1X_out_injectXv2X_name",
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             GraphComputerTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb089764/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
index f40a8c7..15a6c0b 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
@@ -49,6 +49,7 @@ public class TinkerGraphJavaTranslatorProvider extends TinkerGraphProvider {
             TraversalInterruptionComputerTest.class.getCanonicalName(),
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             ElementIdStrategyProcessTest.class.getCanonicalName(),
             EventStrategyProcessTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName()));


[44/50] tinkerpop git commit: implemented promise API for gremlin-python. side effect retrieval is problematic

Posted by sp...@apache.org.
implemented promise API for gremlin-python. side effect retrieval is problematic


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

Branch: refs/heads/TINKERPOP-1490
Commit: b0b933084b38f77fcd4843796980cabe313ed1e4
Parents: f02e183
Author: davebshow <da...@gmail.com>
Authored: Wed Dec 7 13:35:42 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:03:41 2016 -0500

----------------------------------------------------------------------
 .../python/TraversalSourceGenerator.groovy      | 27 +++++++++
 .../driver/driver_remote_connection.py          | 21 +++++--
 .../gremlin_python/driver/remote_connection.py  |  7 +++
 .../jython/gremlin_python/process/traversal.py  | 28 +++++++++-
 .../driver/test_driver_remote_connection.py     | 59 ++++++++++++++++++++
 5 files changed, 137 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0b93308/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index 73ffcb6..fc76b71 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -114,6 +114,28 @@ class Traversal(object):
                 except StopIteration: return tempList
                 tempList.append(temp)
             return tempList
+    def promise(self, cb=None):
+        self.traversal_strategies.apply_async_strategies(self)
+        future_traversers = self.traversers
+        future = type(future_traversers)()
+        def process(f):
+            try:
+                traversers = f.result()
+            except Exception as e:
+                future.set_exception(e)
+            else:
+                self.traversers = iter(traversers)
+                if cb:
+                    try:
+                        result = cb(self)
+                    except Exception as e:
+                        future.set_exception(e)
+                    else:
+                        future.set_result(result)
+                else:
+                    future.set_result(self)
+        future_traversers.add_done_callback(process)
+        return future
 
 
 """)
@@ -223,6 +245,9 @@ class TraversalStrategies(object):
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
+    def apply_async_strategies(self, traversal):
+        for traversal_strategy in self.traversal_strategies:
+            traversal_strategy.apply_async(traversal)
     def __repr__(self):
         return str(self.traversal_strategies)
 
@@ -233,6 +258,8 @@ class TraversalStrategy(object):
         self.configuration = {} if configuration is None else configuration
     def apply(self, traversal):
         return
+    def apply_async(self, traversal):
+        return
     def __eq__(self, other):
         return isinstance(other, self.__class__)
     def __hash__(self):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0b93308/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index d975f60..babb113 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -17,9 +17,11 @@ specific language governing permissions and limitations
 under the License.
 """
 import base64
+import functools
 import json
 import uuid
 from tornado import gen
+from tornado import concurrent
 from tornado import ioloop
 from tornado import websocket
 
@@ -51,10 +53,15 @@ class DriverRemoteConnection(RemoteConnection):
         '''
         request_id = str(uuid.uuid4())
         traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
-        side_effect_keys = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_keys(request_id))
-        side_effect_value = lambda key: self._loop.run_sync(lambda: self.submit_sideEffect_value(request_id, key))
-        side_effect_close = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_close(request_id))
-        return RemoteTraversal(iter(traversers), RemoteTraversalSideEffects(side_effect_keys, side_effect_value, side_effect_close))
+        keys, value, close = self._get_side_effect_lambdas(request_id)
+        return RemoteTraversal(iter(traversers), RemoteTraversalSideEffects(keys, value, close))
+
+    def submit_async(self, bytecode):
+        request_id = str(uuid.uuid4())
+        future_traversers = self.submit_traversal_bytecode(request_id, bytecode)
+        keys, value, close = self._get_side_effect_lambdas(request_id)
+        side_effects = RemoteTraversalSideEffects(keys, value, close)
+        return RemoteTraversal(future_traversers, side_effects)
 
     @gen.coroutine
     def submit_traversal_bytecode(self, request_id, bytecode):
@@ -135,6 +142,12 @@ class DriverRemoteConnection(RemoteConnection):
         result = yield self._execute_message(message)
         raise gen.Return(result)
 
+    def _get_side_effect_lambdas(self, request_id):
+        side_effect_keys = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_keys(request_id))
+        side_effect_value = lambda key: self._loop.run_sync(lambda: self.submit_sideEffect_value(request_id, key))
+        side_effect_close = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_close(request_id))
+        return side_effect_keys, side_effect_value, side_effect_close
+
     @gen.coroutine
     def _execute_message(self, send_message):
         send_message = b"".join([b"\x21",

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0b93308/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index 46fb760..93c92b7 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -95,3 +95,10 @@ class RemoteStrategy(TraversalStrategy):
             remote_traversal = self.remote_connection.submit(traversal.bytecode)
             traversal.side_effects = remote_traversal.side_effects
             traversal.traversers = remote_traversal.traversers
+
+    def apply_async(self, traversal):
+        if traversal.traversers is None:
+            remote_traversal = self.remote_connection.submit_async(
+                traversal.bytecode)
+            traversal.side_effects = remote_traversal.side_effects
+            traversal.traversers = remote_traversal.traversers

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0b93308/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index a7b6118..2c2db59 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -77,6 +77,28 @@ class Traversal(object):
                 except StopIteration: return tempList
                 tempList.append(temp)
             return tempList
+    def promise(self, cb=None):
+        self.traversal_strategies.apply_async_strategies(self)
+        future_traversers = self.traversers
+        future = type(future_traversers)()
+        def process(f):
+            try:
+                traversers = f.result()
+            except Exception as e:
+                future.set_exception(e)
+            else:
+                self.traversers = iter(traversers)
+                if cb:
+                    try:
+                        result = cb(self)
+                    except Exception as e:
+                        future.set_exception(e)
+                    else:
+                        future.set_result(result)
+                else:
+                    future.set_result(self)
+        future_traversers.add_done_callback(process)
+        return future
 
 
 Barrier = Enum('Barrier', 'normSack')
@@ -286,6 +308,9 @@ class TraversalStrategies(object):
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
+    def apply_async_strategies(self, traversal):
+        for traversal_strategy in self.traversal_strategies:
+            traversal_strategy.apply_async(traversal)
     def __repr__(self):
         return str(self.traversal_strategies)
 
@@ -296,6 +321,8 @@ class TraversalStrategy(object):
         self.configuration = {} if configuration is None else configuration
     def apply(self, traversal):
         return
+    def apply_async(self, traversal):
+        return
     def __eq__(self, other):
         return isinstance(other, self.__class__)
     def __hash__(self):
@@ -379,4 +406,3 @@ class Binding(object):
         return hash(self.key) + hash(self.value)
     def __repr__(self):
         return "binding[" + self.key + "=" + str(self.value) + "]"
-

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0b93308/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 6b057d5..c9e64c5 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -24,6 +24,8 @@ from unittest import TestCase
 
 import pytest
 
+from tornado import ioloop, gen
+
 from gremlin_python import statics
 from gremlin_python.statics import long
 from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
@@ -193,6 +195,63 @@ class TestDriverRemoteConnection(TestCase):
             t.side_effects.value_lambda('b')
         connection.close()
 
+    def test_promise(self):
+        loop = ioloop.IOLoop.current()
+        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+        g = Graph().traversal().withRemote(connection)
+
+        @gen.coroutine
+        def go():
+            future_traversal = g.V().promise(lambda x: x.toList())
+            assert not future_traversal.done()
+            resp = yield future_traversal
+            assert future_traversal.done()
+            assert len(resp) == 6
+            count = yield g.V().count().promise(lambda x: x.next())
+            assert count == 6
+
+        loop.run_sync(go)
+
+    def test_promise_side_effects(self):
+        loop = ioloop.IOLoop.current()
+        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+        g = Graph().traversal().withRemote(connection)
+
+        # Side effects are problematic in coroutines.
+        # Because they are designed to be synchronous (calling `run_sync`)
+        # they result in an error if called from a coroutine because
+        # the event loop is already running
+        @gen.coroutine
+        def go():
+            traversal = yield g.V().aggregate('a').promise()
+            # Trying to get side effect keys throws error - BAD
+            with pytest.raises(RuntimeError):
+                keys = traversal.side_effects.keys()
+                # IOLoop is now hosed.
+
+        loop.run_sync(go)
+
+        # Get a new IOLoop - this should happen for each test case.
+        connection.close()
+        ioloop.IOLoop.clear_instance()
+        loop.close()
+        loop = ioloop.IOLoop()
+        loop.make_current()
+
+        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+        g = Graph().traversal().withRemote(connection)
+
+        # If we return the traversal though, we can use side effects per usual.
+        @gen.coroutine
+        def go():
+            traversal = yield g.V().aggregate('a').promise()
+            raise gen.Return(traversal)  # Weird legacy Python compatible idiom
+
+        # See, normal side effects.
+        traversal = loop.run_sync(go)
+        a, = traversal.side_effects.keys()
+        assert  a == 'a'
+
 
 if __name__ == '__main__':
     test = False


[20/50] tinkerpop git commit: TINKERPOP-1562 Deprecated Artifact

Posted by sp...@apache.org.
TINKERPOP-1562 Deprecated Artifact

Moved it to a new home as the hole plugin package is going to go away in 3.3.0


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

Branch: refs/heads/TINKERPOP-1490
Commit: 39e39652a0d3e6a4f9ef480d16b08372774f2b30
Parents: a2a2359
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 09:39:10 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../groovy/util/DependencyGrabber.groovy        | 15 ++--
 .../gremlin/groovy/plugin/Artifact.java         |  2 +
 .../tinkerpop/gremlin/groovy/util/Artifact.java | 86 ++++++++++++++++++++
 .../gremlin/groovy/plugin/ArtifactTest.java     |  2 -
 .../gremlin/groovy/util/ArtifactTest.java       | 85 +++++++++++++++++++
 5 files changed, 182 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/39e39652/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
index e7ab55b..f2bfe5c 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
@@ -20,11 +20,14 @@ package org.apache.tinkerpop.gremlin.groovy.util
 
 import groovy.grape.Grape
 import org.apache.commons.lang3.SystemUtils
-import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
-import java.nio.file.*
+import java.nio.file.DirectoryStream
+import java.nio.file.FileSystems
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.StandardCopyOption
 import java.util.jar.JarFile
 import java.util.jar.Manifest
 
@@ -118,9 +121,9 @@ class DependencyGrabber {
                     .findAll {!filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
                     .each(copyTo(targetPluginPath))
             getAdditionalDependencies(targetPluginPath, artifact).collect(convertUriToPath(fs))
-                .findAll { !(it.fileName.toFile().name ==~ /(slf4j|logback\-classic)-.*\.jar/) }
-                .findAll { !filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
-                .each(copyTo(targetPluginPath))
+                    .findAll { !(it.fileName.toFile().name ==~ /(slf4j|logback\-classic)-.*\.jar/) }
+                    .findAll { !filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
+                    .each(copyTo(targetPluginPath))
 
             // get dependencies for the lib path.  the lib path should not filter out any jars - used for reference
             dependencyLocations.collect(convertUriToPath(fs)).each(copyTo(targetLibPath))
@@ -162,7 +165,7 @@ class DependencyGrabber {
      * Windows places a starting forward slash in the URI that needs to be stripped off or else the
      * {@code FileSystem} won't properly resolve it.
      */
-    private static Closure convertUriToPath(final FileSystem fs) {
+    private static Closure convertUriToPath(def fs) {
         return { URI uri ->
             def p = SystemUtils.IS_OS_WINDOWS ? uri.path.substring(1) : uri.path
             return fs.getPath(p)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/39e39652/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
index 29ce7d6..7fb0bd3 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
@@ -22,7 +22,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin;
  * A software artifact identified by its maven coordinates.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.util.Artifact}
  */
+@Deprecated
 public class Artifact {
     private final String group;
     private final String artifact;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/39e39652/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
new file mode 100644
index 0000000..2e2554b
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.util;
+
+/**
+ * A software artifact identified by its maven coordinates.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class Artifact {
+    private final String group;
+    private final String artifact;
+    private final String version;
+
+    /**
+     * Create a new instance.
+     *
+     * @param group the {@code groupId}
+     * @param artifact the {@code artifactId}
+     * @param version the {@code version}
+     */
+    public Artifact(final String group, final String artifact, final String version) {
+        if (group == null || group.isEmpty())
+            throw new IllegalArgumentException("group cannot be null or empty");
+
+        if (artifact == null || artifact.isEmpty())
+            throw new IllegalArgumentException("artifact cannot be null or empty");
+
+        if (version == null || version.isEmpty())
+            throw new IllegalArgumentException("version cannot be null or empty");
+
+        this.group = group;
+        this.artifact = artifact;
+        this.version = version;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public String getArtifact() {
+        return artifact;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Artifact a = (Artifact) o;
+
+        if (group != null ? !group.equals(a.group) : a.group != null) return false;
+        if (artifact != null ? !artifact.equals(a.artifact) : a.artifact != null) return false;
+        if (version != null ? !version.equals(a.version) : a.version != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = group != null ? group.hashCode() : 0;
+        result = 31 * result + (artifact != null ? artifact.hashCode() : 0);
+        result = 31 * result + (version != null ? version.hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/39e39652/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
index a876df8..f3c96f9 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
@@ -18,13 +18,11 @@
  */
 package org.apache.tinkerpop.gremlin.groovy.plugin;
 
-
 import org.junit.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 
-
 /**
  * @author Nghia Tran (https://github.com/n-tran)
  */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/39e39652/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java
new file mode 100644
index 0000000..0e0c283
--- /dev/null
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.util;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * @author Nghia Tran (https://github.com/n-tran)
+ */
+public class ArtifactTest {
+    @Test
+    public void shouldBeEqualIfSame() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = a;
+
+        assertThat(a.equals(b), is(true));
+    }
+
+    @Test
+    public void shouldNotBeEqualIfArgumentIsNull() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = null;
+
+        assertThat(a.equals(b), is(false));
+    }
+
+    @Test
+    public void shouldNotBeEqualIfArgumentIsNotAnArtifact() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final String b = " ";
+
+        assertThat(a.equals(b), is(false));
+    }
+
+    @Test
+    public void shouldNotBeEqualIfTheGroupIsNotEqual() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = new Artifact("com.apacheTest.tinkerpop2","tinkergraph-gremlin","3.0.0");
+
+        assertThat(a.equals(b), is(false));
+    }
+
+    @Test
+    public void shouldNotBeEqualIfTheArtifactIsNotEqual() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-artifact","3.0.0");
+
+        assertThat(a.equals(b), is(false));
+    }
+
+    @Test
+    public void shouldNotBeEqualIfTheVersionIsNotEqual() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","4.0.0");
+
+        assertThat(a.equals(b), is(false));
+    }
+
+    @Test
+    public void shouldBeEqual() {
+        final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+        final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+
+        assertThat(a.equals(b), is(true));
+    }
+}


[10/50] tinkerpop git commit: TINKERPOP-1562 Hooked up GremlinJythonScriptEngine to Customizers

Posted by sp...@apache.org.
TINKERPOP-1562 Hooked up GremlinJythonScriptEngine to Customizers

GremlnJythonScriptEngine is now initialized the same way that GremlinGroovyScriptEngine is.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 05ff0c0fe957a9fe697c5b1a176c682837ee0c64
Parents: a2ac1f2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 24 08:11:35 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:49 2016 -0500

----------------------------------------------------------------------
 .../jsr223/GremlinJythonScriptEngine.java       | 167 ++++++++++++-------
 .../GremlinJythonScriptEngineFactory.java       |   5 +-
 .../jsr223/GremlinJythonScriptEngineTest.java   |  12 +-
 .../jsr223/GremlinEnabledScriptEngineTest.java  |   1 -
 4 files changed, 120 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05ff0c0f/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
index 554d80a..1b95a02 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -19,8 +19,10 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
@@ -35,7 +37,13 @@ import javax.script.ScriptContext;
 import javax.script.ScriptException;
 import java.io.Reader;
 import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -44,6 +52,10 @@ public class GremlinJythonScriptEngine implements GremlinScriptEngine {
 
     private final PyScriptEngine pyScriptEngine;
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #GremlinJythonScriptEngine(Customizer...)}.
+     */
+    @Deprecated
     public GremlinJythonScriptEngine() {
         this.pyScriptEngine = (PyScriptEngine) new PyScriptEngineFactory().getScriptEngine();
         try {
@@ -61,70 +73,48 @@ public class GremlinJythonScriptEngine implements GremlinScriptEngine {
                 this.pyScriptEngine.eval(SymbolHelper.toPython(x.name()) + " = " + x.getDeclaringClass().getSimpleName() + "." + x.name());
             }
 
-            // add sugar methods
-            this.pyScriptEngine.eval("def getitem_bypass(self, index):\n" +
-                    "  if isinstance(index,int):\n    return self.range(index,index+1)\n" +
-                    "  elif isinstance(index,slice):\n    return self.range(index.start,index.stop)\n" +
-                    "  else:\n    return TypeError('Index must be int or slice')");
-            this.pyScriptEngine.eval(GraphTraversal.class.getSimpleName() + ".__getitem__ = getitem_bypass");
-            this.pyScriptEngine.eval(GraphTraversal.class.getSimpleName() + ".__getattr__ = lambda self, key: self.values(key)\n");
-            this.pyScriptEngine.eval("\n" +
-                    "from java.lang import Long\n" +
-                    "import org.apache.tinkerpop.gremlin.util.function.Lambda\n" + // todo: remove or remove imported subclass names? (choose)
-                    "from org.apache.tinkerpop.gremlin.util.function.Lambda import AbstractLambda\n" +
-                    "from org.apache.tinkerpop.gremlin.util.function.Lambda import UnknownArgLambda\n" +
-                    "from org.apache.tinkerpop.gremlin.util.function.Lambda import ZeroArgLambda\n" +
-                    "from org.apache.tinkerpop.gremlin.util.function.Lambda import OneArgLambda\n" +
-                    "from org.apache.tinkerpop.gremlin.util.function.Lambda import TwoArgLambda\n\n" +
-
-                    "class JythonUnknownArgLambda(UnknownArgLambda):\n" +
-                    "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
-                    "    UnknownArgLambda.__init__(self, script, lang, -1)\n" +
-                    "    self.func = func\n" +
-                    "  def __repr__(self):\n" +
-                    "    return self.getLambdaScript()\n\n" +
-
-                    "class JythonZeroArgLambda(ZeroArgLambda):\n" +
-                    "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
-                    "    ZeroArgLambda.__init__(self, script, lang)\n" +
-                    "    self.func = func\n" +
-                    "  def __repr__(self):\n" +
-                    "    return self.getLambdaScript()\n" +
-                    "  def get(self):\n" +
-                    "    return self.func()\n\n" +
-
-                    "class JythonOneArgLambda(OneArgLambda):\n" +
-                    "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
-                    "    OneArgLambda.__init__(self, script, lang)\n" +
-                    "    self.func = func\n" +
-                    "  def __repr__(self):\n" +
-                    "    return self.getLambdaScript()\n" +
-                    "  def test(self,a):\n" +
-                    "    return self.func(a)\n" +
-                    "  def apply(self,a):\n" +
-                    "    return self.func(a)\n" +
-                    "  def accept(self,a):\n" +
-                    "    self.func(a)\n" +
-                    "  def compare(self,a,b):\n" +
-                    "    return self.func(a,b)\n\n" +
-
-                    "class JythonTwoArgLambda(TwoArgLambda):\n" +
-                    "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
-                    "    TwoArgLambda.__init__(self, script, lang)\n" +
-                    "    self.func = func\n" +
-                    "  def __repr__(self):\n" +
-                    "    return self.getLambdaScript()\n" +
-                    "  def apply(self,a,b):\n" +
-                    "    return self.func(a,b)\n" +
-                    "  def compare(self,a,b):\n" +
-                    "    return self.func(a,b)\n"
-            );
+            loadSugar();
 
         } catch (final ScriptException e) {
             throw new IllegalStateException(e.getMessage(), e);
         }
     }
 
+    public GremlinJythonScriptEngine(final Customizer... customizers) {
+        this.pyScriptEngine = (PyScriptEngine) new PyScriptEngineFactory().getScriptEngine();
+        final List<Customizer> listOfCustomizers = Arrays.asList(customizers);
+
+        final List<ImportCustomizer> importCustomizers = listOfCustomizers.stream()
+                .filter(p -> p instanceof ImportCustomizer)
+                .map(p -> (ImportCustomizer) p)
+                .collect(Collectors.toList());
+
+        try {
+            for (ImportCustomizer ic : importCustomizers) {
+                for (Class<?> c : ic.getClassImports()) {
+                    if (null == c.getDeclaringClass())
+                        this.pyScriptEngine.eval("from " + c.getPackage().getName() + " import " + c.getSimpleName());
+                    else
+                        this.pyScriptEngine.eval("from " + c.getPackage().getName() + "." + c.getDeclaringClass().getSimpleName() + " import " + c.getSimpleName());
+                }
+
+                for (Method m : ic.getMethodImports()) {
+                    this.pyScriptEngine.eval(SymbolHelper.toPython(m.getName()) + " = " + m.getDeclaringClass().getSimpleName() + "." + m.getName());
+                }
+
+                // enums need to import after methods for some reason or else label comes in as a PyReflectedFunction
+                for (Enum e : ic.getEnumImports()) {
+                    this.pyScriptEngine.eval(SymbolHelper.toPython(e.name()) + " = " + e.getDeclaringClass().getSimpleName() + "." + e.name());
+                }
+            }
+
+            loadSugar();
+
+        } catch (Exception ex) {
+            throw new IllegalStateException(ex);
+        }
+    }
+
     @Override
     public Traversal.Admin eval(final Bytecode bytecode, final Bindings bindings) throws ScriptException {
         bindings.putAll(bytecode.getBindings());
@@ -209,4 +199,65 @@ public class GremlinJythonScriptEngine implements GremlinScriptEngine {
     public GremlinScriptEngineFactory getFactory() {
         return new GremlinJythonScriptEngineFactory();
     }
+
+    private void loadSugar() throws ScriptException {
+        // add sugar methods
+        this.pyScriptEngine.eval("def getitem_bypass(self, index):\n" +
+                "  if isinstance(index,int):\n    return self.range(index,index+1)\n" +
+                "  elif isinstance(index,slice):\n    return self.range(index.start,index.stop)\n" +
+                "  else:\n    return TypeError('Index must be int or slice')");
+        this.pyScriptEngine.eval(GraphTraversal.class.getSimpleName() + ".__getitem__ = getitem_bypass");
+        this.pyScriptEngine.eval(GraphTraversal.class.getSimpleName() + ".__getattr__ = lambda self, key: self.values(key)\n");
+        this.pyScriptEngine.eval("\n" +
+                "from java.lang import Long\n" +
+                "import org.apache.tinkerpop.gremlin.util.function.Lambda\n" + // todo: remove or remove imported subclass names? (choose)
+                "from org.apache.tinkerpop.gremlin.util.function.Lambda import AbstractLambda\n" +
+                "from org.apache.tinkerpop.gremlin.util.function.Lambda import UnknownArgLambda\n" +
+                "from org.apache.tinkerpop.gremlin.util.function.Lambda import ZeroArgLambda\n" +
+                "from org.apache.tinkerpop.gremlin.util.function.Lambda import OneArgLambda\n" +
+                "from org.apache.tinkerpop.gremlin.util.function.Lambda import TwoArgLambda\n\n" +
+
+                "class JythonUnknownArgLambda(UnknownArgLambda):\n" +
+                "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
+                "    UnknownArgLambda.__init__(self, script, lang, -1)\n" +
+                "    self.func = func\n" +
+                "  def __repr__(self):\n" +
+                "    return self.getLambdaScript()\n\n" +
+
+                "class JythonZeroArgLambda(ZeroArgLambda):\n" +
+                "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
+                "    ZeroArgLambda.__init__(self, script, lang)\n" +
+                "    self.func = func\n" +
+                "  def __repr__(self):\n" +
+                "    return self.getLambdaScript()\n" +
+                "  def get(self):\n" +
+                "    return self.func()\n\n" +
+
+                "class JythonOneArgLambda(OneArgLambda):\n" +
+                "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
+                "    OneArgLambda.__init__(self, script, lang)\n" +
+                "    self.func = func\n" +
+                "  def __repr__(self):\n" +
+                "    return self.getLambdaScript()\n" +
+                "  def test(self,a):\n" +
+                "    return self.func(a)\n" +
+                "  def apply(self,a):\n" +
+                "    return self.func(a)\n" +
+                "  def accept(self,a):\n" +
+                "    self.func(a)\n" +
+                "  def compare(self,a,b):\n" +
+                "    return self.func(a,b)\n\n" +
+
+                "class JythonTwoArgLambda(TwoArgLambda):\n" +
+                "  def __init__(self,func,script='none',lang='gremlin-jython'):\n" +
+                "    TwoArgLambda.__init__(self, script, lang)\n" +
+                "    self.func = func\n" +
+                "  def __repr__(self):\n" +
+                "    return self.getLambdaScript()\n" +
+                "  def apply(self,a,b):\n" +
+                "    return self.func(a,b)\n" +
+                "  def compare(self,a,b):\n" +
+                "    return self.func(a,b)\n"
+        );
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05ff0c0f/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
index c94e94f..696c2ea 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
@@ -19,6 +19,7 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager;
@@ -100,6 +101,8 @@ public class GremlinJythonScriptEngineFactory extends PyScriptEngineFactory impl
 
     @Override
     public GremlinScriptEngine getScriptEngine() {
-        return new GremlinJythonScriptEngine();
+        final List<Customizer> customizers =  manager.getCustomizers(GREMLIN_JYTHON);
+        return (customizers.isEmpty()) ? new GremlinJythonScriptEngine() :
+                new GremlinJythonScriptEngine(customizers.toArray(new Customizer[customizers.size()]));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05ff0c0f/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
index 8bc60a5..8ec1cf4 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
@@ -36,6 +36,8 @@ import java.math.BigInteger;
 import java.util.Arrays;
 import java.util.HashSet;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -56,11 +58,11 @@ public class GremlinJythonScriptEngineTest {
     @Test
     public void shouldHaveCoreImports() throws Exception {
         final ScriptEngine engine = new DefaultGremlinScriptEngineManager().getEngineByName("gremlin-jython");
-        assertTrue(engine.eval("Graph") instanceof Class);
-        assertTrue(engine.eval("__") instanceof Class);
-        assertTrue(engine.eval("T") instanceof Class);
-        assertTrue(engine.eval("label") instanceof T);
-        assertTrue(engine.eval("T.label") instanceof T);
+        assertThat(engine.eval("Graph"), instanceOf(Class.class));
+        assertThat(engine.eval("__"), instanceOf(Class.class));
+        assertThat(engine.eval("T"), instanceOf(Class.class));
+        assertThat(engine.eval("label"), instanceOf(T.class));
+        assertThat(engine.eval("T.label"), instanceOf(T.class));
         assertEquals(SackFunctions.Barrier.class, engine.eval("Barrier"));
         assertEquals(SackFunctions.Barrier.normSack, engine.eval("Barrier.normSack"));
         assertEquals(Column.class, engine.eval("Column"));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05ff0c0f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
index 723d898..f6bbcb8 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
@@ -55,7 +55,6 @@ public class GremlinEnabledScriptEngineTest {
         }
     }
 
-    @org.junit.Ignore("TEMPORARY - until GremlinJythonScriptEngine supports this stuff")
     @Test
     public void shouldSupportDeprecatedGremlinModules() throws Exception {
         final GremlinScriptEngineManager mgr = new DefaultGremlinScriptEngineManager();


[36/50] tinkerpop git commit: Merge branch 'TINKERPOP-1562' into tp32

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1562' into tp32


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

Branch: refs/heads/TINKERPOP-1490
Commit: 708c601626dd3eb83b46002027d55ae658000ced
Parents: fdeb7a0 9f84ac4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Dec 12 07:09:22 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Dec 12 07:09:22 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../upgrade/release-3.2.x-incubating.asciidoc   |  50 +++
 .../groovy/plugin/GiraphGremlinPlugin.java      |   2 +
 .../giraph/jsr223/GiraphGremlinPlugin.java      |  58 +++
 .../tinkerpop/gremlin/console/Console.groovy    |  31 +-
 .../ConsoleImportCustomizerProvider.groovy      |   2 +
 .../tinkerpop/gremlin/console/Mediator.groovy   |   4 +-
 .../console/commands/InstallCommand.groovy      |  14 +-
 .../console/jsr223/GephiRemoteAcceptor.groovy   | 369 +++++++++++++++++++
 .../console/plugin/ConsolePluginAcceptor.groovy |   2 +-
 .../console/plugin/GephiRemoteAcceptor.groovy   |   2 +
 .../gremlin/console/plugin/PluggedIn.groovy     | 112 ++++++
 .../groovy/plugin/DriverGremlinPlugin.java      |   2 +
 .../groovy/plugin/DriverRemoteAcceptor.java     |   2 +
 .../groovy/plugin/GephiGremlinPlugin.java       |   1 +
 .../groovy/plugin/UtilitiesGremlinPlugin.java   |   1 +
 .../console/jsr223/DriverGremlinPlugin.java     | 104 ++++++
 .../console/jsr223/DriverRemoteAcceptor.java    | 238 ++++++++++++
 .../console/jsr223/GephiGremlinPlugin.java      |  41 +++
 .../console/jsr223/UtilitiesGremlinPlugin.java  | 106 ++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   3 +
 .../jsr223/UtilitiesGremlinPluginScript.groovy  |  52 +++
 .../groovy/plugin/GremlinPluginAdapterTest.java | 130 +++++++
 .../groovy/plugin/script-customizer-1.groovy    |   3 +
 .../groovy/plugin/script-customizer-2.groovy    |   2 +
 .../gremlin/jsr223/AbstractGremlinPlugin.java   |  58 +++
 .../gremlin/jsr223/BindingsCustomizer.java      |  33 ++
 .../CachedGremlinScriptEngineManager.java       |   1 +
 .../gremlin/jsr223/CoreGremlinModule.java       |  25 +-
 .../gremlin/jsr223/CoreGremlinPlugin.java       |  62 ++++
 .../tinkerpop/gremlin/jsr223/CoreImports.java   | 250 +++++++++++++
 .../tinkerpop/gremlin/jsr223/Customizer.java    |   4 +-
 .../jsr223/DefaultBindingsCustomizer.java       |  40 ++
 .../DefaultGremlinScriptEngineManager.java      |  38 +-
 .../gremlin/jsr223/DefaultImportCustomizer.java | 102 +++++
 .../gremlin/jsr223/DefaultScriptCustomizer.java |  56 +++
 .../tinkerpop/gremlin/jsr223/GremlinModule.java |  13 +
 .../tinkerpop/gremlin/jsr223/GremlinPlugin.java |  61 +++
 .../jsr223/GremlinScriptEngineManager.java      |   8 +
 .../gremlin/jsr223/ImportCustomizer.java        |  83 +----
 .../gremlin/jsr223/ImportGremlinPlugin.java     | 190 ++++++++++
 .../gremlin/jsr223/LazyBindingsCustomizer.java  |  39 ++
 .../gremlin/jsr223/ScriptCustomizer.java        |  34 ++
 .../gremlin/jsr223/ScriptEngineCache.java       |  54 +++
 .../gremlin/jsr223/ScriptFileGremlinPlugin.java |  77 ++++
 .../SingleGremlinScriptEngineManager.java       |   2 +-
 .../jsr223/console/ConsoleCustomizer.java       |  33 ++
 .../jsr223/console/GremlinShellEnvironment.java |  37 ++
 .../gremlin/jsr223/console/PluginAcceptor.java  |  62 ++++
 .../gremlin/jsr223/console/RemoteAcceptor.java  |  83 +++++
 .../gremlin/jsr223/console/RemoteException.java |  40 ++
 .../tinkerpop/gremlin/util/CoreImports.java     |  35 +-
 .../gremlin/util/ScriptEngineCache.java         |   4 +-
 .../jsr223/DefaultImportCustomizerTest.java     |  76 ++++
 .../jsr223/DefaultScriptCustomizerTest.java     |  55 +++
 .../gremlin/jsr223/ImportGremlinPluginTest.java | 149 ++++++++
 .../gremlin/jsr223/ScriptEngineCacheTest.java   |  46 +++
 .../jsr223/ScriptFileGremlinPluginTest.java     |  62 ++++
 .../jsr223/SingleScriptEngineManagerTest.java   |  45 +++
 .../gremlin/jsr223/script-customizer-1.groovy   |   3 +
 .../gremlin/jsr223/script-customizer-2.groovy   |   2 +
 .../dsl/credential/CredentialGraphTest.java     | 121 ++++++
 .../dsl/credential/CredentialGraphTest.java     |   2 +-
 .../groovy/util/DependencyGrabber.groovy        |  29 +-
 .../gremlin/groovy/engine/GremlinExecutor.java  | 123 ++++++-
 .../gremlin/groovy/engine/ScriptEngines.java    |   2 +
 .../jsr223/CompileStaticGroovyCustomizer.java   |  60 +++
 .../jsr223/ConfigurationGroovyCustomizer.java   |  82 +++++
 .../groovy/jsr223/DependencyManager.java        |   3 +
 .../jsr223/GremlinGroovyScriptEngine.java       | 102 +++--
 .../jsr223/GroovyCompilerGremlinPlugin.java     | 132 +++++++
 .../gremlin/groovy/jsr223/GroovyCustomizer.java |  33 ++
 .../groovy/jsr223/ImportGroovyCustomizer.java   |  66 ++++
 .../jsr223/InterpreterModeGroovyCustomizer.java |  36 ++
 .../jsr223/ScriptEnginePluginAcceptor.java      |   2 +
 .../groovy/jsr223/SugarGremlinPlugin.java       |  41 +++
 .../jsr223/ThreadInterruptGroovyCustomizer.java |  35 ++
 .../jsr223/TimedInterruptGroovyCustomizer.java  |  62 ++++
 .../jsr223/TimedInterruptTimeoutException.java  |  38 ++
 .../jsr223/TypeCheckedGroovyCustomizer.java     |  65 ++++
 .../CompileStaticCustomizerProvider.java        |   3 +
 .../ConfigurationCustomizerProvider.java        |   3 +
 .../InterpreterModeCustomizerProvider.java      |   5 +
 .../ThreadInterruptCustomizerProvider.java      |   3 +
 .../TimedInterruptCustomizerProvider.java       |   3 +
 .../TimedInterruptTimeoutException.java         |   4 +
 .../TypeCheckedCustomizerProvider.java          |   3 +
 .../VariableIdentificationCustomizer.java       |   2 +
 .../jsr223/dsl/credential/CredentialGraph.java  | 121 ++++++
 .../CredentialGraphGremlinPlugin.java           |  51 +++
 .../dsl/credential/CredentialGraphTokens.java   |  31 ++
 .../groovy/plugin/AbstractGremlinPlugin.java    |   2 +
 .../gremlin/groovy/plugin/Artifact.java         |   2 +
 .../gremlin/groovy/plugin/GremlinPlugin.java    |   1 +
 .../groovy/plugin/GremlinPluginException.java   |   2 +
 .../plugin/IllegalEnvironmentException.java     |   2 +
 .../gremlin/groovy/plugin/PluginAcceptor.java   |   2 +
 .../plugin/PluginInitializationException.java   |   2 +
 .../gremlin/groovy/plugin/RemoteAcceptor.java   |   2 +
 .../gremlin/groovy/plugin/RemoteException.java  |   2 +
 .../groovy/plugin/SugarGremlinPlugin.java       |   2 +
 .../plugin/dsl/credential/CredentialGraph.java  |   2 +
 .../CredentialGraphGremlinPlugin.java           |   2 +
 .../dsl/credential/CredentialGraphTokens.java   |   2 +
 .../tinkerpop/gremlin/groovy/util/Artifact.java |  86 +++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   2 +
 ...aultDefaultImportCustomizerProviderTest.java |  90 +++++
 .../DefaultImportCustomizerProviderTest.java    |  90 -----
 ...mlinGroovyScriptEngineCompileStaticTest.java |  72 +++-
 .../GremlinGroovyScriptEngineConfigTest.java    |  11 +-
 .../jsr223/GremlinGroovyScriptEngineTest.java   |  52 ++-
 ...inGroovyScriptEngineThreadInterruptTest.java |  23 +-
 ...linGroovyScriptEngineTimedInterruptTest.java |  65 +++-
 ...remlinGroovyScriptEngineTypeCheckedTest.java |  72 +++-
 .../jsr223/GroovyCompilerGremlinPluginTest.java | 128 +++++++
 .../gremlin/groovy/plugin/ArtifactTest.java     |   2 -
 .../gremlin/groovy/util/ArtifactTest.java       |  85 +++++
 .../python/TraversalSourceGenerator.groovy      |   2 +-
 .../jsr223/GremlinJythonScriptEngine.java       | 172 ++++++---
 .../GremlinJythonScriptEngineFactory.java       |   9 +-
 .../jsr223/GremlinJythonScriptEngineTest.java   |  12 +-
 .../python/jsr223/JythonScriptEngineSetup.java  |   2 +-
 .../python/jsr223/JythonTranslatorTest.java     |  10 -
 .../jsr223/PythonGraphSONJavaTranslator.java    |   2 +-
 .../gremlin/python/jsr223/PythonProvider.java   |   5 +-
 .../tinkerpop/gremlin/server/Settings.java      |   8 +
 .../jsr223/GremlinServerGremlinPlugin.java      |  42 +++
 .../server/op/AbstractEvalOpProcessor.java      |   5 +
 .../server/util/ServerGremlinExecutor.java      |  16 +-
 .../jsr223/GremlinEnabledScriptEngineTest.java  |  37 +-
 .../groovy/plugin/HadoopGremlinPlugin.java      |   2 +
 .../groovy/plugin/HadoopRemoteAcceptor.java     |   2 +
 .../hadoop/jsr223/HadoopGremlinPlugin.java      | 159 ++++++++
 .../hadoop/jsr223/HadoopRemoteAcceptor.java     | 127 +++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   1 +
 .../neo4j/groovy/plugin/Neo4jGremlinPlugin.java |   2 +
 .../neo4j/jsr223/Neo4jGremlinPlugin.java        |  71 ++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   1 +
 pom.xml                                         |  25 +-
 .../spark/groovy/plugin/SparkGremlinPlugin.java |   2 +
 .../spark/jsr223/SparkGremlinPlugin.java        |  92 +++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   1 +
 .../groovy/plugin/TinkerGraphGremlinPlugin.java |   3 +-
 .../jsr223/TinkerGraphGremlinPlugin.java        |  72 ++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   1 +
 145 files changed, 5879 insertions(+), 364 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/708c6016/CHANGELOG.asciidoc
----------------------------------------------------------------------


[29/50] tinkerpop git commit: TINKERPOP-1570 Bumped to netty 4.0.42

Posted by sp...@apache.org.
TINKERPOP-1570 Bumped to netty 4.0.42


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

Branch: refs/heads/TINKERPOP-1490
Commit: e2b69d94c79367bdb0a0f99c8d51dbc386841c6c
Parents: 054b6f0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Dec 5 11:42:17 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Dec 6 07:12:38 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc     | 1 +
 gremlin-driver/pom.xml | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e2b69d94/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index c7841a4..5944a3f 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Bumped to Netty 4.0.42.final.
 * Fixed a bug in Gremlin-Python around `__.__()` and `__.start()`.
 * Fixed a bug around long serialization in Gremlin-Python when using Python3.
 * Deprecated `TraversalSource.withBindings()` as it is no longer needed in Gremlin-Java and never was needed for other variants.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e2b69d94/gremlin-driver/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-driver/pom.xml b/gremlin-driver/pom.xml
index e55d4a2..4f25504 100644
--- a/gremlin-driver/pom.xml
+++ b/gremlin-driver/pom.xml
@@ -26,7 +26,7 @@ limitations under the License.
     <artifactId>gremlin-driver</artifactId>
     <name>Apache TinkerPop :: Gremlin Driver</name>
     <properties>
-        <netty.version>4.0.40.Final</netty.version>
+        <netty.version>4.0.42.Final</netty.version>
     </properties>
     <dependencies>
         <dependency>


[09/50] tinkerpop git commit: TINKERPOP-1562 Get customizers for both python and jython.

Posted by sp...@apache.org.
TINKERPOP-1562 Get customizers for both python and jython.

The customizers are combined to a set and therefore should only apply once. Presumably there wouldn't be a different set of customizers for one versus the other. If there were and you wanted them separate I guess you'd have to build two separate script engine instances.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 9f33bee4d75ee359c6687d4b777bb687a459925f
Parents: 05ff0c0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Nov 26 07:37:28 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:49 2016 -0500

----------------------------------------------------------------------
 .../python/jsr223/GremlinJythonScriptEngineFactory.java  |  6 +++++-
 .../gremlin/jsr223/GremlinEnabledScriptEngineTest.java   | 11 +++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9f33bee4/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
index 696c2ea..34978a7 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
@@ -29,7 +29,9 @@ import org.python.jsr223.PyScriptEngineFactory;
 import javax.script.ScriptEngine;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -101,7 +103,9 @@ public class GremlinJythonScriptEngineFactory extends PyScriptEngineFactory impl
 
     @Override
     public GremlinScriptEngine getScriptEngine() {
-        final List<Customizer> customizers =  manager.getCustomizers(GREMLIN_JYTHON);
+        final Set<Customizer> customizers = new HashSet<>(manager.getCustomizers(GREMLIN_JYTHON));
+        customizers.addAll(manager.getCustomizers(GREMLIN_PYTHON));
+
         return (customizers.isEmpty()) ? new GremlinJythonScriptEngine() :
                 new GremlinJythonScriptEngine(customizers.toArray(new Customizer[customizers.size()]));
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9f33bee4/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
index f6bbcb8..8fa70b0 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.junit.Test;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 
@@ -79,4 +80,14 @@ public class GremlinEnabledScriptEngineTest {
             assertEquals(clazz, scriptEngine.eval(clazz.getSimpleName()));
         }
     }
+
+    @Test
+    public void shouldReturnOneCustomizers() {
+        // just returns the core plugin as the other assigned plugin doesn't match the tested engine
+        final GremlinScriptEngineManager mgr = new DefaultGremlinScriptEngineManager();
+        mgr.addPlugin(ImportGremlinPlugin.build()
+                .classImports(java.awt.Color.class)
+                .appliesTo(Collections.singletonList("fake-script-engine")).create());
+        assertEquals(1, mgr.getCustomizers(ENGINE_TO_TEST).size());
+    }
 }


[38/50] tinkerpop git commit: TINKERPOP-1490 Deprecated the old RemoteConnection submit method.

Posted by sp...@apache.org.
TINKERPOP-1490 Deprecated the old RemoteConnection submit method.

That method isn't called at all anymore - needs to be removed completely for 3.3.x.


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

Branch: refs/heads/TINKERPOP-1490
Commit: f02e18336aefd540000ecaacd157349537f1f94f
Parents: 460f124
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 14 10:08:48 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                |  1 +
 .../gremlin/process/remote/RemoteConnection.java  | 18 ++++++++++++++++--
 .../process/remote/traversal/RemoteTraversal.java |  6 +++---
 .../driver/remote/DriverRemoteConnection.java     |  6 +++++-
 4 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02e1833/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index b637552..60e1bb1 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -53,6 +53,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Added a `force` option for killing sessions without waiting for transaction close or timeout of a currently running job or multiple jobs.
 * Deprecated `Session.kill()` and `Session.manualKill()`.
 * Added `Traversal.promise()` method to allow for asynchronous traversal processing on "remote" traversals.
+* Deprecated `RemoteConnection.submit(Bytecode)` in favor of `submitAsync(Bytecode)`.
 * Added `choose(predicate,traversal)` and `choose(traversal,traversal)` to effect if/then-semantics (no else). Equivalent to `choose(x,y,identity())`.
 * Removed `ImmutablePath.TailPath` as it is no longer required with new recursion model.
 * Removed call stack recursion in `ImmutablePath`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02e1833/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
index f4e3976..1831276 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
@@ -38,7 +38,7 @@ import java.util.concurrent.CompletableFuture;
 public interface RemoteConnection extends AutoCloseable {
 
     /**
-     * @deprecated As of release 3.2.2, replaced by {@link #submit(Bytecode)}.
+     * @deprecated As of release 3.2.2, replaced by {@link #submitAsync(Bytecode)}.
      */
     @Deprecated
     public <E> Iterator<Traverser.Admin<E>> submit(final Traversal<?, E> traversal) throws RemoteConnectionException;
@@ -47,13 +47,27 @@ public interface RemoteConnection extends AutoCloseable {
      * Submits {@link Traversal} {@link Bytecode} to a server and returns a {@link RemoteTraversal}.
      * The {@link RemoteTraversal} is an abstraction over two types of results that can be returned as part of the
      * response from the server: the results of the {@link Traversal} itself and the side-effects that it produced.
+     *
+     * @deprecated As of release 3.2.4, replaced by {@link #submitAsync(Bytecode)}.
      */
+    @Deprecated
     public <E> RemoteTraversal<?,E> submit(final Bytecode bytecode) throws RemoteConnectionException;
 
     /**
      * Submits {@link Traversal} {@link Bytecode} to a server and returns a promise of a {@link RemoteTraversal}.
      * The {@link RemoteTraversal} is an abstraction over two types of results that can be returned as part of the
      * response from the server: the results of the {@link Traversal} itself and the side-effects that it produced.
+     * <p/>
+     * The default implementation calls the {@link #submit(Bytecode)} method for backward compatibility, but generally
+     * speaking this method should be implemented directly as {@link #submit(Bytecode)} is not called directly by
+     * any part of TinkerPop. Even if the {@code RemoteConnection} itself is not capable of asynchronous behaviour, it
+     * should simply implement this method in a blocking form.
      */
-    public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final Bytecode bytecode) throws RemoteConnectionException;
+    public default <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final Bytecode bytecode) throws RemoteConnectionException {
+        // default implementation for backward compatibility to 3.2.4 - this method will probably just become
+        // the new submit() in 3.3.x when the deprecation is removed
+        final CompletableFuture<RemoteTraversal<?, E>> promise = new CompletableFuture<>();
+        promise.complete(submit(bytecode));
+        return promise;
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02e1833/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
index 57b0cda..70ec27f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/RemoteTraversal.java
@@ -25,9 +25,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 
 /**
- * A {@link RemoteTraversal} is returned from {@link RemoteConnection#submit(Bytecode)}. It is iterated from within
- * {@link RemoteStep} using {@link #nextTraverser()}. Implementations should typically be given a "result" from a
- * remote source where the traversal was executed. The "result" should be an iterator which preferably has its data
+ * A {@link RemoteTraversal} is returned from {@link RemoteConnection#submitAsync(Bytecode)}. It is iterated from
+ * within {@link RemoteStep} using {@link #nextTraverser()}. Implementations should typically be given a "result" from
+ * a remote source where the traversal was executed. The "result" should be an iterator which preferably has its data
  * bulked.
  * <p/>
  * Note that internally {@link #nextTraverser()} is called from within a loop (specifically in

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02e1833/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index be3fa28..d6415de 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -165,7 +165,7 @@ public class DriverRemoteConnection implements RemoteConnection {
     }
 
     /**
-     * @deprecated As of release 3.2.2, replaced by {@link #submit(Bytecode)}.
+     * @deprecated As of release 3.2.2, replaced by {@link #submitAsync(Bytecode)}.
      */
     @Deprecated
     @Override
@@ -183,6 +183,10 @@ public class DriverRemoteConnection implements RemoteConnection {
         }
     }
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #submitAsync(Bytecode)}.
+     */
+    @Deprecated
     @Override
     public <E> RemoteTraversal<?,E> submit(final Bytecode bytecode) throws RemoteConnectionException {
         try {


[05/50] tinkerpop git commit: TINKERPOP-1562 Added more tests for the GremlnPluginAdapter

Posted by sp...@apache.org.
TINKERPOP-1562 Added more tests for the GremlnPluginAdapter


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

Branch: refs/heads/TINKERPOP-1490
Commit: 35c8fcd651cf0f4788eb4e0435ed7fa966304d5c
Parents: 33460fc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 23 15:36:13 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../groovy/plugin/GremlinPluginAdapterTest.java | 70 ++++++++++++++++++++
 .../groovy/plugin/script-customizer-1.groovy    |  3 +
 .../groovy/plugin/script-customizer-2.groovy    |  2 +
 pom.xml                                         |  1 +
 4 files changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35c8fcd6/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
index dd582b1..c3ade04 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
@@ -18,12 +18,28 @@
  */
 package org.apache.tinkerpop.gremlin.console.groovy.plugin;
 
+import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn;
+import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultBindingsCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultScriptCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin;
 import org.junit.Test;
 
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+import java.io.File;
 import java.time.DayOfWeek;
 import java.time.temporal.TemporalAccessor;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -57,4 +73,58 @@ public class GremlinPluginAdapterTest {
         assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + ".from"));
         assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + ".values"));
     }
+
+    @Test
+    public void shouldAdaptForScriptCustomizer() throws Exception {
+        final File scriptFile1 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-1.groovy", ".groovy");
+        final File scriptFile2 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-2.groovy", ".groovy");
+        final Set<String> files = new HashSet<>();
+        files.add(scriptFile1.getAbsolutePath());
+        files.add(scriptFile2.getAbsolutePath());
+        final ScriptFileGremlinPlugin plugin = ScriptFileGremlinPlugin.build().files(files).create();
+        final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
+
+        assertEquals(plugin.getName(), adapter.getName());
+
+        final List<String> evals = new ArrayList<>();
+        final SpyPluginAcceptor spy = new SpyPluginAcceptor(evals::add);
+        adapter.pluginTo(spy);
+
+        assertEquals("x = 1 + 1\n" +
+                     "y = 10 * x\n" +
+                     "z = 1 + x + y", evals.get(0));
+        assertEquals("l = g.V(z).out()\n" +
+                     "        .group().by('name')", evals.get(1));
+    }
+
+    @Test
+    public void shouldAdaptForBindingsCustomizer() throws Exception {
+        final Bindings bindings = new SimpleBindings();
+        bindings.put("x", 1);
+        bindings.put("y", "yes");
+        bindings.put("z", true);
+        final BindingsCustomizer bindingsCustomizer = new DefaultBindingsCustomizer(bindings);
+        final GremlinPlugin plugin = new GremlinPlugin() {
+            @Override
+            public String getName() {
+                return "anon-bindings";
+            }
+
+            @Override
+            public Optional<Customizer[]> getCustomizers(final String scriptEngineName) {
+                return Optional.of(new Customizer[]{bindingsCustomizer});
+            }
+        };
+        final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
+
+        assertEquals(plugin.getName(), adapter.getName());
+
+        final SpyPluginAcceptor spy = new SpyPluginAcceptor();
+        adapter.pluginTo(spy);
+
+        final Map<String,Object> bindingsFromSpy = spy.getBindings();
+        assertEquals(1, bindingsFromSpy.get("x"));
+        assertEquals("yes", bindingsFromSpy.get("y"));
+        assertEquals(true, bindingsFromSpy.get("z"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35c8fcd6/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy
new file mode 100644
index 0000000..c2cc784
--- /dev/null
+++ b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy
@@ -0,0 +1,3 @@
+x = 1 + 1
+y = 10 * x
+z = 1 + x + y
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35c8fcd6/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy
new file mode 100644
index 0000000..1a4f9a9
--- /dev/null
+++ b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy
@@ -0,0 +1,2 @@
+l = g.V(z).out()
+        .group().by('name')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35c8fcd6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0bff1e7..37c7c7e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,6 +287,7 @@ limitations under the License.
                         <exclude>**/goal.txt</exclude>
                         <exclude>**/src/main/resources/META-INF/services/**</exclude>
                         <exclude>**/src/test/resources/META-INF/services/**</exclude>
+                        <exclude>**/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-*.groovy</exclude>
                         <exclude>**/src/test/resources/org/apache/tinkerpop/gremlin/jsr223/script-customizer-*.groovy</exclude>
                         <exclude>**/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/*.txt</exclude>
                         <exclude>**/src/main/ext/**</exclude>


[31/50] tinkerpop git commit: [driver_remote] Encode Bytecode as a dict, not a string

Posted by sp...@apache.org.
[driver_remote] Encode Bytecode as a dict, not a string


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

Branch: refs/heads/TINKERPOP-1490
Commit: 0b74ea40aacaab519357626fa4c2c580ffe6b148
Parents: 595cf3b
Author: Branden Moore <bj...@sandia.gov>
Authored: Wed Dec 7 12:53:38 2016 -0700
Committer: Branden Moore <bj...@sandia.gov>
Committed: Wed Dec 7 12:53:38 2016 -0700

----------------------------------------------------------------------
 .../main/jython/gremlin_python/driver/driver_remote_connection.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0b74ea40/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index eab06f1..d975f60 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -66,7 +66,7 @@ class DriverRemoteConnection(RemoteConnection):
             "op": "bytecode",
             "processor": "traversal",
             "args": {
-                "gremlin": self._graphson_writer.writeObject(bytecode),
+                "gremlin": self._graphson_writer.toDict(bytecode),
                 "aliases": {"g": self.traversal_source}
             }
         }


[32/50] tinkerpop git commit: Minor fix to iteration completion logic

Posted by sp...@apache.org.
Minor fix to iteration completion logic

Had to store the value of hasNext() as some graphs may open a new transaction on such calls and leave it hanging. CTR


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

Branch: refs/heads/TINKERPOP-1490
Commit: 966df98921e42a2918ea9f676ac2ad3a3027d64f
Parents: 595cf3b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Dec 8 09:18:56 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Dec 8 09:21:24 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/server/op/AbstractOpProcessor.java    | 9 +++++++--
 .../gremlin/server/op/traversal/TraversalOpProcessor.java   | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/966df989/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
index 5482de1..c3ac475 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
@@ -154,9 +154,14 @@ public abstract class AbstractOpProcessor implements OpProcessor {
                         break;
                     }
 
+                    // track whether there is anything left in the iterator because it needs to be accessed after
+                    // the transaction could be closed - in that case a call to hasNext() could open a new transaction
+                    // unintentionally
+                    final boolean moreInIterator = itty.hasNext();
+
                     try {
                         // only need to reset the aggregation list if there's more stuff to write
-                        if (itty.hasNext())
+                        if (moreInIterator)
                             aggregate = new ArrayList<>(resultIterationBatchSize);
                         else {
                             // iteration and serialization are both complete which means this finished successfully. note that
@@ -179,7 +184,7 @@ public abstract class AbstractOpProcessor implements OpProcessor {
                         throw ex;
                     }
 
-                    if (!itty.hasNext()) iterateComplete(ctx, msg, itty);
+                    if (!moreInIterator) iterateComplete(ctx, msg, itty);
 
                     // the flush is called after the commit has potentially occurred.  in this way, if a commit was
                     // required then it will be 100% complete before the client receives it. the "frame" at this point

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/966df989/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 5edbe26..5461007 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -110,7 +110,7 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
         }};
     }
 
-    private static Cache<UUID, TraversalSideEffects> cache = null;
+    protected static Cache<UUID, TraversalSideEffects> cache = null;
 
     public TraversalOpProcessor() {
         super(false);


[35/50] tinkerpop git commit: Merge branch 'TINKERPOP-1570' into tp32

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1570' into tp32


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

Branch: refs/heads/TINKERPOP-1490
Commit: fdeb7a0b16e80e6405f9e9584db9c0bc7dd986dc
Parents: b88b00c e2b69d9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Dec 12 07:06:25 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Dec 12 07:06:25 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc     | 1 +
 gremlin-driver/pom.xml | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fdeb7a0b/CHANGELOG.asciidoc
----------------------------------------------------------------------


[13/50] tinkerpop git commit: TINKERPOP-1562 Hook up Console to do core imports under v3d3

Posted by sp...@apache.org.
TINKERPOP-1562 Hook up Console to do core imports under v3d3


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

Branch: refs/heads/TINKERPOP-1490
Commit: 83689211d05905fb4fd31375a8db225200a72ae5
Parents: 6d1b97e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 30 07:28:37 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    | 21 +++++++++++++-------
 .../ConsoleImportCustomizerProvider.groovy      |  2 ++
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/83689211/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index d39e085..a2e518c 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -31,6 +31,8 @@ import org.apache.tinkerpop.gremlin.console.commands.UninstallCommand
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn
 import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
+import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation
 import org.apache.tinkerpop.gremlin.structure.Edge
 import org.apache.tinkerpop.gremlin.structure.T
@@ -103,13 +105,18 @@ class Console {
         // hide output temporarily while imports execute
         showShellEvaluationOutput(false)
 
-        // TODO: register CoreGremlinPlugin if using v3d3
-
-        // add the default imports
-        new ConsoleImportCustomizerProvider().getCombinedImports().stream()
-                .collect { IMPORT_SPACE + it }.each { groovy.execute(it) }
-        new ConsoleImportCustomizerProvider().getCombinedStaticImports().stream()
-                .collect { IMPORT_STATIC_SPACE + it }.each { groovy.execute(it) }
+        if (Mediator.useV3d3) {
+            def imports = (ImportCustomizer) CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").get()[0]
+            imports.classImports.collect { IMPORT_SPACE + it.canonicalName }.each { groovy.execute(it) }
+            imports.methodImports.collect { IMPORT_STATIC_SPACE + it.getDeclaringClass().getCanonicalName() + "." + it.name}.each{ groovy.execute(it) }
+            imports.enumImports.collect { IMPORT_STATIC_SPACE + it.getDeclaringClass().getCanonicalName() + "." + it.name()}.each{ groovy.execute(it) }
+        } else {
+            // add the default imports
+            new ConsoleImportCustomizerProvider().getCombinedImports().stream()
+                    .collect { IMPORT_SPACE + it }.each { groovy.execute(it) }
+            new ConsoleImportCustomizerProvider().getCombinedStaticImports().stream()
+                    .collect { IMPORT_STATIC_SPACE + it }.each { groovy.execute(it) }
+        }
 
         final InteractiveShellRunner runner = new InteractiveShellRunner(groovy, handlePrompt)
         runner.setErrorHandler(handleError)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/83689211/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
index 0404e93..85fda8c 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
@@ -23,7 +23,9 @@ import groovy.sql.Sql
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 class ConsoleImportCustomizerProvider extends AbstractImportCustomizerProvider {
     public ConsoleImportCustomizerProvider() {
         // useful groovy bits that are good for the Console


[16/50] tinkerpop git commit: TINKERPOP-1562 Fix yet another compilation error.

Posted by sp...@apache.org.
TINKERPOP-1562 Fix yet another compilation error.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 9218e8a1b4b532fbbfdcba00f005c8e9fdf95c59
Parents: 873ac61
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 17:03:34 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9218e8a1/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
index c3ade04..cb6fa60 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
@@ -78,7 +78,7 @@ public class GremlinPluginAdapterTest {
     public void shouldAdaptForScriptCustomizer() throws Exception {
         final File scriptFile1 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-1.groovy", ".groovy");
         final File scriptFile2 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-2.groovy", ".groovy");
-        final Set<String> files = new HashSet<>();
+        final List<String> files = new ArrayList<>();
         files.add(scriptFile1.getAbsolutePath());
         files.add(scriptFile2.getAbsolutePath());
         final ScriptFileGremlinPlugin plugin = ScriptFileGremlinPlugin.build().files(files).create();


[21/50] tinkerpop git commit: TINKERPOP-1562 Use List of files to preserve order in script customzier

Posted by sp...@apache.org.
TINKERPOP-1562 Use List of files to preserve order in script customzier


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

Branch: refs/heads/TINKERPOP-1490
Commit: 2d49710b2f7a45453aa1165074440e704a007044
Parents: 8dc9b1f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 16:29:10 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java       | 3 +--
 .../tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java       | 4 +++-
 .../tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java   | 5 ++---
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d49710b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java
index 9640f28..c996cae 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java
@@ -24,7 +24,6 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.util.Collection;
 import java.util.List;
-import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -37,7 +36,7 @@ public class DefaultScriptCustomizer implements ScriptCustomizer {
 
     private final Collection<List<String>> scripts;
 
-    public DefaultScriptCustomizer(final Set<File> files) {
+    public DefaultScriptCustomizer(final List<File> files) {
         this(files.stream().map(f -> {
             try {
                 return Files.lines(f.toPath(), StandardCharsets.UTF_8).collect(Collectors.toList());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d49710b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
index 757001c..93ad9d8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ScriptFileGremlinPlugin.java
@@ -20,8 +20,10 @@ package org.apache.tinkerpop.gremlin.jsr223;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -44,7 +46,7 @@ public final class ScriptFileGremlinPlugin extends AbstractGremlinPlugin {
     public static final class Builder {
 
         private final Set<String> appliesTo = new HashSet<>();
-        private Set<File> files = new HashSet<>();
+        private List<File> files = new ArrayList<>();
 
         private Builder() {}
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d49710b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
index 3e4da13..07ab770 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizerTest.java
@@ -23,10 +23,9 @@ import org.junit.Test;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
 
@@ -39,7 +38,7 @@ public class DefaultScriptCustomizerTest {
     public void shouldOpenViaPropertiesFileConfig() throws IOException {
         final File scriptFile1 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-1.groovy", ".groovy");
         final File scriptFile2 = TestHelper.generateTempFileFromResource(DefaultScriptCustomizerTest.class, "script-customizer-2.groovy", ".groovy");
-        final Set<File> files = new HashSet<>();
+        final List<File> files = new ArrayList<>();
         files.add(scriptFile1);
         files.add(scriptFile2);
         final ScriptCustomizer scripts = new DefaultScriptCustomizer(files);


[19/50] tinkerpop git commit: TINKERPOP-1562 Deprecated plugin exceptions.

Posted by sp...@apache.org.
TINKERPOP-1562 Deprecated plugin exceptions.

These are needed anymore under the revised plugin model in gremlin-core.


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

Branch: refs/heads/TINKERPOP-1490
Commit: a2a23596322acf8201a67ac7d3baf8ef7dbb135d
Parents: 80f79bc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 09:21:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../gremlin/jsr223/GremlinPluginException.java  | 41 --------------------
 .../groovy/plugin/GremlinPluginException.java   |  2 +
 .../plugin/IllegalEnvironmentException.java     |  2 +
 .../plugin/PluginInitializationException.java   |  2 +
 4 files changed, 6 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a2a23596/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPluginException.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPluginException.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPluginException.java
deleted file mode 100644
index ce4ab2f..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPluginException.java
+++ /dev/null
@@ -1,41 +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.
- */
-package org.apache.tinkerpop.gremlin.jsr223;
-
-/**
- * Base exception for {@link GremlinPlugin}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public abstract class GremlinPluginException extends Exception {
-    public GremlinPluginException() {
-    }
-
-    public GremlinPluginException(final String message) {
-        super(message);
-    }
-
-    public GremlinPluginException(final String message, final Throwable cause) {
-        super(message, cause);
-    }
-
-    public GremlinPluginException(final Throwable cause) {
-        super(cause);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a2a23596/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java
index d85c743..c8664c7 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java
@@ -22,7 +22,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin;
  * Base exception for {@link GremlinPlugin}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 public abstract class GremlinPluginException extends Exception {
     public GremlinPluginException() {
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a2a23596/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java
index 86dbcbc..8d6fbe2 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java
@@ -23,7 +23,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin;
  * the needs of the {@link GremlinPlugin}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 public class IllegalEnvironmentException extends GremlinPluginException {
     public IllegalEnvironmentException(final GremlinPlugin plugin, final String... expectedKeys) {
         super(String.format("The %s plugin may not be compatible with this environment - requires the follow ScriptEngine environment keys [%s]", plugin.getName(), String.join(",", expectedKeys)));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a2a23596/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java
index 7d87215..0dd6fc1 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java
@@ -23,7 +23,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin;
  * {@code ScriptEngine}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 public class PluginInitializationException extends GremlinPluginException {
     public PluginInitializationException(final String message) {
         super(message);


[42/50] tinkerpop git commit: TINKERPOP-1490 Updated dev docs on RemoteConnection API

Posted by sp...@apache.org.
TINKERPOP-1490 Updated dev docs on RemoteConnection API


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

Branch: refs/heads/TINKERPOP-1490
Commit: 460f1243b7b0cddb52fc687b370158c1860c9cb7
Parents: 81fa7e0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 14 10:08:17 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:00:40 2016 -0500

----------------------------------------------------------------------
 docs/src/dev/provider/index.asciidoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/460f1243/docs/src/dev/provider/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc
index 8760d01..71d071f 100644
--- a/docs/src/dev/provider/index.asciidoc
+++ b/docs/src/dev/provider/index.asciidoc
@@ -427,7 +427,7 @@ iterate.
 There is one method to implement on `RemoteConnection`:
 
 [source,java]
-public <E> RemoteTraversal<?,E> submit(final Bytecode bytecode) throws RemoteConnectionException;
+public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final Bytecode bytecode) throws RemoteConnectionException;
 
 Note that it returns a `RemoteTraversal`. This interface should also be implemented and in most cases implementers can
 simply extend the `AbstractRemoteTraversal`, which provides default implementations for all the `Traversal` methods


[04/50] tinkerpop git commit: TINKERPOP-1562 Add new Neo4j GremlinPlugin and deprecated old one

Posted by sp...@apache.org.
TINKERPOP-1562 Add new Neo4j GremlinPlugin and deprecated old one


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

Branch: refs/heads/TINKERPOP-1490
Commit: 2e65a113e2a9e0b56bcbdba4c124cb1590759cf3
Parents: c41250c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 22 11:15:57 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../groovy/plugin/AbstractGremlinPlugin.java    |  2 +
 .../neo4j/groovy/plugin/Neo4jGremlinPlugin.java |  1 +
 .../neo4j/jsr223/Neo4jGremlinPlugin.java        | 71 ++++++++++++++++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |  1 +
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |  1 +
 .../jsr223/TinkerGraphGremlinPlugin.java        |  7 +-
 6 files changed, 78 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java
index fcc8d05..090da6e 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java
@@ -30,7 +30,9 @@ import java.util.Map;
  * shell and io objects.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin}.
  */
+@Deprecated
 public abstract class AbstractGremlinPlugin implements GremlinPlugin {
     public static final String ENV_CONSOLE_IO = "ConsolePluginAcceptor.io";
     public static final String ENV_CONSOLE_SHELL = "ConsolePluginAcceptor.shell";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
index f3fe37c..9053cf3 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java
@@ -30,6 +30,7 @@ import java.util.Set;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.neo4j.jsr223.Neo4jGremlinPlugin}.
  */
 public final class Neo4jGremlinPlugin extends AbstractGremlinPlugin {
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
new file mode 100644
index 0000000..82a8d18
--- /dev/null
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.neo4j.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jEdge;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jElement;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraphVariables;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jHelper;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jProperty;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertex;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertexProperty;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class Neo4jGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.neo4j";
+
+    private static final ImportCustomizer imports;
+
+    static {
+        try {
+            imports = DefaultImportCustomizer.build()
+                    .addClassImports(Neo4jEdge.class,
+                            Neo4jElement.class,
+                            Neo4jGraph.class,
+                            Neo4jGraphVariables.class,
+                            Neo4jHelper.class,
+                            Neo4jProperty.class,
+                            Neo4jVertex.class,
+                            Neo4jVertexProperty.class)
+                    .addMethodImports(LabelP.class.getMethod("of", String.class)).create();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public Neo4jGremlinPlugin() {
+        super(NAME, imports);
+    }
+
+    @Override
+    public boolean requireRestart() {
+        return true;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..cb86e57
--- /dev/null
+++ b/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1 @@
+org.apache.tinkerpop.gremlin.neo4j.jsr223.Neo4jGremlinPlugin
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..939b6ff
--- /dev/null
+++ b/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1 @@
+org.apache.tinkerpop.gremlin.spark.jsr223.SparkGremlinPlugin
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2e65a113/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java
index 68e649c..19188d2 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java
@@ -19,7 +19,6 @@
 package org.apache.tinkerpop.gremlin.tinkergraph.jsr223;
 
 import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
-import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
 import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
@@ -41,13 +40,11 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty;
 
-import java.util.Optional;
-
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class TinkerGraphGremlinPlugin extends AbstractGremlinPlugin {
-    private static final String MODULE_NAME = "tinkerpop.tinkergraph";
+    private static final String NAME = "tinkerpop.tinkergraph";
 
     private static final ImportCustomizer imports = DefaultImportCustomizer.build()
             .addClassImports(TinkerEdge.class,
@@ -70,6 +67,6 @@ public final class TinkerGraphGremlinPlugin extends AbstractGremlinPlugin {
                              TinkerWorkerPool.class).create();
 
     public TinkerGraphGremlinPlugin() {
-        super(MODULE_NAME, imports);
+        super(NAME, imports);
     }
 }


[50/50] tinkerpop git commit: raise error if side effect method called while loop is running

Posted by sp...@apache.org.
raise error if side effect method called while loop is running


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

Branch: refs/heads/TINKERPOP-1490
Commit: 79dac23b2f305911e651648c5b43fb3fe59d94c8
Parents: a8c8b65
Author: davebshow <da...@gmail.com>
Authored: Wed Dec 7 16:37:05 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:14:20 2016 -0500

----------------------------------------------------------------------
 .../driver/driver_remote_connection.py          |  4 ++--
 .../gremlin_python/driver/remote_connection.py  | 12 +++++++++-
 .../driver/test_driver_remote_connection.py     | 24 +++++++++++---------
 3 files changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/79dac23b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index babb113..b951cdf 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -54,13 +54,13 @@ class DriverRemoteConnection(RemoteConnection):
         request_id = str(uuid.uuid4())
         traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
         keys, value, close = self._get_side_effect_lambdas(request_id)
-        return RemoteTraversal(iter(traversers), RemoteTraversalSideEffects(keys, value, close))
+        return RemoteTraversal(iter(traversers), RemoteTraversalSideEffects(keys, value, close, self._loop))
 
     def submit_async(self, bytecode):
         request_id = str(uuid.uuid4())
         future_traversers = self.submit_traversal_bytecode(request_id, bytecode)
         keys, value, close = self._get_side_effect_lambdas(request_id)
-        side_effects = RemoteTraversalSideEffects(keys, value, close)
+        side_effects = RemoteTraversalSideEffects(keys, value, close, self._loop)
         return RemoteTraversal(future_traversers, side_effects)
 
     @gen.coroutine

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/79dac23b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index 93c92b7..f7ed48e 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -57,20 +57,27 @@ class RemoteTraversal(Traversal):
 
 
 class RemoteTraversalSideEffects(TraversalSideEffects):
-    def __init__(self, keys_lambda, value_lambda, close_lambda):
+    def __init__(self, keys_lambda, value_lambda, close_lambda, loop):
         self._keys_lambda = keys_lambda
         self._value_lambda = value_lambda
         self._close_lambda = close_lambda
+        self._loop = loop
         self._keys = set()
         self._side_effects = {}
         self._closed = False
 
     def keys(self):
+        if self._loop._running:
+            raise RuntimeError("Cannot call side effect methods"
+                               "while event loop is running")
         if not self._closed:
             self._keys = self._keys_lambda()
         return self._keys
 
     def get(self, key):
+        if self._loop._running:
+            raise RuntimeError("Cannot call side effect methods"
+                               "while event loop is running")
         if not self._side_effects.get(key):
             if not self._closed:
                 results = self._value_lambda(key)
@@ -81,6 +88,9 @@ class RemoteTraversalSideEffects(TraversalSideEffects):
         return self._side_effects[key]
 
     def close(self):
+        if self._loop._running:
+            raise RuntimeError("Cannot call side effect methods"
+                               "while event loop is running")
         results = self._close_lambda()
         self._closed = True
         return results

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/79dac23b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index c9e64c5..783cf7e 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -211,6 +211,7 @@ class TestDriverRemoteConnection(TestCase):
             assert count == 6
 
         loop.run_sync(go)
+        connection.close()
 
     def test_promise_side_effects(self):
         loop = ioloop.IOLoop.current()
@@ -224,22 +225,17 @@ class TestDriverRemoteConnection(TestCase):
         @gen.coroutine
         def go():
             traversal = yield g.V().aggregate('a').promise()
-            # Trying to get side effect keys throws error - BAD
+            # Calling synchronous side effect methods from coroutine raises.
             with pytest.raises(RuntimeError):
                 keys = traversal.side_effects.keys()
-                # IOLoop is now hosed.
 
-        loop.run_sync(go)
+            with pytest.raises(RuntimeError):
+                keys = traversal.side_effects.get('a')
 
-        # Get a new IOLoop - this should happen for each test case.
-        connection.close()
-        ioloop.IOLoop.clear_instance()
-        loop.close()
-        loop = ioloop.IOLoop()
-        loop.make_current()
+            with pytest.raises(RuntimeError):
+                keys = traversal.side_effects.close()
 
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        g = Graph().traversal().withRemote(connection)
+        loop.run_sync(go)
 
         # If we return the traversal though, we can use side effects per usual.
         @gen.coroutine
@@ -251,6 +247,12 @@ class TestDriverRemoteConnection(TestCase):
         traversal = loop.run_sync(go)
         a, = traversal.side_effects.keys()
         assert  a == 'a'
+        results = traversal.side_effects.get('a')
+        assert results
+        results = traversal.side_effects.close()
+        assert not results
+
+        connection.close()
 
 
 if __name__ == '__main__':


[08/50] tinkerpop git commit: TINKERPOP-1562 Added gremlin-console plugins under the new model.

Posted by sp...@apache.org.
TINKERPOP-1562 Added gremlin-console plugins under the new model.

Had to rework the PluggedIn adapters a bit so that they could better handle Console environment variable.s


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

Branch: refs/heads/TINKERPOP-1490
Commit: a91fb80e64ceb2e5c97b5f8c2ef20205d075ec18
Parents: bb5b47d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 22 16:35:16 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:28:51 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    |   4 +-
 .../console/jsr223/GephiRemoteAcceptor.groovy   | 372 +++++++++++++++++++
 .../gremlin/console/plugin/PluggedIn.groovy     |  14 +-
 .../groovy/plugin/DriverGremlinPlugin.java      |   2 +
 .../groovy/plugin/DriverRemoteAcceptor.java     |   2 +
 .../groovy/plugin/GephiGremlinPlugin.java       |   1 +
 .../groovy/plugin/UtilitiesGremlinPlugin.java   |   1 +
 .../console/jsr223/DriverGremlinPlugin.java     | 106 ++++++
 .../console/jsr223/DriverRemoteAcceptor.java    | 238 ++++++++++++
 .../console/jsr223/GephiGremlinPlugin.java      |  45 +++
 .../console/jsr223/UtilitiesGremlinPlugin.java  | 106 ++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |   3 +
 .../jsr223/UtilitiesGremlinPluginScript.groovy  |  52 +++
 .../groovy/plugin/GremlinPluginAdapterTest.java |   5 +-
 14 files changed, 940 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index cb6e90f..d39e085 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -131,9 +131,9 @@ class Console {
                 def pluggedIn
 
                 if (Mediator.useV3d3) {
-                    pluggedIn = new PluggedIn(new PluggedIn.GremlinPluginAdapter(plugin), groovy, io, false)
+                    pluggedIn = new PluggedIn(new PluggedIn.GremlinPluginAdapter((org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin) plugin, groovy, io), groovy, io, false)
                 } else {
-                    pluggedIn = new PluggedIn(plugin, groovy, io, false)
+                    pluggedIn = new PluggedIn((GremlinPlugin) plugin, groovy, io, false)
                 }
 
                 mediator.availablePlugins.put(plugin.class.name, pluggedIn)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
new file mode 100644
index 0000000..dbc1156
--- /dev/null
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/jsr223/GephiRemoteAcceptor.groovy
@@ -0,0 +1,372 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.console.jsr223
+
+import groovy.json.JsonOutput
+import groovy.json.JsonSlurper
+import groovy.transform.CompileStatic
+import org.apache.http.client.methods.CloseableHttpResponse
+import org.apache.http.client.methods.HttpUriRequest
+import org.apache.http.client.methods.RequestBuilder
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import org.apache.http.util.EntityUtils
+import org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.structure.Edge
+import org.apache.tinkerpop.gremlin.structure.Graph
+import org.apache.tinkerpop.gremlin.structure.Vertex
+import org.codehaus.groovy.tools.shell.Groovysh
+import org.codehaus.groovy.tools.shell.IO
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Randall Barnhart (randompi@gmail.com)
+ */
+class GephiRemoteAcceptor implements RemoteAcceptor {
+
+    private String host = "localhost"
+    private int port = 8080
+    private String workspace = "workspace1"
+
+    private final Groovysh shell
+    private final IO io
+
+    private final Random rand = new Random();
+    boolean traversalSubmittedForViz = false
+    long vizStepDelay
+    private float[] vizStartRGBColor
+    private float[] vizDefaultRGBColor
+    private char vizColorToFade
+    private float vizColorFadeRate
+    private float vizStartSize
+    private float vizSizeDecrementRate
+    private Map vertexAttributes = [:]
+
+    private CloseableHttpClient httpclient = HttpClients.createDefault();
+
+    public GephiRemoteAcceptor(final Groovysh shell, final IO io) {
+        this.shell = shell
+        this.io = io
+
+        // traversal visualization defaults
+        vizStepDelay = 1000;                 // 1 second pause between viz of steps
+        vizStartRGBColor = [0.0f, 1.0f, 0.5f]  // light aqua green
+        vizDefaultRGBColor = [0.6f, 0.6f, 0.6f]  // light grey
+        vizColorToFade = 'g'                 // will fade so blue is strongest
+        vizColorFadeRate = 0.7               // the multiplicative rate to fade visited vertices
+        vizStartSize = 10
+        vizSizeDecrementRate = 0.33f
+    }
+
+    @Override
+    connect(final List<String> args) throws RemoteException {
+        if (args.size() >= 1)
+            workspace = args[0]
+
+        if (args.size() >= 2)
+            host = args[1]
+
+        if (args.size() >= 3) {
+            try {
+                port = Integer.parseInt(args[2])
+            } catch (Exception ex) {
+                throw new RemoteException("Port must be an integer value")
+            }
+        }
+
+        def vizConfig = " with stepDelay:$vizStepDelay, startRGBColor:$vizStartRGBColor, " +
+                "colorToFade:$vizColorToFade, colorFadeRate:$vizColorFadeRate, startSize:$vizStartSize," +
+                "sizeDecrementRate:$vizSizeDecrementRate"
+
+        return "Connection to Gephi - http://$host:$port/$workspace" + vizConfig
+    }
+
+    @Override
+    Object configure(final List<String> args) throws RemoteException {
+        if (args.size() < 2)
+            throw new RemoteException("Invalid config arguments - check syntax")
+
+        if (args[0] == "host")
+            host = args[1]
+        else if (args[0] == "port") {
+            try {
+                port = Integer.parseInt(args[1])
+            } catch (Exception ignored) {
+                throw new RemoteException("Port must be an integer value")
+            }
+        } else if (args[0] == "workspace")
+            workspace = args[1]
+        else if (args[0] == "stepDelay")
+            parseVizStepDelay(args[1])
+        else if (args[0] == "startRGBColor")
+            parseVizStartRGBColor(args[1])
+        else if (args[0] == "colorToFade")
+            parseVizColorToFade(args[1])
+        else if (args[0] == "colorFadeRate")
+            parseVizColorFadeRate(args[1])
+        else if (args[0] == "sizeDecrementRate")
+            parseVizSizeDecrementRate(args[1])
+        else if (args[0] == "startSize")
+            parseVizStartSize(args[1])
+        else if (args[0] == "visualTraversal") {
+            def graphVar = shell.interp.context.getVariable(args[1])
+            if (!(graphVar instanceof Graph))
+                throw new RemoteException("Invalid argument to 'visualTraversal' - first parameter must be a Graph instance")
+
+            def gVar = args.size() == 3 ? args[2] : "vg"
+            def theG = GraphTraversalSource.build().with(new GephiTraversalVisualizationStrategy(this)).create(graphVar)
+            shell.interp.context.setVariable(gVar, theG)
+        } else
+            throw new RemoteException("Invalid config arguments - check syntax")
+
+        return "Connection to Gephi - http://$host:$port/$workspace" +
+                " with stepDelay:$vizStepDelay, startRGBColor:$vizStartRGBColor, " +
+                "colorToFade:$vizColorToFade, colorFadeRate:$vizColorFadeRate, startSize:$vizStartSize," +
+                "sizeDecrementRate:$vizSizeDecrementRate"
+    }
+
+    @Override
+    @CompileStatic
+    Object submit(final List<String> args) throws RemoteException {
+        final String line = String.join(" ", args)
+        if (line.trim() == "clear") {
+            clearGraph()
+            io.out.println("Gephi workspace cleared")
+            return
+        }
+
+        // need to clear the vertex attributes
+        vertexAttributes.clear()
+
+        // this tells the GraphTraversalVisualizationStrategy that if the line eval's to a traversal it should
+        // try to visualize it
+        traversalSubmittedForViz = true
+
+        // get the colors/sizes back to basics before trying visualize
+        resetColorsSizes()
+
+        final Object o = shell.execute(line)
+        if (o instanceof Graph) {
+            clearGraph()
+            def graph = (Graph) o
+            def g = graph.traversal()
+            g.V().sideEffect { addVertexToGephi(g, it.get()) }.iterate()
+        }
+
+        traversalSubmittedForViz = false
+    }
+
+    @Override
+    void close() throws IOException {
+        httpclient.close()
+    }
+
+    /**
+     * Visits the last set of vertices traversed and degrades their color and size.
+     */
+    def updateVisitedVertices(def List except = []) {
+        vertexAttributes.keySet().findAll{ vertexId -> !except.contains(vertexId) }.each { String vertexId ->
+            def attrs = vertexAttributes[vertexId]
+            float currentColor = attrs.color
+            currentColor *= vizColorFadeRate
+
+            int currentSize = attrs["size"]
+            currentSize = Math.max(vizStartSize, currentSize - (currentSize * vizSizeDecrementRate))
+
+            vertexAttributes.get(vertexId).color = currentColor
+            vertexAttributes.get(vertexId).size = currentSize
+
+            changeVertexAttributes(vertexId)
+        }
+    }
+
+    def changeVertexAttributes(def String vertexId) {
+        def props = [:]
+        props.put(vizColorToFade.toString(), vertexAttributes[vertexId].color)
+        props.put("size", vertexAttributes[vertexId].size)
+        updateGephiGraph([cn: [(vertexId): props]])
+    }
+
+    /**
+     * Visit a vertex traversed and initialize its color and size.
+     */
+    def visitVertexInGephi(def Vertex v) {
+        def props = [:]
+        props.put('r', vizStartRGBColor[0])
+        props.put('g', vizStartRGBColor[1])
+        props.put('b', vizStartRGBColor[2])
+        props.put('size', vizStartSize * 2.5)
+        props.put('visited', 1)
+
+        updateGephiGraph([cn: [(v.id().toString()): props]])
+
+        vertexAttributes[v.id().toString()] = [color: vizStartRGBColor[fadeColorIndex()], size: vizStartSize * 2.5, touch: 1]
+    }
+
+    def fadeColorIndex() {
+        if (vizColorToFade == 'r')
+            return 0
+        else if (vizColorToFade == 'g')
+            return 1
+        else if (vizColorToFade == 'b')
+            return 2
+    }
+
+    def addVertexToGephi(def GraphTraversalSource g, def Vertex v, def boolean ignoreEdges = false) {
+        // grab the first property value from the strategies of values
+        def props = g.V(v).valueMap().next().collectEntries { kv -> [(kv.key): kv.value[0]] }
+        props << [label: v.label()]
+        props.put('r', vizDefaultRGBColor[0])
+        props.put('g', vizDefaultRGBColor[1])
+        props.put('b', vizDefaultRGBColor[2])
+        props.put('x', rand.nextFloat())
+        props.put('y', rand.nextFloat())
+        props.put('size', 10)
+        props.put('visited', 0)
+
+        // only add if it does not exist in graph already
+        if (!getFromGephiGraph([operation: "getNode", id: v.id().toString()]).isPresent())
+            updateGephiGraph([an: [(v.id().toString()): props]])
+
+        if (!ignoreEdges) {
+            g.V(v).outE().sideEffect {
+                addEdgeToGephi(g, it.get())
+            }.iterate()
+        }
+    }
+
+    @CompileStatic
+    def addEdgeToGephi(def GraphTraversalSource g, def Edge e) {
+        def props = g.E(e).valueMap().next()
+        props.put('label', e.label())
+        props.put('source', e.outVertex().id().toString())
+        props.put('target', e.inVertex().id().toString())
+        props.put('directed', true)
+        props.put('visited', 0)
+
+        // make sure the in vertex is there but don't add its edges - that will happen later as we are looping
+        // all vertices in the graph
+        addVertexToGephi(g, e.inVertex(), true)
+
+        // both vertices are definitely there now, so add the edge
+        updateGephiGraph([ae: [(e.id().toString()): props]])
+    }
+
+    def clearGraph() {
+        updateGephiGraph([dn: [filter: "ALL"]])
+    }
+
+    def resetColorsSizes() {
+        updateGephiGraph([cn: [filter: [nodeAttribute: [attribute: "visited", value: 1]],
+                               attributes: [size: 1, r: vizDefaultRGBColor[0], g: vizDefaultRGBColor[1], b: vizDefaultRGBColor[2]]]])
+        updateGephiGraph([ce: [filter: [edgeAttribute: [attribute: "visited", value: 1]],
+                               attributes: [size: 1, r: vizDefaultRGBColor[0], g: vizDefaultRGBColor[1], b: vizDefaultRGBColor[2]]]])
+    }
+
+    def getFromGephiGraph(def Map queryArgs) {
+        def requestBuilder = RequestBuilder.get("http://$host:$port/$workspace")
+        queryArgs.each { requestBuilder = requestBuilder.addParameter(it.key, it.value) }
+
+        def httpResp = makeRequest(requestBuilder.build())
+        def resp = EntityUtils.toString(httpResp.entity)
+
+        // gephi streaming plugin does not set the content type or respect the Accept header - treat as text
+        if (resp.isEmpty())
+            return Optional.empty()
+        else
+            return Optional.of(new JsonSlurper().parseText(resp))
+    }
+
+    def updateGephiGraph(def Map postBody) {
+        def requestBuilder = RequestBuilder.post("http://$host:$port/$workspace")
+                                           .addParameter("format", "JSON")
+                                           .addParameter("operation", "updateGraph")
+                                           .setEntity(new StringEntity(JsonOutput.toJson(postBody)))
+        EntityUtils.consume(makeRequest(requestBuilder.build()).entity)
+    }
+
+    private CloseableHttpResponse makeRequest(HttpUriRequest request) {
+        def httpResp = httpclient.execute(request)
+        if (httpResp.getStatusLine().getStatusCode() == 200) {
+            return httpResp
+        } else {
+            def resp = EntityUtils.toString(httpResp.entity)
+            throw new RuntimeException("Unsuccessful request to Gephi - [${httpResp.getStatusLine().getStatusCode()}] ${httpResp.getStatusLine().getReasonPhrase()} - $resp")
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "Gephi - [$workspace]"
+    }
+
+    private void parseVizStepDelay(String arg) {
+        try {
+            vizStepDelay = Long.parseLong(arg)
+        } catch (Exception ignored) {
+            throw new RemoteException("The stepDelay must be a long value")
+        }
+    }
+
+    private void parseVizStartRGBColor(String arg) {
+        try {
+            vizStartRGBColor = arg[1..-2].tokenize(',')*.toFloat()
+            assert (vizStartRGBColor.length == 3)
+        } catch (Exception ignored) {
+            throw new RemoteException("The vizStartRGBColor must be an array of 3 float values, e.g. [0.0,1.0,0.5]")
+        }
+    }
+
+    private void parseVizColorToFade(String arg) {
+        try {
+            vizColorToFade = arg.charAt(0).toLowerCase();
+            assert (vizColorToFade == 'r' || vizColorToFade == 'g' || vizColorToFade == 'b')
+        } catch (Exception ignored) {
+            throw new RemoteException("The vizColorToFade must be one character value among: r, g, b, R, G, B")
+        }
+    }
+
+    private void parseVizColorFadeRate(String arg) {
+        try {
+            vizColorFadeRate = Float.parseFloat(arg)
+        } catch (Exception ignored) {
+            throw new RemoteException("The colorFadeRate must be a float value")
+        }
+    }
+
+    private void parseVizSizeDecrementRate(String arg) {
+        try {
+            vizSizeDecrementRate = Float.parseFloat(arg)
+        } catch (Exception ignored) {
+            throw new RemoteException("The sizeDecrementRate must be a float value")
+        }
+    }
+
+    private void parseVizStartSize(String arg) {
+        try {
+            vizStartSize = Float.parseFloat(arg)
+        } catch (Exception ignored) {
+            throw new RemoteException("The startSize must be a float value")
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
index dc63a2f..7a08a9d 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
@@ -68,9 +68,13 @@ class PluggedIn {
 
     public static class GremlinPluginAdapter implements GremlinPlugin {
         org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin
+        private final Groovysh shell
+        private final IO io
 
-        public GremlinPluginAdapter(final org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin) {
+        public GremlinPluginAdapter(final org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin, final Groovysh shell, final IO io) {
             this.corePlugin = corePlugin
+            this.shell = shell
+            this.io = io
         }
 
         @Override
@@ -103,11 +107,11 @@ class PluggedIn {
         @Override
         Optional<RemoteAcceptor> remoteAcceptor() {
             // find a consoleCustomizer if available
-            if (!corePlugin.getCustomizers("gremlin-groovy").any{ it instanceof ConsoleCustomizer })
-                Optional.empty()
+            if (!corePlugin.getCustomizers("gremlin-groovy").isPresent() || !corePlugin.getCustomizers("gremlin-groovy").get().any{ it instanceof ConsoleCustomizer })
+                return Optional.empty()
 
-            ConsoleCustomizer customizer = (ConsoleCustomizer) corePlugin.getCustomizers("gremlin-groovy").find{ it instanceof ConsoleCustomizer }
-            return Optional.of(new RemoteAcceptorAdapter(customizer.remoteAcceptor))
+            ConsoleCustomizer customizer = (ConsoleCustomizer) corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof ConsoleCustomizer }
+            return Optional.of(new RemoteAcceptorAdapter(customizer.getRemoteAcceptor([(ConsoleCustomizer.ENV_CONSOLE_SHELL): shell, (ConsoleCustomizer.ENV_CONSOLE_IO): io])))
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
index 2c52bd5..2f8fc75 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
@@ -35,7 +35,9 @@ import java.util.Set;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.DriverGremlinPlugin}.
  */
+@Deprecated
 public class DriverGremlinPlugin extends AbstractGremlinPlugin {
 
     private static final Set<String> IMPORTS = new HashSet<String>() {{

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
index c346540..80e8194 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
@@ -50,7 +50,9 @@ import java.util.stream.Stream;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor}.
  */
+@Deprecated
 public class DriverRemoteAcceptor implements RemoteAcceptor {
     public static final int NO_TIMEOUT = 0;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
index 6977aa8..df0541f 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
@@ -29,6 +29,7 @@ import java.util.Optional;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.GephiGremlinPlugin}.
  */
 public class GephiGremlinPlugin extends AbstractGremlinPlugin {
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
index 59c2b1a..d1c853d 100644
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
@@ -34,6 +34,7 @@ import java.util.Set;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.UtilitiesGremlinPlugin}.
  */
 public class UtilitiesGremlinPlugin extends AbstractGremlinPlugin {
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
new file mode 100644
index 0000000..89cec10
--- /dev/null
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.console.jsr223;
+
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.Host;
+import org.apache.tinkerpop.gremlin.driver.LoadBalancingStrategy;
+import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
+import org.apache.tinkerpop.gremlin.driver.Result;
+import org.apache.tinkerpop.gremlin.driver.ResultSet;
+import org.apache.tinkerpop.gremlin.driver.Tokens;
+import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
+import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseResult;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatus;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversalSideEffects;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer;
+import org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer;
+import org.apache.tinkerpop.gremlin.driver.ser.SerTokens;
+import org.apache.tinkerpop.gremlin.driver.ser.SerializationException;
+import org.apache.tinkerpop.gremlin.driver.ser.Serializers;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
+import org.codehaus.groovy.tools.shell.Groovysh;
+
+import java.util.Map;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DriverGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.server";
+
+    private static final ImportCustomizer imports = DefaultImportCustomizer.build()
+            .addClassImports(Cluster.class,
+                    Client.class,
+                    Host.class,
+                    LoadBalancingStrategy.class,
+                    MessageSerializer.class,
+                    Result.class,
+                    ResultSet.class,
+                    Tokens.class,
+                    ConnectionException.class,
+                    ResponseException.class,
+                    RequestMessage.class,
+                    ResponseMessage.class,
+                    ResponseResult.class,
+                    ResponseStatus.class,
+                    ResponseStatusCode.class,
+                    GraphSONMessageSerializerGremlinV1d0.class,
+                    GraphSONMessageSerializerGremlinV2d0.class,
+                    GraphSONMessageSerializerV1d0.class,
+                    GraphSONMessageSerializerV2d0.class,
+                    GryoLiteMessageSerializerV1d0.class,
+                    GryoMessageSerializerV1d0.class,
+                    JsonBuilderGryoSerializer.class,
+                    MessageTextSerializer.class,
+                    SerializationException.class,
+                    Serializers.class,
+                    SerTokens.class,
+                    DriverRemoteConnection.class,
+                    DriverRemoteTraversal.class,
+                    DriverRemoteTraversalSideEffects.class).create();
+
+    public DriverGremlinPlugin() {
+        super(NAME, imports, new DriverConsoleCustomizer());
+    }
+
+    private static class DriverConsoleCustomizer implements ConsoleCustomizer {
+        @Override
+        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
+            return new DriverRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
new file mode 100644
index 0000000..93ac184
--- /dev/null
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverRemoteAcceptor.java
@@ -0,0 +1,238 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.console.jsr223;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.Result;
+import org.apache.tinkerpop.gremlin.driver.ResultSet;
+import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor;
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException;
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.codehaus.groovy.tools.shell.Groovysh;
+
+import javax.security.sasl.SaslException;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Stream;
+
+/**
+ * A {@link RemoteAcceptor} that takes input from the console and sends it to Gremlin Server over the standard
+ * Java driver.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class DriverRemoteAcceptor implements RemoteAcceptor {
+    public static final int NO_TIMEOUT = 0;
+
+    private Cluster currentCluster;
+    private Client currentClient;
+    private int timeout = NO_TIMEOUT;
+    private Map<String,String> aliases = new HashMap<>();
+    private Optional<String> session = Optional.empty();
+
+    private static final String TOKEN_RESET = "reset";
+    private static final String TOKEN_SHOW = "show";
+
+    /**
+     * @deprecated As of 3.1.3, replaced by "none" option
+     */
+    @Deprecated
+    private static final String TOKEN_MAX = "max";
+    private static final String TOKEN_NONE = "none";
+    private static final String TOKEN_TIMEOUT = "timeout";
+    private static final String TOKEN_ALIAS = "alias";
+    private static final String TOKEN_SESSION = "session";
+    private static final String TOKEN_SESSION_MANAGED = "session-managed";
+    private static final List<String> POSSIBLE_TOKENS = Arrays.asList(TOKEN_TIMEOUT, TOKEN_ALIAS);
+
+    private final Groovysh shell;
+
+    public DriverRemoteAcceptor(final Groovysh shell) {
+        this.shell = shell;
+    }
+
+    @Override
+    public Object connect(final List<String> args) throws RemoteException {
+        if (args.size() < 1) throw new RemoteException("Expects the location of a configuration file as an argument");
+
+        try {
+            this.currentCluster = Cluster.open(args.get(0));
+            final boolean useSession = args.size() >= 2 && (args.get(1).equals(TOKEN_SESSION) || args.get(1).equals(TOKEN_SESSION_MANAGED));
+            if (useSession) {
+                final String sessionName = args.size() == 3 ? args.get(2) : UUID.randomUUID().toString();
+                session = Optional.of(sessionName);
+
+                final boolean managed = args.get(1).equals(TOKEN_SESSION_MANAGED);
+
+                this.currentClient = this.currentCluster.connect(sessionName, managed);
+            } else {
+                this.currentClient = this.currentCluster.connect();
+            }
+            this.currentClient.init();
+            return String.format("Configured %s", this.currentCluster) + getSessionStringSegment();
+        } catch (final FileNotFoundException ignored) {
+            throw new RemoteException("The 'connect' option must be accompanied by a valid configuration file");
+        } catch (final Exception ex) {
+            throw new RemoteException("Error during 'connect' - " + ex.getMessage(), ex);
+        }
+    }
+
+    @Override
+    public Object configure(final List<String> args) throws RemoteException {
+        final String option = args.size() == 0 ? "" : args.get(0);
+        if (!POSSIBLE_TOKENS.contains(option))
+            throw new RemoteException(String.format("The 'config' option expects one of ['%s'] as an argument", String.join(",", POSSIBLE_TOKENS)));
+
+        final List<String> arguments = args.subList(1, args.size());
+
+        if (option.equals(TOKEN_TIMEOUT)) {
+            final String errorMessage = "The timeout option expects a positive integer representing milliseconds or 'none' as an argument";
+            if (arguments.size() != 1) throw new RemoteException(errorMessage);
+            try {
+                // first check for MAX timeout then NONE and finally parse the config to int. "max" is now "deprecated"
+                // in the sense that it will no longer be promoted. support for it will be removed at a later date
+                timeout = arguments.get(0).equals(TOKEN_MAX) ? Integer.MAX_VALUE :
+                        arguments.get(0).equals(TOKEN_NONE) ? NO_TIMEOUT : Integer.parseInt(arguments.get(0));
+                if (timeout < NO_TIMEOUT) throw new RemoteException("The value for the timeout cannot be less than " + NO_TIMEOUT);
+                return timeout == NO_TIMEOUT ? "Remote timeout is disabled" : "Set remote timeout to " + timeout + "ms";
+            } catch (Exception ignored) {
+                throw new RemoteException(errorMessage);
+            }
+        } else if (option.equals(TOKEN_ALIAS)) {
+            if (arguments.size() == 1 && arguments.get(0).equals(TOKEN_RESET)) {
+                aliases.clear();
+                return "Aliases cleared";
+            }
+
+            if (arguments.size() == 1 && arguments.get(0).equals(TOKEN_SHOW)) {
+                return aliases;
+            }
+
+            if (arguments.size() % 2 != 0)
+                throw new RemoteException("Arguments to alias must be 'reset' to clear any existing alias settings or key/value alias/binding pairs");
+
+            final Map<String,Object> aliasMap = ElementHelper.asMap(arguments.toArray());
+            aliases.clear();
+            aliasMap.forEach((k,v) -> aliases.put(k, v.toString()));
+            return aliases;
+        }
+
+        return this.toString();
+    }
+
+    @Override
+    public Object submit(final List<String> args) throws RemoteException {
+        final String line = getScript(String.join(" ", args), this.shell);
+
+        try {
+            final List<Result> resultSet = send(line);
+            this.shell.getInterp().getContext().setProperty(RESULT, resultSet);
+            return resultSet.stream().map(result -> result.getObject()).iterator();
+        } catch (SaslException sasl) {
+            throw new RemoteException("Security error - check username/password and related settings", sasl);
+        } catch (Exception ex) {
+            final Optional<ResponseException> inner = findResponseException(ex);
+            if (inner.isPresent()) {
+                final ResponseException responseException = inner.get();
+                if (responseException.getResponseStatusCode() == ResponseStatusCode.SERVER_ERROR_SERIALIZATION)
+                    throw new RemoteException(String.format("Server could not serialize the result requested. Server error - %s. Note that the class must be serializable by the client and server for proper operation.", responseException.getMessage()));
+                else
+                    throw new RemoteException(responseException.getMessage());
+            } else if (ex.getCause() != null) {
+                final Throwable rootCause = ExceptionUtils.getRootCause(ex);
+                if (rootCause instanceof TimeoutException)
+                    throw new RemoteException("Host did not respond in a timely fashion - check the server status and submit again.");
+                else
+                    throw new RemoteException(rootCause.getMessage());
+            } else
+                throw new RemoteException(ex.getMessage());
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (this.currentClient != null) this.currentClient.close();
+        if (this.currentCluster != null) this.currentCluster.close();
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+
+    private List<Result> send(final String gremlin) throws SaslException {
+        try {
+            final ResultSet rs = this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get();
+            return timeout > NO_TIMEOUT ? rs.all().get(timeout, TimeUnit.MILLISECONDS) : rs.all().get();
+        } catch(TimeoutException ignored) {
+            throw new IllegalStateException("Request timed out while processing - increase the timeout with the :remote command");
+        } catch (Exception e) {
+            // handle security error as-is and unwrapped
+            final Optional<Throwable> throwable  = Stream.of(ExceptionUtils.getThrowables(e)).filter(t -> t instanceof SaslException).findFirst();
+            if (throwable.isPresent())
+                throw (SaslException) throwable.get();
+
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public boolean allowRemoteConsole() {
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "Gremlin Server - [" + this.currentCluster + "]" + getSessionStringSegment();
+    }
+
+    private Optional<ResponseException> findResponseException(final Throwable ex) {
+        if (ex instanceof ResponseException)
+            return Optional.of((ResponseException) ex);
+
+        if (null == ex.getCause())
+            return Optional.empty();
+
+        return findResponseException(ex.getCause());
+    }
+
+    private String getSessionStringSegment() {
+        return session.isPresent() ? String.format("-[%s]", session.get()) : "";
+    }
+
+    /**
+     * Retrieve a script as defined in the shell context.  This allows for multi-line scripts to be submitted.
+     */
+    public static String getScript(final String submittedScript, final Groovysh shell) {
+        return submittedScript.startsWith("@") ? shell.getInterp().getContext().getProperty(submittedScript.substring(1)).toString() : submittedScript;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
new file mode 100644
index 0000000..7698112
--- /dev/null
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.console.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.codehaus.groovy.tools.shell.IO;
+
+import java.util.Map;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GephiGremlinPlugin extends AbstractGremlinPlugin {
+    private static final String NAME = "tinkerpop.gephi";
+
+    public GephiGremlinPlugin() {
+        super(NAME, new GephiConsoleCustomizer());
+    }
+
+    private static class GephiConsoleCustomizer implements ConsoleCustomizer {
+        @Override
+        public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final Map<String, Object> environment) {
+            return new GephiRemoteAcceptor((Groovysh) environment.get(ConsoleCustomizer.ENV_CONSOLE_SHELL),
+                    (IO) environment.get(ConsoleCustomizer.ENV_CONSOLE_IO));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java
new file mode 100644
index 0000000..57bacda
--- /dev/null
+++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.console.jsr223;
+
+import groovyx.gbench.Benchmark;
+import groovyx.gbench.BenchmarkStaticExtension;
+import groovyx.gprof.ProfileStaticExtension;
+import groovyx.gprof.Profiler;
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultScriptCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class UtilitiesGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.utilities";
+
+    private static final ImportCustomizer imports;
+
+    private static final ScriptCustomizer scripts;
+
+    static {
+        try {
+            imports = DefaultImportCustomizer.build()
+                    .addClassImports(groovyx.gbench.Benchmark.class,
+                            groovyx.gbench.BenchmarkBuilder.class,
+                            groovyx.gbench.BenchmarkConstants.class,
+                            groovyx.gbench.BenchmarkContext.class,
+                            groovyx.gbench.Benchmarker.class,
+                            groovyx.gbench.BenchmarkList.class,
+                            groovyx.gbench.BenchmarkLogger.class,
+                            groovyx.gbench.BenchmarkMath.class,
+                            groovyx.gbench.BenchmarkMeasure.class,
+                            groovyx.gbench.BenchmarkStaticExtension.class,
+                            groovyx.gbench.BenchmarkSystem.class,
+                            groovyx.gbench.BenchmarkTime.class,
+                            groovyx.gbench.BenchmarkWarmUp.class,
+                            groovyx.gprof.Profiler.class,
+                            groovyx.gprof.ProfileStaticExtension.class,
+                            groovyx.gprof.CallFilter.class,
+                            groovyx.gprof.CallInfo.class,
+                            groovyx.gprof.CallInterceptor.class,
+                            groovyx.gprof.CallMatcher.class,
+                            groovyx.gprof.CallTree.class,
+                            groovyx.gprof.MethodCallFilter.class,
+                            groovyx.gprof.MethodCallInfo.class,
+                            groovyx.gprof.MethodInfo.class,
+                            groovyx.gprof.ProfileMetaClass.class,
+                            groovyx.gprof.ProxyReport.class,
+                            groovyx.gprof.Report.class,
+                            groovyx.gprof.ReportElement.class,
+                            groovyx.gprof.ReportNormalizer.class,
+                            groovyx.gprof.ReportPrinter.class,
+                            groovyx.gprof.ThreadInfo.class,
+                            groovyx.gprof.ThreadRunFilter.class,
+                            groovyx.gprof.Utils.class)
+                    .addMethodImports(
+                            ProfileStaticExtension.class.getMethod("profile", Object.class, Callable.class),
+                            ProfileStaticExtension.class.getMethod("profile", Object.class, Map.class, Callable.class)).create();
+
+            final BufferedReader reader = new BufferedReader(new InputStreamReader(UtilitiesGremlinPlugin.class.getResourceAsStream("UtilitiesGremlinPluginScript.groovy")));
+            final List<String> lines = new ArrayList<>();
+            String line;
+            while ((line = reader.readLine()) != null) {
+                lines.add(line);
+            }
+            reader.close();
+
+            scripts = new DefaultScriptCustomizer(Collections.singletonList(lines));
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    public UtilitiesGremlinPlugin() {
+        super(NAME, imports, scripts);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..631c889
--- /dev/null
+++ b/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1,3 @@
+org.apache.tinkerpop.gremlin.console.jsr223.DriverGremlinPlugin
+org.apache.tinkerpop.gremlin.console.jsr223.GephiGremlinPlugin
+org.apache.tinkerpop.gremlin.console.jsr223.UtilitiesGremlinPlugin
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
new file mode 100644
index 0000000..5f5e3c6
--- /dev/null
+++ b/gremlin-console/src/main/resources/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginScript.groovy
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+/**
+ * @author Daniel Kuppitz (http://thinkaurelius.com)
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+
+describeGraph = { Class<? extends org.apache.tinkerpop.gremlin.structure.Graph> c ->
+    def lf = System.getProperty("line.separator")
+    def optIns = c.getAnnotationsByType(org.apache.tinkerpop.gremlin.structure.Graph.OptIn)
+    def optOuts = c.getAnnotationsByType(org.apache.tinkerpop.gremlin.structure.Graph.OptOut)
+
+    def optInCount = optIns != null ? optIns.size() : 0
+    def optOutCount = optOuts != null ? optOuts.size() : 0
+    def suitesSupported = optIns != null && optIns.size() > 0 ? optIns.collect { "> " + it.value() }.join(lf) : "> none"
+    def testsOptedOut = optOuts != null && optOuts.size() > 0 ? optOuts.collect { "> " + it.test() + "#" + it.method() + "${lf}\t\"" + it.reason() + "\"" }.join(lf) : "> none";
+
+    // not the use of {lf} here rather than triple quoted string is that groovy 2.4.0 seems to have trouble
+    // parsing that into groovysh - note the bug report here: https://jira.codehaus.org/browse/GROOVY-7290
+    return "${lf}" +
+"IMPLEMENTATION - ${c.getCanonicalName()} ${lf}" +
+"TINKERPOP TEST SUITE ${lf}" +
+"- Compliant with ($optInCount of 10 suites) ${lf}" +
+"$suitesSupported ${lf}" +
+"- Opts out of $optOutCount individual tests ${lf}" +
+"$testsOptedOut ${lf}" +
+"- NOTE - ${lf}" +
+"The describeGraph() function shows information about a Graph implementation. ${lf}" +
+"It uses information found in Java Annotations on the implementation itself to ${lf}" +
+"determine this output and does not assess the actual code of the test cases of ${lf}" +
+"the implementation itself.  Compliant implementations will faithfully and ${lf}" +
+"honestly supply these Annotations to provide the most accurate depiction of ${lf}" +
+"their support."
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a91fb80e/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
index 77422da..dd582b1 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
@@ -19,10 +19,7 @@
 package org.apache.tinkerpop.gremlin.console.groovy.plugin;
 
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn;
-import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
 import org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin;
-import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer;
-import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin;
 import org.junit.Test;
 
 import java.time.DayOfWeek;
@@ -44,7 +41,7 @@ public class GremlinPluginAdapterTest {
                 .classImports(java.awt.Color.class, java.sql.CallableStatement.class)
                 .enumImports(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
                 .methodImports(DayOfWeek.class.getMethod("from", TemporalAccessor.class), DayOfWeek.class.getMethod("values")).create();
-        final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin);
+        final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
 
         assertEquals(plugin.getName(), adapter.getName());
 


[37/50] tinkerpop git commit: Lessened log severity for Gremlin Server wrt serializers

Posted by sp...@apache.org.
Lessened log severity for Gremlin Server wrt serializers

No behavioral change here except that users won't see a WARN message anymore if multiple serializers support the same mimetype. CTR


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

Branch: refs/heads/TINKERPOP-1490
Commit: 347a0a9603d834a5b1dbd4874b701a6363b84644
Parents: 708c601
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Dec 12 09:21:26 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Dec 12 09:21:26 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                |  1 +
 docs/src/reference/gremlin-applications.asciidoc  | 18 ++++++++++++------
 .../gremlin/server/AbstractChannelizer.java       |  2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/347a0a96/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index add4370..8e01ce0 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Lessened the severity of Gremlin Server logging when it encounters two or more serializers addressing the same mime type.
 * Bumped to Netty 4.0.42.final.
 * Fixed a bug in Gremlin-Python around `__.__()` and `__.start()`.
 * Fixed a bug around long serialization in Gremlin-Python when using Python3.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/347a0a96/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index f7ba2b5..53b1dfd 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -1381,12 +1381,18 @@ link:http://docs.groovy-lang.org/latest/html/documentation/#compilation-customiz
 Serialization
 ^^^^^^^^^^^^^
 
-Gremlin Server can accept requests and return results using different serialization formats.  The format of the
-serialization is configured by the `serializers` setting described in the table above.  Note that some serializers
-have additional configuration options as defined by the `serializers[X].config` setting.  The `config` setting is a
-`Map` where the keys and values get passed to the serializer at its initialization.  The available and/or expected
-keys are dependent on the serializer being used.  Gremlin Server comes packaged with two different serializers:
-GraphSON and Gryo.
+Gremlin Server can accept requests and return results using different serialization formats.  Serializers implement the
+`MessageSerializer` interface. In doing so, they express the list of mime types they expect to support. When
+configuring multiple serializers it is possible for two or more serializers to support the same mime type. Such a
+situation may be common with a generic mime type such as `application/json`. Serializers are added in the order that
+they are encountered in the configuration file and the first one added for a specific mime type will not be overridden
+by other serializers that also support it.
+
+The format of the serialization is configured by the `serializers` setting described in the table above.  Note that
+some serializers have additional configuration options as defined by the `serializers[X].config` setting.  The
+`config` setting is a `Map` where the keys and values get passed to the serializer at its initialization.  The
+available and/or expected keys are dependent on the serializer being used.  Gremlin Server comes packaged with two
+different serializers: GraphSON and Gryo.
 
 GraphSON
 ++++++++

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/347a0a96/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
index fdedd31..57c6994 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
@@ -196,7 +196,7 @@ public abstract class AbstractChannelizer extends ChannelInitializer<SocketChann
             final String mimeType = pair.getValue0();
             final MessageSerializer serializer = pair.getValue1();
             if (serializers.containsKey(mimeType))
-                logger.warn("{} already has {} configured.  It will not be replaced by {}. Check configuration for serializer duplication or other issues.",
+                logger.info("{} already has {} configured - it will not be replaced by {}.",
                         mimeType, serializers.get(mimeType).getClass().getName(), serializer.getClass().getName());
             else {
                 logger.info("Configured {} with {}", mimeType, pair.getValue1().getClass().getName());


[48/50] tinkerpop git commit: TINKERPOP-1490 Merge fixes after rebase on tp32

Posted by sp...@apache.org.
TINKERPOP-1490 Merge fixes after rebase on tp32


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

Branch: refs/heads/TINKERPOP-1490
Commit: a8c8b6553a0bd0b41c292822f41e2e0d8e073cf1
Parents: 21663f4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Dec 7 15:01:28 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:14:20 2016 -0500

----------------------------------------------------------------------
 gremlin-python/src/main/jython/gremlin_python/process/traversal.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a8c8b655/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 2c2db59..07afeac 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -406,3 +406,4 @@ class Binding(object):
         return hash(self.key) + hash(self.value)
     def __repr__(self):
         return "binding[" + self.key + "=" + str(self.value) + "]"
+


[45/50] tinkerpop git commit: TINKERPOP-1490 Implemented promise API for Traversal

Posted by sp...@apache.org.
TINKERPOP-1490 Implemented promise API for Traversal

Added two promise() methods that return CompletableFuture on Traversal. Provided an override on DefaultTraversal for those methods because the function that transforms the Traversal is executed in a different thread and therefore requires Graph transaction management (or else we would orphan transactions). Did not update gremlin-python with the promise API because it seemed to beg discussion on the "right" way to do that (i.e. what library to use to support promises?, just use futures from the core lib?, etc).


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

Branch: refs/heads/TINKERPOP-1490
Commit: 6c4cbc849f83b9ed44d3c5bbef5e59d67b702593
Parents: b0b9330
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 1 09:30:28 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:10:14 2016 -0500

----------------------------------------------------------------------
 gremlin-core/pom.xml                            |  5 +++
 .../traversal/util/DefaultTraversal.java        | 37 +++++++++++++++++
 .../gremlin/python/jsr223/PythonProvider.java   |  1 +
 .../process/traversal/CoreTraversalTest.java    | 42 ++++++++++++++++++++
 .../TinkerGraphGroovyTranslatorProvider.java    |  1 +
 .../TinkerGraphJavaTranslatorProvider.java      |  1 +
 6 files changed, 87 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index e8f3a34..0594448 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -61,6 +61,11 @@ limitations under the License.
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
+        </dependency>
         <!-- LOGGING -->
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 3c21e37..6ce6dfe 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -43,6 +43,9 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Function;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -325,6 +328,40 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
         this.graph = graph;
     }
 
+    /**
+     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions.
+     */
+    @Override
+    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction) {
+        return this.promise(traversalFunction, Traversal.Admin.traversalExecutorService);
+    }
+
+    /**
+     * Override of {@link Traversal#promise(Function)} that is aware of graph transactions. In a transactional graph
+     * a promise represents the full scope of a transaction, even if the graph is only partially iterated.
+     */
+    @Override
+    public <T2> CompletableFuture<T2> promise(final Function<Traversal, T2> traversalFunction, final ExecutorService service) {
+        if (graph != null && graph.features().graph().supportsTransactions()) {
+            final Function<Traversal, T2> transactionAware = traversal -> {
+
+                try {
+                    if (graph.tx().isOpen()) graph.tx().rollback();
+                    final T2 obj = traversalFunction.apply(traversal);
+                    if (graph.tx().isOpen()) graph.tx().commit();
+                    return obj;
+                } catch (Exception ex) {
+                    if (graph.tx().isOpen()) graph.tx().rollback();
+                    throw ex;
+                }
+            };
+
+            return Traversal.Admin.super.promise(transactionAware, service);
+        } else {
+            return Traversal.Admin.super.promise(traversalFunction, service);
+        }
+    }
+
     @Override
     public boolean equals(final Object other) {
         return other != null && other.getClass().equals(this.getClass()) && this.equals(((Traversal.Admin) other));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index 9e03884..5dd9c28 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -69,6 +69,7 @@ public class PythonProvider extends AbstractGraphProvider {
             "shouldNeverPropagateANullValuedTraverser",
             "shouldHidePartitionKeyForValues",
             "g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
index 68f8217..050f9de 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/CoreTraversalTest.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.process.traversal;
 
 import org.apache.tinkerpop.gremlin.ExceptionCoverage;
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
+import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -40,6 +41,9 @@ import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
@@ -307,4 +311,42 @@ public class CoreTraversalTest extends AbstractGremlinProcessTest {
         }
 
     }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void shouldUsePromiseAndControlTransactionsIfAvailable() throws Exception {
+        // this test will validate that transactional graphs can properly open/close transactions within a promise.
+        // as there is a feature check, non-transactional graphs can use this to simply exercise the promise API
+        final Vertex vAdded = g.addV("person").property("name", "stephen").promise(t -> (Vertex) t.next()).get(10000, TimeUnit.MILLISECONDS);
+        final Vertex vRead = g.V().has("name", "stephen").next();
+        assertEquals(vAdded.id(), vRead.id());
+
+        // transaction should have been committed at this point so test the count in this thread to validate persistence
+        assertVertexEdgeCounts(graph, 1, 0);
+
+        // cancel a promise and ensure the transaction ended in failure. hold the traversal in park until it can be
+        // interrupted, then the promise will have to rollback the transaction.
+        final CompletableFuture promiseToCancel = g.addV("person").property("name", "marko").sideEffect(traverser -> {
+            try {
+                Thread.sleep(100000);
+            } catch (Exception ignored) {
+
+            }
+        }).promise(t -> (Vertex) t.next());
+
+        try {
+            promiseToCancel.get(500, TimeUnit.MILLISECONDS);
+            fail("Should have timed out");
+        } catch (TimeoutException te) {
+
+        }
+
+        promiseToCancel.cancel(true);
+
+        // graphs that support transactions will rollback the transaction
+        if (graph.features().graph().supportsTransactions())
+            assertVertexEdgeCounts(graph, 1, 0);
+        else
+            assertVertexEdgeCounts(graph, 2, 0);
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
index dd118d7..a595c34 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
@@ -51,6 +51,7 @@ public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider {
             "g_VX1X_out_injectXv2X_name",
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             GraphComputerTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c4cbc84/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
index f40a8c7..15a6c0b 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
@@ -49,6 +49,7 @@ public class TinkerGraphJavaTranslatorProvider extends TinkerGraphProvider {
             TraversalInterruptionComputerTest.class.getCanonicalName(),
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
+            "shouldUsePromiseAndControlTransactionsIfAvailable",
             ElementIdStrategyProcessTest.class.getCanonicalName(),
             EventStrategyProcessTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName()));


[46/50] tinkerpop git commit: TINKERPOP-1490 Remove some dead tests from ignores.

Posted by sp...@apache.org.
TINKERPOP-1490 Remove some dead tests from ignores.


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

Branch: refs/heads/TINKERPOP-1490
Commit: f4bc29c0a5a5ef26e182765bd3d8d6d2780925d0
Parents: 9bbf025
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Nov 11 13:39:40 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 16 10:12:08 2016 -0500

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java  | 1 -
 .../process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java  | 1 -
 .../process/jsr223/TinkerGraphJavaTranslatorProvider.java           | 1 -
 3 files changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f4bc29c0/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
index 5dd9c28..9e03884 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java
@@ -69,7 +69,6 @@ public class PythonProvider extends AbstractGraphProvider {
             "shouldNeverPropagateANullValuedTraverser",
             "shouldHidePartitionKeyForValues",
             "g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f4bc29c0/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
index a595c34..dd118d7 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java
@@ -51,7 +51,6 @@ public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider {
             "g_VX1X_out_injectXv2X_name",
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             GraphComputerTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f4bc29c0/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
index 15a6c0b..f40a8c7 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java
@@ -49,7 +49,6 @@ public class TinkerGraphJavaTranslatorProvider extends TinkerGraphProvider {
             TraversalInterruptionComputerTest.class.getCanonicalName(),
             "shouldNeverPropagateANoBulkTraverser",
             "shouldNeverPropagateANullValuedTraverser",
-            "shouldUsePromiseAndControlTransactionsIfAvailable",
             ElementIdStrategyProcessTest.class.getCanonicalName(),
             EventStrategyProcessTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName()));


[15/50] tinkerpop git commit: TINKERPOP-1562 Update upgrade docs with ScriptEngine changes.

Posted by sp...@apache.org.
TINKERPOP-1562 Update upgrade docs with ScriptEngine changes.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 00ccf0fe0b728bd742f9b6f9c1cf6936f4f07b27
Parents: 8368921
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 30 18:42:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:50 2016 -0500

----------------------------------------------------------------------
 .../upgrade/release-3.2.x-incubating.asciidoc   | 50 ++++++++++++++++++++
 1 file changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/00ccf0fe/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 2b38906..8a184b4 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -55,6 +55,56 @@ This has been changed to a regular `NoSuchElementException` that includes the st
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1330[TINKERPOP-1330]
 
+ScriptEngine support in gremlin-core
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+`ScriptEngine` and `GremlinPlugin` infrastructure has been moved from gremlin-groovy to gremlin-core to allow for
+better re-use across different Gremlin Language Variants. At this point, this change is non-breaking as it was
+implemented through deprecation.
+
+The basic concept of a `ScriptEngine` has been replaced by the notion of a `GremlinScriptEngine` (i.e. a
+"ScriptEngine" that is specifically tuned for executing Gremlin-related scripts). "ScriptEngine" infrastructure has
+been developed to help support this new interface, specifically `GremlinScriptEngineFactory` and
+`GremlinScriptEngineManager`. Prefer use of this infrastructure when instantiating a `GremlinScriptEngine` rather
+than trying to instantiate directly.
+
+For example, rather than instantiate a `GremlinGroovyScriptEngine` with the constructor:
+
+[source,java]
+----
+GremlinScriptEngine engine = new GremlinGroovyScriptEngine();
+----
+
+prefer to instantiate it as follows:
+
+[source,java]
+----
+GremlinScriptEngineManager manager = new CachedGremlinScriptEngineManager();
+GremlinScriptEngine engine = manager.getEngineByName("gremlin-groovy");
+----
+
+Related to the addition of `GremlinScriptEngine`, `org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin` in
+gremlin-groovy has been deprecated and then replaced by `org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin`. The new
+version of `GremlinPlugin` is similar but does carry some new methods to implement that involves the new `Customizer`
+interface. The `Customizer` interface is the way in which `GremlinScriptEngine` instance can be configured with
+imports, initialization scripts, compiler options, etc.
+
+Note that a `GremlinPlugin` can be applied to a `GremlinScriptEngine` by adding it to the `GremlinScriptEngineManager`
+that creates it.
+
+[source,java]
+----
+GremlinScriptEngineManager manager = new CachedGremlinScriptEngineManager();
+manager.addPlugin(ImportGremlinPlugin.build().classImports(java.awt.Color.class).create());
+GremlinScriptEngine engine = manager.getEngineByName("gremlin-groovy");
+----
+
+All of this new infrastructure is currently optional on the 3.2.x line of code. More detailed documentation will for
+these changes will be supplied as part of 3.3.0 when these features become mandatory and the deprecated code is
+removed.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1562[TINKERPOP-1562]
+
 Upgrading for Providers
 ~~~~~~~~~~~~~~~~~~~~~~~
 


[25/50] tinkerpop git commit: TINKERPOP-1562 Make all groovy customizer providers straight Customizer instances

Posted by sp...@apache.org.
TINKERPOP-1562 Make all groovy customizer providers straight Customizer instances


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

Branch: refs/heads/TINKERPOP-1490
Commit: a82c56fad2500f49da265466d5e23f345749d348
Parents: 00ccf0f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Nov 30 18:43:13 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 2 06:31:51 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../tinkerpop/gremlin/util/CoreImports.java     | 34 +++++--
 .../jsr223/CompileStaticGroovyCustomizer.java   | 60 ++++++++++++
 .../jsr223/ConfigurationGroovyCustomizer.java   | 82 +++++++++++++++++
 .../jsr223/CustomizerProviderCustomizer.java    | 40 --------
 .../jsr223/GremlinGroovyScriptEngine.java       | 97 ++++++++++----------
 .../jsr223/GroovyCompilerGremlinPlugin.java     | 18 ++--
 .../gremlin/groovy/jsr223/GroovyCustomizer.java | 33 +++++++
 .../groovy/jsr223/ImportGroovyCustomizer.java   | 66 +++++++++++++
 .../jsr223/InterpreterModeGroovyCustomizer.java | 36 ++++++++
 .../jsr223/ThreadInterruptGroovyCustomizer.java | 35 +++++++
 .../jsr223/TimedInterruptGroovyCustomizer.java  | 62 +++++++++++++
 .../jsr223/TimedInterruptTimeoutException.java  | 38 ++++++++
 .../jsr223/TypeCheckedGroovyCustomizer.java     | 65 +++++++++++++
 .../CompileStaticCustomizerProvider.java        |  2 +
 .../ConfigurationCustomizerProvider.java        |  2 +
 .../InterpreterModeCustomizerProvider.java      |  4 +
 .../ThreadInterruptCustomizerProvider.java      |  2 +
 .../TimedInterruptCustomizerProvider.java       |  2 +
 .../TimedInterruptTimeoutException.java         |  4 +
 .../TypeCheckedCustomizerProvider.java          |  2 +
 .../VariableIdentificationCustomizer.java       |  2 +
 ...mlinGroovyScriptEngineCompileStaticTest.java | 20 ++--
 .../GremlinGroovyScriptEngineConfigTest.java    |  5 +-
 .../jsr223/GremlinGroovyScriptEngineTest.java   |  6 +-
 ...inGroovyScriptEngineThreadInterruptTest.java |  2 +-
 ...linGroovyScriptEngineTimedInterruptTest.java | 22 ++---
 ...remlinGroovyScriptEngineTypeCheckedTest.java | 18 ++--
 .../jsr223/GroovyCompilerGremlinPluginTest.java | 14 +--
 .../server/op/AbstractEvalOpProcessor.java      |  5 +
 30 files changed, 625 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ebcc318..b4ba2a6 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -46,6 +46,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Fixed a `NoSuchElementException` bug with `GroupXXXStep` where if the reduced `TraverserSet` is empty, don't add the key/value.
 * Fixed a `NullPointerException` bug with profiling `GroupSideEffectStep` in OLTP.
 * Improved ability to release resources in `GraphProvider` instances in the test suite.
+* Factored `GremlinPlugin` functionality out of gremlin-groovy and into gremlin-core - related classes were deprecated.
 * Added a `force` option for killing sessions without waiting for transaction close or timeout of a currently running job or multiple jobs.
 * Deprecated `Session.kill()` and `Session.manualKill()`.
 * Added `choose(predicate,traversal)` and `choose(traversal,traversal)` to effect if/then-semantics (no else). Equivalent to `choose(x,y,identity())`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
index e6c64fd..1c6a6e6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
@@ -83,12 +83,15 @@ import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoCore;
 import org.apache.tinkerpop.gremlin.structure.io.Storage;
 import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.javatuples.Pair;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**
@@ -187,11 +190,11 @@ public final class CoreImports {
         // METHODS //
         /////////////
 
-        Stream.of(IoCore.class.getMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).forEach(METHOD_IMPORTS::add);
-        Stream.of(P.class.getMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).forEach(METHOD_IMPORTS::add);
-        Stream.of(__.class.getMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).filter(m -> !m.getName().equals("__")).forEach(METHOD_IMPORTS::add);
-        Stream.of(Computer.class.getMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).forEach(METHOD_IMPORTS::add);
-        Stream.of(TimeUtil.class.getMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(IoCore.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(P.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(__.class).filter(m -> !m.getName().equals("__")).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(Computer.class).forEach(METHOD_IMPORTS::add);
+        uniqueMethods(TimeUtil.class).forEach(METHOD_IMPORTS::add);
 
         ///////////
         // ENUMS //
@@ -207,7 +210,6 @@ public final class CoreImports {
         Collections.addAll(ENUM_IMPORTS, Scope.values());
         Collections.addAll(ENUM_IMPORTS, T.values());
         Collections.addAll(ENUM_IMPORTS, TraversalOptionParent.Pick.values());
-
     }
 
     private CoreImports() {
@@ -225,4 +227,24 @@ public final class CoreImports {
     public static Set<Enum> getEnumImports() {
         return Collections.unmodifiableSet(ENUM_IMPORTS);
     }
+
+    /**
+     * Filters to unique method names on each class.
+     */
+    private static Stream<Method> uniqueMethods(final Class<?> clazz) {
+        final Set<String> unique = new HashSet<>();
+        return Stream.of(clazz.getMethods())
+                .filter(m -> Modifier.isStatic(m.getModifiers()))
+                .map(m -> Pair.with(generateMethodDescriptor(m), m))
+                .filter(p -> {
+                    final boolean exists = unique.contains(p.getValue0());
+                    if (!exists) unique.add(p.getValue0());
+                    return !exists;
+                })
+                .map(Pair::getValue1);
+    }
+
+    private static String generateMethodDescriptor(final Method m) {
+        return m.getDeclaringClass().getCanonicalName() + "." + m.getName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CompileStaticGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CompileStaticGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CompileStaticGroovyCustomizer.java
new file mode 100644
index 0000000..c57e64b
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CompileStaticGroovyCustomizer.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import groovy.transform.CompileStatic;
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Injects the {@code CompileStatic} transformer to enable type validation on script execution.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class CompileStaticGroovyCustomizer implements GroovyCustomizer {
+
+    private final String extensions;
+
+    CompileStaticGroovyCustomizer() {
+        this(null);
+    }
+
+    CompileStaticGroovyCustomizer(final String extensions) {
+        this.extensions = extensions;
+    }
+
+    @Override
+    public CompilationCustomizer create() {
+        final Map<String, Object> annotationParams = new HashMap<>();
+        if (extensions != null && !extensions.isEmpty()) {
+            if (extensions.contains(","))
+                annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList()));
+            else
+                annotationParams.put("extensions", Collections.singletonList(extensions));
+        }
+
+        return new ASTTransformationCustomizer(annotationParams, CompileStatic.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationGroovyCustomizer.java
new file mode 100644
index 0000000..23fe002
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationGroovyCustomizer.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.codehaus.groovy.control.CompilerConfiguration;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Allows configurations to be directly supplied to a groovy {@code CompilerConfiguration} when a
+ * {@link GremlinGroovyScriptEngine} is initialized, providing fine-grained
+ * control over its internals.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class ConfigurationGroovyCustomizer implements GroovyCustomizer {
+
+    private final Map<String,Object> properties;
+
+    /**
+     * Creates a new instance using configuration values specified
+     */
+    ConfigurationGroovyCustomizer(final Object... keyValues) {
+        if (null == keyValues || keyValues.length == 0)
+            throw new IllegalArgumentException("ConfigurationCustomizerProvider must have key/values specified");
+
+        if (keyValues.length % 2 != 0)
+            throw new IllegalArgumentException("The keyValues must have an even number of values");
+
+        properties = ElementHelper.asMap(keyValues);
+    }
+
+    /**
+     * Creates a new instance using configuration values specified
+     */
+    ConfigurationGroovyCustomizer(final Map<String,Object> keyValues) {
+        properties = keyValues;
+    }
+
+    public CompilerConfiguration applyCustomization(final CompilerConfiguration compilerConfiguration) {
+        final Class<CompilerConfiguration> clazz = CompilerConfiguration.class;
+        final List<Method> methods = Arrays.asList(clazz.getMethods());
+        for (Map.Entry<String,Object> entry : properties.entrySet()) {
+            final Method method = methods.stream().filter(m -> m.getName().equals("set" + entry.getKey())).findFirst()
+                   .orElseThrow(() -> new IllegalStateException("Invalid setting [" + entry.getKey() + "] for CompilerConfiguration"));
+
+            try {
+                method.invoke(compilerConfiguration, entry.getValue());
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+
+        return compilerConfiguration;
+    }
+
+    @Override
+    public CompilationCustomizer create() {
+        throw new UnsupportedOperationException("This is a marker implementation that does not create a CompilationCustomizer instance");
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
deleted file mode 100644
index 73614a1..0000000
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/CustomizerProviderCustomizer.java
+++ /dev/null
@@ -1,40 +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.
- */
-package org.apache.tinkerpop.gremlin.groovy.jsr223;
-
-import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
-import org.apache.tinkerpop.gremlin.jsr223.Customizer;
-
-/**
- * An adapter that allows existing {@link CompilerCustomizerProvider} instances to behave as a {#link Customizer}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class CustomizerProviderCustomizer implements Customizer {
-
-    private final CompilerCustomizerProvider customizerProvider;
-
-    CustomizerProviderCustomizer(final CompilerCustomizerProvider customizerProvider) {
-        this.customizerProvider = customizerProvider;
-    }
-
-    CompilerCustomizerProvider getCustomizerProvider() {
-        return customizerProvider;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index 2996792..0f36dbf 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -70,6 +70,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -177,6 +178,9 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
     private ImportCustomizerProvider importCustomizerProvider;
     private final List<CompilerCustomizerProvider> customizerProviders;
 
+    private final ImportGroovyCustomizer importGroovyCustomizer;
+    private final List<GroovyCustomizer> groovyCustomizers;
+
     private final Set<Artifact> artifactsToUse = new HashSet<>();
     private final boolean interpreterModeEnabled;
 
@@ -207,46 +211,21 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
                 .filter(p -> p instanceof ImportCustomizer)
                 .map(p -> (ImportCustomizer) p)
                 .collect(Collectors.toList());
-        if (importCustomizers.isEmpty()) {
-            importCustomizerProvider = NoImportCustomizerProvider.INSTANCE;
-        } else {
-            final Set<String> imports = new HashSet<>();
-            final Set<String> staticImports = new HashSet<>();
-            importCustomizers.forEach(ic -> {
-                ic.getClassImports().forEach(c -> {
-                    final String importStatement = c.getName();
-                    imports.add(importStatement);
-                });
-
-                ic.getEnumImports().forEach(e -> {
-                    final String importStatement = e.getDeclaringClass().getCanonicalName() + ".*";
-                    staticImports.add(importStatement);
-                });
+        final ImportCustomizer[] importCustomizerArray = new ImportCustomizer[importCustomizers.size()];
+        importGroovyCustomizer = new ImportGroovyCustomizer(importCustomizers.toArray(importCustomizerArray));
 
-                ic.getMethodImports().forEach(m -> {
-                    final String importStatement = m.getDeclaringClass().getCanonicalName() + ".*";
-                    staticImports.add(importStatement);
-                });
-            });
-
-            importCustomizerProvider = new EmptyImportCustomizerProvider(imports, staticImports);
-        }
-
-        // this is a bit temporary - until CompilerCustomizerProvider is gone
-        final List<CompilerCustomizerProvider> customizerProviderCustomizer = listOfCustomizers.stream()
-                .filter(p -> p instanceof CustomizerProviderCustomizer)
-                .map(p -> ((CustomizerProviderCustomizer) p).getCustomizerProvider())
+        groovyCustomizers = listOfCustomizers.stream()
+                .filter(p -> p instanceof GroovyCustomizer)
+                .map(p -> ((GroovyCustomizer) p))
                 .collect(Collectors.toList());
 
         // determine if interpreter mode should be enabled
-        interpreterModeEnabled = customizerProviderCustomizer.stream()
-                .anyMatch(p -> p.getClass().equals(InterpreterModeCustomizerProvider.class));
+        interpreterModeEnabled = groovyCustomizers.stream()
+                .anyMatch(p -> p.getClass().equals(InterpreterModeGroovyCustomizer.class));
 
-        // remove used providers as the rest will be applied directly
-        customizerProviders = customizerProviderCustomizer.stream()
-                .filter(p -> p != null &&
-                        !((p instanceof ImportCustomizerProvider)))
-                .collect(Collectors.toList());
+        // not using the old provider model so set that to empty list so that when createClassLoader is called
+        // it knows to use groovyCustomizers instead
+        customizerProviders = Collections.emptyList();
 
         createClassLoader();
     }
@@ -273,10 +252,14 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
 
         // remove used providers as the rest will be applied directly
         customizerProviders = providers.stream()
-                .filter(p -> p != null &&
-                        !((p instanceof ImportCustomizerProvider)))
+                .filter(p -> p != null && !(p instanceof ImportCustomizerProvider))
                 .collect(Collectors.toList());
 
+        // groovy customizers are not used here - set to empty list so that the customizerProviders get used
+        // in createClassLoader
+        groovyCustomizers = Collections.emptyList();
+        importGroovyCustomizer = null;
+
         createClassLoader();
     }
 
@@ -350,7 +333,11 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
      */
     @Override
     public synchronized void addImports(final Set<String> importStatements) {
-        final Set<String> staticImports = new HashSet<>();
+        // can't use this feature because imports can't come in as String for the revised model
+        if (null == importCustomizerProvider)
+            throw new IllegalStateException("Imports cannot be added to a GremlinGroovyScriptEngine that uses Customizer instances");
+
+            final Set<String> staticImports = new HashSet<>();
         final Set<String> imports = new HashSet<>();
 
         importStatements.forEach(s -> {
@@ -362,9 +349,8 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
                 imports.add(s.substring(6).trim());
         });
 
-        // use the EmptyImportCustomizer because it doesn't come with static initializers containing
-        // existing imports.
         importCustomizerProvider = new EmptyImportCustomizerProvider(importCustomizerProvider, imports, staticImports);
+
         internalReset();
     }
 
@@ -697,17 +683,32 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
     }
 
     private synchronized void createClassLoader() {
-        final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
-        conf.addCompilationCustomizers(this.importCustomizerProvider.create());
+        // check for customizerProviders temporarily until this deprecated stuff is gone
+        if (groovyCustomizers.isEmpty() && null == importGroovyCustomizer) {
+            final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
+            conf.addCompilationCustomizers(this.importCustomizerProvider.create());
 
-        // ConfigurationCustomizerProvider is treated separately
-        customizerProviders.stream().filter(cp -> !(cp instanceof ConfigurationCustomizerProvider))
-                .forEach(p -> conf.addCompilationCustomizers(p.create()));
+            // ConfigurationCustomizerProvider is treated separately
+            customizerProviders.stream().filter(cp -> !(cp instanceof ConfigurationCustomizerProvider))
+                    .forEach(p -> conf.addCompilationCustomizers(p.create()));
 
-        customizerProviders.stream().filter(cp -> cp instanceof ConfigurationCustomizerProvider).findFirst()
-                .ifPresent(cp -> ((ConfigurationCustomizerProvider) cp).applyCustomization(conf));
+            customizerProviders.stream().filter(cp -> cp instanceof ConfigurationCustomizerProvider).findFirst()
+                    .ifPresent(cp -> ((ConfigurationCustomizerProvider) cp).applyCustomization(conf));
 
-        this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf);
+            this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf);
+        } else {
+            final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
+            conf.addCompilationCustomizers(this.importGroovyCustomizer.create());
+
+            // ConfigurationCustomizerProvider is treated separately
+            groovyCustomizers.stream().filter(cp -> !(cp instanceof ConfigurationGroovyCustomizer))
+                    .forEach(p -> conf.addCompilationCustomizers(p.create()));
+
+            groovyCustomizers.stream().filter(cp -> cp instanceof ConfigurationGroovyCustomizer).findFirst()
+                    .ifPresent(cp -> ((ConfigurationGroovyCustomizer) cp).applyCustomization(conf));
+
+            this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf);
+        }
     }
 
     private void use(final Artifact artifact) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
index 0d2e9c6..71f5dc7 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPlugin.java
@@ -18,12 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.groovy.jsr223;
 
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider;
 import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
@@ -106,21 +100,21 @@ public class GroovyCompilerGremlinPlugin extends AbstractGremlinPlugin {
             final List<Customizer> list = new ArrayList<>();
 
             if (interpreterMode)
-                list.add(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+                list.add(new InterpreterModeGroovyCustomizer());
 
             if (!keyValues.isEmpty())
-                list.add(new CustomizerProviderCustomizer(new ConfigurationCustomizerProvider(keyValues)));
+                list.add(new ConfigurationGroovyCustomizer(keyValues));
 
             if (threadInterrupt)
-                list.add(new CustomizerProviderCustomizer(new ThreadInterruptCustomizerProvider()));
+                list.add(new ThreadInterruptGroovyCustomizer());
 
             if (timeInMillis > 0)
-                list.add(new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(timeInMillis)));
+                list.add(new TimedInterruptGroovyCustomizer(timeInMillis));
 
             if (compilation == Compilation.COMPILE_STATIC)
-                list.add(new CustomizerProviderCustomizer(new CompileStaticCustomizerProvider(extensions)));
+                list.add(new CompileStaticGroovyCustomizer(extensions));
             else if (compilation == Compilation.TYPE_CHECKED)
-                list.add(new CustomizerProviderCustomizer(new TypeCheckedCustomizerProvider(extensions)));
+                list.add(new TypeCheckedGroovyCustomizer(extensions));
             else if (compilation != Compilation.NONE)
                 throw new IllegalStateException("Use of unknown compilation type: " + compilation);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCustomizer.java
new file mode 100644
index 0000000..94426c0
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCustomizer.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface GroovyCustomizer extends Customizer {
+
+    /**
+     * Create a new instance of a {@code CompilationCustomizer} to add to the {@link GremlinGroovyScriptEngine}.
+     */
+    public CompilationCustomizer create();
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ImportGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ImportGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ImportGroovyCustomizer.java
new file mode 100644
index 0000000..79243a0
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ImportGroovyCustomizer.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class ImportGroovyCustomizer implements GroovyCustomizer {
+
+    private final List<ImportCustomizer> customizers;
+
+    ImportGroovyCustomizer(final ImportCustomizer... customizers) {
+        this.customizers = Arrays.asList(customizers);
+    }
+
+    ImportGroovyCustomizer(final ImportGroovyCustomizer ic, final ImportCustomizer... customizers) {
+        this.customizers = new ArrayList<>(Arrays.asList(customizers));
+        this.customizers.addAll(ic.customizers);
+    }
+
+    @Override
+    public CompilationCustomizer create() {
+        final org.codehaus.groovy.control.customizers.ImportCustomizer ic = new org.codehaus.groovy.control.customizers.ImportCustomizer();
+
+        // there's something weird in groovy about doing specific imports instead of wildcard imports. with wildcard
+        // imports groovy seems to allow methods to be overloaded with enums such that things like Column.values and
+        // __.values() can be resolved by the compiler. if they are both directly in the imports then one or the other
+        // can't be found. the temporary fix is to hardcode a wildcard import __ and then filter out the core imports
+        // from the incoming customizer. ultimately, the fix should be to resolve the naming conflicts to ensure a
+        // unique space somehow.
+        ic.addStaticStars(__.class.getCanonicalName());
+        for (ImportCustomizer customizer : customizers) {
+            customizer.getClassImports().forEach(i -> ic.addImports(i.getCanonicalName()));
+            customizer.getMethodImports().stream()
+                    .filter(m -> !m.getDeclaringClass().equals(__.class))
+                    .forEach(m -> ic.addStaticImport(m.getDeclaringClass().getCanonicalName(), m.getName()));
+            customizer.getEnumImports().forEach(m -> ic.addStaticImport(m.getDeclaringClass().getCanonicalName(), m.name()));
+        }
+
+        return ic;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/InterpreterModeGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/InterpreterModeGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/InterpreterModeGroovyCustomizer.java
new file mode 100644
index 0000000..89b471e
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/InterpreterModeGroovyCustomizer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.jsr223.ast.InterpreterMode;
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+/**
+ * Places the {@code ScriptEngine} in "interpreter mode" where local variables of a script are treated as global
+ * bindings. This implementation is technically not a true {@link GroovyCustomizer} instance as the
+ * "interpreter mode" feature does not require a {@code CompilerCustomizer}. This class merely acts as a flag that
+ * tells the {@link GremlinGroovyScriptEngine} to turn this feature on.
+ */
+class InterpreterModeGroovyCustomizer implements GroovyCustomizer {
+    @Override
+    public CompilationCustomizer create() {
+        return new ASTTransformationCustomizer(InterpreterMode.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ThreadInterruptGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ThreadInterruptGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ThreadInterruptGroovyCustomizer.java
new file mode 100644
index 0000000..4492c3c
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ThreadInterruptGroovyCustomizer.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import groovy.transform.ThreadInterrupt;
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+/**
+ * Injects checks for thread interruption into scripts.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class ThreadInterruptGroovyCustomizer implements GroovyCustomizer {
+    @Override
+    public CompilationCustomizer create() {
+        return new ASTTransformationCustomizer(ThreadInterrupt.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptGroovyCustomizer.java
new file mode 100644
index 0000000..c432164
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptGroovyCustomizer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import groovy.transform.TimedInterrupt;
+import org.codehaus.groovy.ast.tools.GeneralUtils;
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Injects a check in loops and other areas of code to interrupt script execution if the run time exceeds the
+ * specified time.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class TimedInterruptGroovyCustomizer implements GroovyCustomizer {
+    private static final long DEFAULT_INTERRUPTION_TIMEOUT = 60000;
+
+    private final long interruptionTimeout;
+
+    TimedInterruptGroovyCustomizer() {
+        this(DEFAULT_INTERRUPTION_TIMEOUT);
+    }
+
+    TimedInterruptGroovyCustomizer(final Long interruptionTimeout) {
+        this.interruptionTimeout = interruptionTimeout;
+    }
+
+    TimedInterruptGroovyCustomizer(final Integer interruptionTimeout) {
+        this.interruptionTimeout = interruptionTimeout.longValue();
+    }
+
+    @Override
+    public CompilationCustomizer create() {
+        final Map<String, Object> timedInterruptAnnotationParams = new HashMap<>();
+        timedInterruptAnnotationParams.put("value", interruptionTimeout);
+        timedInterruptAnnotationParams.put("unit", GeneralUtils.propX(GeneralUtils.classX(TimeUnit.class), TimeUnit.MILLISECONDS.toString()));
+        timedInterruptAnnotationParams.put("checkOnMethodStart", false);
+        timedInterruptAnnotationParams.put("thrown", GeneralUtils.classX(TimedInterruptTimeoutException.class));
+        return new ASTTransformationCustomizer(timedInterruptAnnotationParams, TimedInterrupt.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java
new file mode 100644
index 0000000..bdd49b3
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * An exception thrown from the {@link TimedInterruptCustomizerProvider} when the timeout is exceeded. This exception
+ * allows differentiation from other "timeout exceptions" that might occur.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TimedInterruptTimeoutException extends TimeoutException {
+    public TimedInterruptTimeoutException() {
+    }
+
+    public TimedInterruptTimeoutException(final String message) {
+        super(message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java
new file mode 100644
index 0000000..ac8dd1d
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import groovy.transform.TypeChecked;
+import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
+import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
+import org.codehaus.groovy.control.customizers.CompilationCustomizer;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Injects the {@code TypeChecked} transformer to enable type validation on script execution.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class TypeCheckedGroovyCustomizer implements GroovyCustomizer {
+
+    private final String extensions;
+
+    TypeCheckedGroovyCustomizer() {
+        this(null);
+    }
+
+    /**
+     * Configures the {@code TypeChecked} annotation to use optional extensions.  The argument should be one or more
+     * groovy scripts on the classpath or the fully qualified classname of a precompiled extension.  If there are
+     * multiple extensions then extensions should be comma separated.
+     */
+    TypeCheckedGroovyCustomizer(final String extensions) {
+        this.extensions = extensions;
+    }
+
+    @Override
+    public CompilationCustomizer create() {
+        final Map<String, Object> annotationParams = new HashMap<>();
+        if (extensions != null && !extensions.isEmpty()) {
+            if (extensions.contains(","))
+                annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList()));
+            else
+                annotationParams.put("extensions", Collections.singletonList(extensions));
+        }
+        return new ASTTransformationCustomizer(annotationParams, TypeChecked.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
index ab0bff5..4371e8a 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java
@@ -34,7 +34,9 @@ import java.util.stream.Stream;
  * Injects the {@code CompileStatic} transformer to enable type validation on script execution.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class CompileStaticCustomizerProvider implements CompilerCustomizerProvider {
 
     private final String extensions;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
index 78357cb..3c8b673 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java
@@ -35,7 +35,9 @@ import java.util.Map;
  * control over its internals.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class ConfigurationCustomizerProvider implements CompilerCustomizerProvider {
 
     private final Map<String,Object> properties;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
index 013ba8b..3044474 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java
@@ -29,7 +29,11 @@ import org.codehaus.groovy.control.customizers.CompilationCustomizer;
  * bindings. This implementation is technically not a true {@link CompilerCustomizerProvider} instance as the
  * "interpreter mode" feature does not require a {@code CompilerCustomizer}. This class merely acts as a flag that
  * tells the {@link org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine} to turn this feature on.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class InterpreterModeCustomizerProvider implements CompilerCustomizerProvider {
     @Override
     public CompilationCustomizer create() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
index e46e9b7..c5fc60c 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java
@@ -28,7 +28,9 @@ import org.codehaus.groovy.control.customizers.CompilationCustomizer;
  * Injects checks for thread interruption into scripts.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class ThreadInterruptCustomizerProvider implements CompilerCustomizerProvider {
     @Override
     public CompilationCustomizer create() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
index 9913088..f0e1080 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java
@@ -34,7 +34,9 @@ import java.util.concurrent.TimeUnit;
  * specified time.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class TimedInterruptCustomizerProvider implements CompilerCustomizerProvider {
     public static final long DEFAULT_INTERRUPTION_TIMEOUT = 60000;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java
index 40abd59..4063d4f 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java
@@ -23,7 +23,11 @@ import java.util.concurrent.TimeoutException;
 /**
  * An exception thrown from the {@link TimedInterruptCustomizerProvider} when the timeout is exceeded. This exception
  * allows differentiation from other "timeout exceptions" that might occur.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException}.
  */
+@Deprecated
 public class TimedInterruptTimeoutException extends TimeoutException {
     public TimedInterruptTimeoutException() {
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
index cf9147b..b5c2729 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java
@@ -34,7 +34,9 @@ import java.util.stream.Stream;
  * Injects the {@code TypeChecked} transformer to enable type validation on script execution.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced by a public class.
  */
+@Deprecated
 public class TypeCheckedCustomizerProvider implements CompilerCustomizerProvider {
 
     private final String extensions;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java
index 79df578..2c216d7 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java
@@ -35,7 +35,9 @@ import java.util.TreeSet;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, not replaced.
  */
+@Deprecated
 public class VariableIdentificationCustomizer extends CompilationCustomizer {
 
     private static final ThreadLocal<Set<String>> variables = new ThreadLocal<Set<String>>()  {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
index b62f3f3..6f3383e 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
@@ -59,8 +59,8 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
             assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
         }
 
-        final CompileStaticCustomizerProvider provider = new CompileStaticCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(provider))) {
+        final CompileStaticGroovyCustomizer provider = new CompileStaticGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) {
             scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
@@ -92,14 +92,14 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
     @Test
     public void shouldCompileStaticWithExtension() throws Exception {
         // with no type checking extension this should pass
-        final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+        final CompileStaticGroovyCustomizer providerNoExtension = new CompileStaticGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
             assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
         }
 
-        final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
+        final CompileStaticGroovyCustomizer providerWithExtension = new CompileStaticGroovyCustomizer(
                 PrecompiledExtensions.PreventColorUsageExtension.class.getName());
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
             scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
@@ -140,16 +140,16 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
     @Test
     public void shouldCompileStaticWithMultipleExtension() throws Exception {
         // with no type checking extension this should pass
-        final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+        final CompileStaticGroovyCustomizer providerNoExtension = new CompileStaticGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
             assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
             assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"));
         }
 
-        final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
+        final CompileStaticGroovyCustomizer providerWithExtension = new CompileStaticGroovyCustomizer(
                 PrecompiledExtensions.PreventColorUsageExtension.class.getName() +
                         "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName());
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
             scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
             fail("Should have failed type checking");
         } catch (ScriptException se) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
index 6b18ece..289b2ca 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
@@ -41,9 +41,8 @@ public class GremlinGroovyScriptEngineConfigTest {
 
     @Test
     public void shouldAddBaseScriptClass() throws Exception {
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(
-                new ConfigurationCustomizerProvider("ScriptBaseClass", BaseScriptForTesting.class.getName())),
-                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(
+                new ConfigurationGroovyCustomizer("ScriptBaseClass", BaseScriptForTesting.class.getName()));
 
         assertEquals("hello, stephen", engine.eval("hello('stephen')"));
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index 65dc56e..eb0a44b 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -122,7 +122,7 @@ public class GremlinGroovyScriptEngineTest {
 
     @Test
     public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception {
-        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeGroovyCustomizer());
         engine.eval("def addItUp = { x, y -> x + y }");
         assertEquals(3, engine.eval("int xxx = 1 + 2"));
         assertEquals(4, engine.eval("yyy = xxx + 1"));
@@ -168,7 +168,7 @@ public class GremlinGroovyScriptEngineTest {
 
     @Test
     public void shouldPromoteDefinedVarsInInterpreterModeWithBindings() throws Exception {
-        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new InterpreterModeCustomizerProvider()));
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeGroovyCustomizer());
         final Bindings b = new SimpleBindings();
         b.put("x", 2);
         engine.eval("def addItUp = { x, y -> x + y }", b);
@@ -354,7 +354,7 @@ public class GremlinGroovyScriptEngineTest {
         final CountDownLatch latch = new CountDownLatch(1);
         final AtomicReference<Color> color = new AtomicReference<>(Color.RED);
 
-        final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine();
+        final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(NoImportCustomizerProvider.INSTANCE);
 
         try {
             scriptEngine.eval("Color.BLACK");

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
index ea778c6..499373f 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java
@@ -55,7 +55,7 @@ public class GremlinGroovyScriptEngineThreadInterruptTest {
 
     @Test
     public void shouldInterruptWhile() throws Exception {
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(new ThreadInterruptCustomizerProvider()));
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new ThreadInterruptGroovyCustomizer());
         final AtomicBoolean asserted = new AtomicBoolean(false);
 
         final Thread t = new Thread(() -> {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
index fa8d4ef..1745b5d 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
 
 import javax.script.ScriptEngine;
 import javax.script.ScriptException;
-import java.util.concurrent.TimeoutException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
@@ -49,14 +48,12 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
 
     @Test
     public void shouldTimeoutScriptOnTimedWhile() throws Exception {
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
-                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new TimedInterruptGroovyCustomizer(1000));
         try {
             engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
             fail("This should have timed out");
         } catch (ScriptException se) {
-            assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+            assertEquals(org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
         }
     }
 
@@ -78,15 +75,13 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
 
     @Test
     public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTimeout() throws Exception {
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
-                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new TimedInterruptGroovyCustomizer(1000));
         Thread.sleep(2000);
         try {
             engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}");
             fail("This should have timed out");
         } catch (ScriptException se) {
-            assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+            assertEquals(org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
         }
 
         assertEquals(2, engine.eval("1+1"));
@@ -116,8 +111,7 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
     @Test
     public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception {
         final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1000)),
-                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+                new TimedInterruptGroovyCustomizer(1000));
 
         for (int ix = 0; ix < 5; ix++) {
             try {
@@ -125,7 +119,7 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
                 engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {}");
                 fail("This should have timed out");
             } catch (ScriptException se) {
-                assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
+                assertEquals(org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
             }
 
             // this script takes 500 ms less than the interruptionTimeout
@@ -148,9 +142,7 @@ public class GremlinGroovyScriptEngineTimedInterruptTest {
     @Test
     public void shouldNotTimeoutStandaloneFunction() throws Exception {
         // use a super fast timeout which should not prevent the call of a cached function
-        final ScriptEngine engine = new GremlinGroovyScriptEngine(
-                new CustomizerProviderCustomizer(new TimedInterruptCustomizerProvider(1)),
-                new CustomizerProviderCustomizer(new DefaultImportCustomizerProvider()));
+        final ScriptEngine engine = new GremlinGroovyScriptEngine(new TimedInterruptGroovyCustomizer(1));
         engine.eval("def addItUp(x,y) { x + y }");
 
         assertEquals(3, engine.eval("addItUp(1,2)"));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
index 0ca12d7..6c70e8e 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
@@ -60,8 +60,8 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
             assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
         }
 
-        final TypeCheckedCustomizerProvider provider = new TypeCheckedCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(provider))) {
+        final TypeCheckedGroovyCustomizer provider = new TypeCheckedGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) {
             scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
@@ -93,14 +93,14 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
     @Test
     public void shouldTypeCheckWithExtension() throws Exception {
         // with no type checking extension this should pass
-        final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+        final TypeCheckedGroovyCustomizer providerNoExtension = new TypeCheckedGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
             assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
         }
 
         final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider(
                 PrecompiledExtensions.PreventColorUsageExtension.class.getName());
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
             scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
@@ -141,16 +141,16 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
     @Test
     public void shouldTypeCheckWithMultipleExtension() throws Exception {
         // with no type checking extension this should pass
-        final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerNoExtension))) {
+        final TypeCheckedGroovyCustomizer providerNoExtension = new TypeCheckedGroovyCustomizer();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
             assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
             assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"));
         }
 
-        final TypeCheckedCustomizerProvider providerWithExtension = new TypeCheckedCustomizerProvider(
+        final TypeCheckedGroovyCustomizer providerWithExtension = new TypeCheckedGroovyCustomizer(
                 PrecompiledExtensions.PreventColorUsageExtension.class.getName() +
                         "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName());
-        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(new CustomizerProviderCustomizer(providerWithExtension))) {
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
             scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
             fail("Should have failed type checking");
         } catch (ScriptException se) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
index 8d2178f..f795fa7 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java
@@ -58,7 +58,7 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(CompileStaticCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(CompileStaticGroovyCustomizer.class));
     }
 
     @Test
@@ -68,7 +68,7 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(TypeCheckedCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(TypeCheckedGroovyCustomizer.class));
     }
 
     @Test
@@ -80,12 +80,12 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(ConfigurationCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(ConfigurationGroovyCustomizer.class));
 
         final CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
         assertThat(compilerConfiguration.getDebug(), is(false));
 
-        final ConfigurationCustomizerProvider provider = (ConfigurationCustomizerProvider) ((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider();
+        final ConfigurationGroovyCustomizer provider = (ConfigurationGroovyCustomizer) customizers.get()[0];
         provider.applyCustomization(compilerConfiguration);
 
         assertThat(compilerConfiguration.getDebug(), is(true));
@@ -98,7 +98,7 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(InterpreterModeCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(InterpreterModeGroovyCustomizer.class));
     }
 
     @Test
@@ -108,7 +108,7 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(ThreadInterruptCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(ThreadInterruptGroovyCustomizer.class));
     }
 
     @Test
@@ -118,7 +118,7 @@ public class GroovyCompilerGremlinPluginTest {
         final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy");
         assertThat(customizers.isPresent(), is(true));
         assertEquals(1, customizers.get().length);
-        assertThat(((CustomizerProviderCustomizer) customizers.get()[0]).getCustomizerProvider(), instanceOf(TimedInterruptCustomizerProvider.class));
+        assertThat(customizers.get()[0], instanceOf(TimedInterruptGroovyCustomizer.class));
     }
 
     @Test(expected = IllegalStateException.class)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a82c56fa/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 b931b8c..d5fe62a 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
@@ -279,6 +279,11 @@ public abstract class AbstractEvalOpProcessor extends AbstractOpProcessor {
                     final String errorMessage = String.format("A timeout occurred within the script during evaluation of [%s] - consider increasing the limit given to TimedInterruptCustomizerProvider", msg);
                     logger.warn(errorMessage);
                     ctx.writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SERVER_ERROR_TIMEOUT).statusMessage("Timeout during script evaluation triggered by TimedInterruptCustomizerProvider").create());
+                } else if (t instanceof org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException) {
+                    // occurs when the TimedInterruptCustomizerProvider is in play
+                    final String errorMessage = String.format("A timeout occurred within the script during evaluation of [%s] - consider increasing the limit given to TimedInterruptCustomizerProvider", msg);
+                    logger.warn(errorMessage);
+                    ctx.writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SERVER_ERROR_TIMEOUT).statusMessage("Timeout during script evaluation triggered by TimedInterruptCustomizerProvider").create());
                 } else if (t instanceof TimeoutException) {
                     final String errorMessage = String.format("Response evaluation exceeded the configured threshold for request [%s] - %s", msg, t.getMessage());
                     logger.warn(errorMessage, t);