You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/03/30 19:58:35 UTC
[1/3] incubator-tinkerpop git commit: Fixed bug where some scripts
weren't submitting with :>
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 5177109be -> 4626ed02a
Fixed bug where some scripts weren't submitting with :>
The issue had to do with all scripts being converted to multi-line which was necessary for remote requests in console mode. However in local mode :> commands don't accept multiple lines. Had to rectify that by assembling multi-line scripts in GremlinGroovysh instead of DriverRemoteAcceptor. CTR
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/92f61576
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/92f61576
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/92f61576
Branch: refs/heads/master
Commit: 92f61576d51c95167c99b3cf505bfe155bb45c4b
Parents: 3b053ea
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 30 13:51:37 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 30 13:55:14 2016 -0400
----------------------------------------------------------------------
.../org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy | 5 ++++-
.../gremlin/console/groovy/plugin/DriverRemoteAcceptor.java | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/92f61576/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
index 0cbd500..31a8ba8 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.console
import org.codehaus.groovy.tools.shell.Command
import org.codehaus.groovy.tools.shell.Groovysh
import org.codehaus.groovy.tools.shell.ParseCode
+import org.codehaus.groovy.tools.shell.Parser
/**
* Overrides the posix style parsing of Groovysh allowing for commands to parse prior to Groovy 2.4.x.
@@ -84,7 +85,9 @@ class GremlinGroovysh extends Groovysh {
switch (status.code) {
case ParseCode.COMPLETE:
- setLastResult(mediator.currentRemote().submit(current))
+ // concat script here because commands don't support multi-line
+ def script = String.join(Parser.getNEWLINE(), current)
+ setLastResult(mediator.currentRemote().submit([script]))
buffers.clearSelected()
break
case ParseCode.INCOMPLETE:
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/92f61576/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 7733524..c92d5b3 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
@@ -138,7 +138,7 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
@Override
public Object submit(final List<String> args) throws RemoteException {
- final String line = RemoteAcceptor.getScript(String.join(Parser.getNEWLINE(), args), this.shell);
+ final String line = RemoteAcceptor.getScript(String.join(" ", args), this.shell);
try {
final List<Result> resultSet = send(line);
[3/3] incubator-tinkerpop git commit: Merge remote-tracking branch
'origin/tp31'
Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/tp31'
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/4626ed02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4626ed02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4626ed02
Branch: refs/heads/master
Commit: 4626ed02a63e79297b20593eba4c182cd7a63fd2
Parents: 5177109 92f6157
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 30 13:58:06 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 30 13:58:06 2016 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/dev/provider/index.asciidoc | 7 ++++++
.../upgrade/release-3.1.x-incubating.asciidoc | 7 ++++++
.../gremlin/console/GremlinGroovysh.groovy | 5 ++++-
.../groovy/plugin/DriverRemoteAcceptor.java | 2 +-
.../apache/tinkerpop/gremlin/driver/Tokens.java | 1 +
.../server/op/AbstractEvalOpProcessor.java | 5 +++++
.../server/GremlinServerIntegrateTest.java | 23 ++++++++++++++++++--
8 files changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4626ed02/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4626ed02/docs/src/dev/provider/index.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4626ed02/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4626ed02/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------
[2/3] incubator-tinkerpop git commit: Added infrastructure for
supporting a per-request timeout override. CTR
Posted by sp...@apache.org.
Added infrastructure for supporting a per-request timeout override. CTR
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/3b053eab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/3b053eab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/3b053eab
Branch: refs/heads/master
Commit: 3b053eabeb4ef3b9fec1f667ccd54d0c91d29b76
Parents: 1128dc3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 30 13:50:53 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 30 13:55:14 2016 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/dev/provider/index.asciidoc | 7 ++++++
.../upgrade/release-3.1.x-incubating.asciidoc | 7 ++++++
.../apache/tinkerpop/gremlin/driver/Tokens.java | 1 +
.../server/op/AbstractEvalOpProcessor.java | 5 +++++
.../server/GremlinServerIntegrateTest.java | 23 ++++++++++++++++++--
6 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5d7995b..f90e71f 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,7 @@ TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Provided Docker script that allows the execution of several build tasks within a Docker container.
+* Added a per-request `scriptEvaluationTimeout` option to the Gremlin Server protocol.
* Changed `DriverRemoteAcceptor` to send scripts as multi-line.
* Fixed a bug in `gremlin-driver` where connections were not returning to the pool after many consecutive errors.
* Fixed a bug where `tree()` did not serialize into GraphSON.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/docs/src/dev/provider/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc
index 3299618..f8869af 100644
--- a/docs/src/dev/provider/index.asciidoc
+++ b/docs/src/dev/provider/index.asciidoc
@@ -747,6 +747,7 @@ be aliased to different variable names for purposes of the current request. The
global variable and its key represents the new binding name as it will be referenced in the Gremlin query. For
example, if the Gremlin Server defines two `TraversalSource` instances named `g1` and `g2`, it would be possible
to send an alias pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
+|scriptEvalTimeout |Long |An override for the server setting that determines the maximum time to wait for a script to execute on the server.
|=========================================================
Session OpProcessor
@@ -787,7 +788,13 @@ Gremlin Server are deployed, session state is not shared among them.
|session |String | *Required* The session identifier for the current session - typically this value should be a UUID (the session will be created if it doesn't exist).
|manageTransaction |Boolean |When set to `true` the transaction for the current request is auto-committed or rolled-back as are done with sessionless requests - defaulted to `false`.
|bindings |Map |A map of key/value pairs to apply as variables in the context of the Gremlin script.
+|scriptEvalTimeout |Long |An override for the server setting that determines the maximum time to wait for a script to execute on the server.
|language |String |The flavor of Gremlin used (e.g. `gremlin-groovy`)
+|aliases |Map |A map of key/value pairs that allow globally bound `Graph` and `TraversalSource` objects to
+be aliased to different variable names for purposes of the current request. The value represents the name the
+global variable and its key represents the new binding name as it will be referenced in the Gremlin query. For
+example, if the Gremlin Server defines two `TraversalSource` instances named `g1` and `g2`, it would be possible
+to send an alias pair with key of "g" and value of "g2" and thus allow the script to refer to "g2" simply as "g".
|=========================================================
'`close` operation arguments'
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/docs/src/upgrade/release-3.1.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.1.x-incubating.asciidoc b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
index b450ece..ba7298a 100644
--- a/docs/src/upgrade/release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
@@ -144,6 +144,13 @@ this value as `false`, so there is no change to the protocol for this feature.
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1039[TINKERPOP-1039],
link:http://tinkerpop.apache.org/docs/3.1.2-incubating/reference/#sessions[Reference Documentation - Considering Sessions]
+scriptEvalTimeout Override
+++++++++++++++++++++++++++
+
+The Gremlin Server protocol now allows the passing of `scriptEvaluationTimeout` as an argument to the `SessionOpProcessor`
+and the `StandardOpProcessor`. This value will override the setting of the same name provided in the Gremlin Server
+configuration file on a per request basis.
+
Plugin Providers
^^^^^^^^^^^^^^^^
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
index dbb37c6..937017a 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
@@ -47,6 +47,7 @@ public final class Tokens {
public static final String ARGS_IMPORTS = "imports";
public static final String ARGS_INFO_TYPE = "infoType";
public static final String ARGS_LANGUAGE = "language";
+ public static final String ARGS_SCRIPT_EVAL_TIMEOUT = "scriptEvaluationTimeout";
/**
* @deprecated As of release 3.1.0-incubating, replaced by {@link #ARGS_ALIASES}.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/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 e168857..c565ed9 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
@@ -195,7 +195,12 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
final boolean managedTransactionsForRequest = manageTransactions ?
true : (Boolean) args.getOrDefault(Tokens.ARGS_MANAGE_TRANSACTION, false);
+ // timeout override
+ final long seto = args.containsKey(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT) ?
+ Long.parseLong(args.get(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT).toString()) : settings.scriptEvaluationTimeout;
+
final GremlinExecutor.LifeCycle lifeCycle = GremlinExecutor.LifeCycle.build()
+ .scriptEvaluationTimeoutOverride(seto)
.beforeEval(b -> {
try {
b.putAll(bindingsSupplier.get());
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3b053eab/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 86723b4..fdcf358 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
@@ -21,8 +21,11 @@ package org.apache.tinkerpop.gremlin.server;
import java.io.File;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.log4j.Logger;
-import org.apache.tinkerpop.gremlin.driver.*;
-import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
+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.Tokens;
import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
@@ -487,6 +490,22 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
}
@Test
+ @SuppressWarnings("unchecked")
+ public void shouldReceiveFailureTimeOutOnScriptEvalUsingOverride() throws Exception {
+ try (SimpleClient client = new WebSocketClient()) {
+ final RequestMessage msg = RequestMessage.build("eval")
+ .addArg(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT, 100)
+ .addArg(Tokens.ARGS_GREMLIN, "Thread.sleep(3000);'some-stuff-that-should not return'")
+ .create();
+ final List<ResponseMessage> responses = client.submit(msg);
+ assertThat(responses.get(0).getStatus().getMessage(), startsWith("Script evaluation exceeded the configured 'scriptEvaluationTimeout' threshold of 100 ms for request"));
+
+ // validate that we can still send messages to the server
+ assertEquals(2, ((List<Integer>) client.submit("1+1").get(0).getResult().getData()).get(0).intValue());
+ }
+ }
+
+ @Test
public void shouldReceiveFailureTimeOutOnScriptEvalOfOutOfControlLoop() throws Exception {
try (SimpleClient client = new WebSocketClient()){
// timeout configured for 1 second so the timed interrupt should trigger prior to the