tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject incubator-tinkerpop git commit: Changed timeout 'none' to a zero setting.
Date Mon, 02 May 2016 11:20:38 GMT
Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1267 2284ea90b -> 704b023e8


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/TINKERPOP-1267
Commit: 704b023e8967656116d2c1437ed96c47bc83708f
Parents: 2284ea9
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Mon May 2 07:19:38 2016 -0400
Committer: Stephen Mallette <spmva@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


Mime
View raw message