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/05/02 16:13:43 UTC
[1/2] incubator-tinkerpop git commit: Added option for "none" on
remote timeouts.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/tp31 14966d789 -> 704b023e8
Added option for "none" on remote timeouts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/2284ea90
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/2284ea90
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/2284ea90
Branch: refs/heads/tp31
Commit: 2284ea90b5f3c93c2d0699cce67f7e481382d8d3
Parents: 14966d7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 26 07:35:23 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 2 06:59:59 2016 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../src/reference/gremlin-applications.asciidoc | 4 +--
.../upgrade/release-3.1.x-incubating.asciidoc | 25 ++++++++++++++++
.../groovy/plugin/DriverRemoteAcceptor.java | 30 ++++++++++++++------
.../groovy/plugin/DriverRemoteAcceptorTest.java | 18 ++++++++++++
5 files changed, 68 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2284ea90/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5600245..1848fdf 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Added configuration option for disabling `:remote` timeout with `:remote config timeout none`.
* Added `init-tp-spark.sh` to Gremlin Console binary distribution.
* Fixed bug where use of `:x` in a Gremlin Console initialization script would generate a stack trace.
* Added configuration options to Gremlin Driver and Server to override the SSL configuration with an `SslContext`.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2284ea90/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index 410dfe1..a894335 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -467,8 +467,8 @@ The Gremlin Server `:remote config` command for the driver has the following con
!`reset` !Clears any aliases that were supplied in previous configurations of the remote.
!`show` !Shows the current set of aliases which is returned as a `Map`
!=========================================================
-|timeout |Specifies the length of time in milliseconds a will wait for a response from the server. Specify "max" to
-essentially have no timeout.
+|timeout |Specifies the length of time in milliseconds a will wait for a response from the server. Specify "none" to
+have no timeout. By default, this setting uses "none".
|=========================================================
[[console-aliases]]
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2284ea90/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 070cc52..4de6dbd 100644
--- a/docs/src/upgrade/release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
@@ -29,6 +29,31 @@ TinkerPop 3.1.3
Please see the link:https://github.com/apache/incubator-tinkerpop/blob/3.1.2-incubating/CHANGELOG.asciidoc#tinkerpop-313-release-date-MONTH-DAY-YEAR[changelog] for a complete list of all the modifications that are part of this release.
+Upgrading for Users
+~~~~~~~~~~~~~~~~~~~
+
+Remote Timeout
+^^^^^^^^^^^^^^
+
+Disabling the timeout for a `:remote` to Gremlin Server was previously accomplished by setting the timeout to `max` as
+in:
+
+[source,text]
+:remote config timeout max
+
+where `max` would set the timeout to be `Integer.MAX_VALUE`. While this feature is still supported, it has been
+deprecated in favor of the new configuration option of `none`, as in:
+
+[source,text]
+:remote config timeout none
+
+The use of `none` completely disables the timeout rather than just setting an arbitrarily high one. Note that it is
+still possible to get a timeout on a request if the server timeout limits are reached. The console timeout value only
+refers to how long the console will wait for a response from the server before giving up. By default, the timeout is
+set to `none`.
+
+See: https://issues.apache.org/jira/browse/TINKERPOP-1267[TINKERPOP-1267]
+
Upgrading for Providers
~~~~~~~~~~~~~~~~~~~~~~~
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2284ea90/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 c92d5b3..ed98011 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
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.console.groovy.plugin;
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.groovy.plugin.RemoteAcceptor;
@@ -52,15 +53,23 @@ import java.util.stream.Stream;
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class DriverRemoteAcceptor implements RemoteAcceptor {
+ public static final int NO_TIMEOUT = -1;
+
private Cluster currentCluster;
private Client currentClient;
- private int timeout = 180000;
+ 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-incubating, 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";
@@ -104,13 +113,14 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
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 'max' as an argument";
+ 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 {
- final int to = arguments.get(0).equals(TOKEN_MAX) ? Integer.MAX_VALUE : Integer.parseInt(arguments.get(0));
- if (to <= 0) throw new RemoteException(errorMessage);
- this.timeout = to;
- return "Set remote timeout to " + to + "ms";
+ // 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));
+ return timeout == NO_TIMEOUT ? "Remote timeout is disable" : "Set remote timeout to " + timeout + "ms";
} catch (Exception ignored) {
throw new RemoteException(errorMessage);
}
@@ -171,10 +181,14 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
if (this.currentCluster != null) this.currentCluster.close();
}
+ public int getTimeout() {
+ return timeout;
+ }
+
private List<Result> send(final String gremlin) throws SaslException {
try {
- return this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get()
- .all().get(this.timeout, TimeUnit.MILLISECONDS);
+ final ResultSet rs = this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get();
+ return timeout > 0 ? 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) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2284ea90/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
index d341098..987a932 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
@@ -109,6 +109,24 @@ public class DriverRemoteAcceptorTest {
}
@Test
+ public void shouldConfigureTimeoutToMax() throws Exception {
+ acceptor.configure(Arrays.asList("timeout", "max"));
+ assertEquals(Integer.MAX_VALUE, acceptor.getTimeout());
+ }
+
+ @Test
+ public void shouldConfigureTimeoutToNone() throws Exception {
+ acceptor.configure(Arrays.asList("timeout", "none"));
+ assertEquals(DriverRemoteAcceptor.NO_TIMEOUT, acceptor.getTimeout());
+ }
+
+ @Test
+ public void shouldConfigureTimeout() throws Exception {
+ acceptor.configure(Arrays.asList("timeout", "123456"));
+ assertEquals(123456, acceptor.getTimeout());
+ }
+
+ @Test
public void shouldConnect() throws Exception {
// there is no gremlin server running for this test, but gremlin-driver lazily connects so this should
// be ok to just validate that a connection is created
[2/2] incubator-tinkerpop git commit: Changed timeout 'none' to a
zero setting.
Posted by sp...@apache.org.
Changed timeout 'none' to a zero setting.
Added more validation and fixed grammatical error in console output.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/704b023e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/704b023e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/704b023e
Branch: refs/heads/tp31
Commit: 704b023e8967656116d2c1437ed96c47bc83708f
Parents: 2284ea9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 2 07:19:38 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 2 07:19:38 2016 -0400
----------------------------------------------------------------------
.../gremlin/console/groovy/plugin/DriverRemoteAcceptor.java | 8 ++++----
.../console/groovy/plugin/DriverRemoteAcceptorTest.java | 5 +++++
2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/704b023e/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 ed98011..5a0f6ef 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
@@ -29,7 +29,6 @@ import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.codehaus.groovy.tools.shell.Groovysh;
-import org.codehaus.groovy.tools.shell.Parser;
import javax.security.sasl.SaslException;
import java.io.FileNotFoundException;
@@ -53,7 +52,7 @@ import java.util.stream.Stream;
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class DriverRemoteAcceptor implements RemoteAcceptor {
- public static final int NO_TIMEOUT = -1;
+ public static final int NO_TIMEOUT = 0;
private Cluster currentCluster;
private Client currentClient;
@@ -120,7 +119,8 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
// 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));
- return timeout == NO_TIMEOUT ? "Remote timeout is disable" : "Set remote timeout to " + timeout + "ms";
+ 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);
}
@@ -188,7 +188,7 @@ public class DriverRemoteAcceptor implements RemoteAcceptor {
private List<Result> send(final String gremlin) throws SaslException {
try {
final ResultSet rs = this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get();
- return timeout > 0 ? rs.all().get(timeout, TimeUnit.MILLISECONDS) : rs.all().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) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/704b023e/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
index 987a932..4bac249 100644
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
@@ -126,6 +126,11 @@ public class DriverRemoteAcceptorTest {
assertEquals(123456, acceptor.getTimeout());
}
+ @Test(expected = RemoteException.class)
+ public void shouldConfigureTimeoutNotLessThanNoTimeout() throws Exception {
+ acceptor.configure(Arrays.asList("timeout", "-1"));
+ }
+
@Test
public void shouldConnect() throws Exception {
// there is no gremlin server running for this test, but gremlin-driver lazily connects so this should