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/07/08 18:15:18 UTC

[01/12] tinkerpop git commit: Fixed logic in ConnectionPool that was preventing it from growing.

Repository: tinkerpop
Updated Branches:
  refs/heads/tp31 bb9d718cc -> c8c77afeb


Fixed logic in ConnectionPool that was preventing it from growing.

Also, fixed a bug (an invalid FastNoSuchElementException)  in Gremlin Server that would only appear when the server paused writes to an overwhelmed client.


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

Branch: refs/heads/tp31
Commit: bc397eca68caa9b0fb41f6146bd610bf6530c9ab
Parents: d699cb6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 29 15:14:00 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jun 29 15:14:00 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                       |  2 ++
 .../apache/tinkerpop/gremlin/driver/ConnectionPool.java  | 10 +---------
 gremlin-server/conf/gremlin-server-neo4j.yaml            |  2 +-
 gremlin-server/conf/gremlin-server-rest-secure.yaml      |  2 +-
 gremlin-server/conf/gremlin-server-secure.yaml           |  2 +-
 gremlin-server/conf/gremlin-server-spark.yaml            |  2 +-
 gremlin-server/conf/gremlin-server.yaml                  |  2 +-
 .../gremlin/server/op/AbstractEvalOpProcessor.java       | 11 ++++++++++-
 .../gremlin/server/gremlin-server-integration.yaml       |  2 +-
 .../gremlin/server/gremlin-server-performance.yaml       |  2 +-
 10 files changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a359eca..f2d4153 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,8 @@ TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
 * Fixed bug in `IoGraphTest` causing IllegalArgumentException: URI is not hierarchical error for external graph implementations.
 * Fixed a bug where timeout functions provided to the `GremlinExecutor` were not executing in the same thread as the script evaluation.
 * Optimized a few special cases in `RangeByIsCountStrategy`.
+* Fixed a bug where the `ConnectionPool` in the driver would not grow with certain configuration options.
+* Fixed a bug where pauses in Gremlin Server writing to an overtaxed client would generate unexpected `FastNoSuchElementException` errors.
 * Named the thread pool used by Gremlin Server sessions: "gremlin-server-session-$n".
 * Fixed a bug in `BulkSet.equals()` which made itself apparent when using `store()` and `aggregate()` with labeled `cap()`.
 * Fixed a bug where `Result.one()` could potentially block indefinitely under certain circumstances.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index aab9646..52c6b6a 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -148,15 +148,7 @@ final class ConnectionPool {
             final int borrowed = leastUsedConn.borrowed.get();
             final int availableInProcess = leastUsedConn.availableInProcess();
 
-            // if the number borrowed starts to exceed what's available for this connection, then we need
-            // to wait for a connection to become available. this is an interesting comparison for "busy-ness"
-            // because it compares the number of times the connection was borrowed to what's in-process.  the
-            // in-process number refers to the number of outstanding requests less the maxInProcessForConnection
-            // setting.  this scenario can only really happen if
-            // maxInProcessForConnection=maxSimultaneousUsagePerConnection or if there is some sort of batch type
-            // operation where more than one message is sent on a single borrowed connection before it is returned
-            // to the pool.
-            if (borrowed >= leastUsedConn.availableInProcess()) {
+            if (borrowed >= maxSimultaneousUsagePerConnection && leastUsedConn.availableInProcess() == 0) {
                 logger.debug("Least used connection selected from pool for {} but borrowed [{}] >= availableInProcess [{}] - wait",
                         host, borrowed, availableInProcess);
                 return waitForConnection(timeout, unit);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/conf/gremlin-server-neo4j.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-neo4j.yaml b/gremlin-server/conf/gremlin-server-neo4j.yaml
index e9d6cd7..ca2d99c 100644
--- a/gremlin-server/conf/gremlin-server-neo4j.yaml
+++ b/gremlin-server/conf/gremlin-server-neo4j.yaml
@@ -66,7 +66,7 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536
 ssl: {
   enabled: false}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/conf/gremlin-server-rest-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-rest-secure.yaml b/gremlin-server/conf/gremlin-server-rest-secure.yaml
index 0659f74..7a337e0 100644
--- a/gremlin-server/conf/gremlin-server-rest-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-rest-secure.yaml
@@ -66,7 +66,7 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536
 authentication: {
   className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/conf/gremlin-server-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-secure.yaml b/gremlin-server/conf/gremlin-server-secure.yaml
index 721932b..91623b7 100644
--- a/gremlin-server/conf/gremlin-server-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-secure.yaml
@@ -66,7 +66,7 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536
 authentication: {
   className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/conf/gremlin-server-spark.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-spark.yaml b/gremlin-server/conf/gremlin-server-spark.yaml
index e6510b6..804df73 100644
--- a/gremlin-server/conf/gremlin-server-spark.yaml
+++ b/gremlin-server/conf/gremlin-server-spark.yaml
@@ -79,7 +79,7 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536
 ssl: {
   enabled: false}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/conf/gremlin-server.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server.yaml b/gremlin-server/conf/gremlin-server.yaml
index f310f56..fe11127 100644
--- a/gremlin-server/conf/gremlin-server.yaml
+++ b/gremlin-server/conf/gremlin-server.yaml
@@ -56,7 +56,7 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536
 ssl: {
   enabled: false}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/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 a5dd0a0..e748fe3 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
@@ -321,11 +321,20 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
             // so iterating next() if the message is not written and flushed would bump the aggregate size beyond
             // the expected resultIterationBatchSize.  Total serialization time for the response remains in
             // effect so if the client is "slow" it may simply timeout.
-            if (aggregate.size() < resultIterationBatchSize) aggregate.add(itty.next());
+            //
+            // there is a need to check hasNext() on the iterator because if the channel is not writeable the
+            // previous pass through the while loop will have next()'d the iterator and if it is "done" then a
+            // NoSuchElementException will raise its head.
+            //
+            // this could be placed inside the isWriteable() portion of the if-then below but it seems better to
+            // allow iteration to continue into a batch if that is possible rather than just doing nothing at all
+            // while waiting for the client to catch up
+            if (aggregate.size() < resultIterationBatchSize && itty.hasNext()) aggregate.add(itty.next());
 
             // send back a page of results if batch size is met or if it's the end of the results being iterated.
             // also check writeability of the channel to prevent OOME for slow clients.
             if (ctx.channel().isWritable()) {
+
                 if (aggregate.size() == resultIterationBatchSize || !itty.hasNext()) {
                     final ResponseStatusCode code = itty.hasNext() ? ResponseStatusCode.PARTIAL_CONTENT : ResponseStatusCode.SUCCESS;
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
index 054f0dd..88c95b7 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
@@ -55,5 +55,5 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc397eca/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
index 841523c..ed7444c 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
@@ -54,5 +54,5 @@ maxChunkSize: 8192
 maxContentLength: 65536
 maxAccumulationBufferComponents: 1024
 resultIterationBatchSize: 64
-writeBufferHighWaterMark: 32768
+writeBufferLowWaterMark: 32768
 writeBufferHighWaterMark: 65536


[08/12] tinkerpop git commit: Increased settings on Cluster creation in test.

Posted by sp...@apache.org.
Increased settings on Cluster creation in test.

The test uses a fair degree of parallelism and now that other bug fixes went into play the pool wasn't growing out of bounds as it was before in some cases, which meant that the Cluster in the test had to wait longer for connections which ultimately led to timeouts. By increasing the number of in-process requests and increasing pool sizes, the test seems to now pass more consistently.


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

Branch: refs/heads/tp31
Commit: e14183c65c5d673b23f10a556de48220b2927bf5
Parents: e66f2c9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 30 19:50:44 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 30 19:50:44 2016 -0400

----------------------------------------------------------------------
 .../gremlin/server/GremlinDriverIntegrateTest.java          | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e14183c6/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 8515e8a..a7cbeee 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -969,7 +969,11 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
 
     @Test
     public void shouldBeThreadSafeToUseOneClient() throws Exception {
-        final Cluster cluster = Cluster.build().create();
+        final Cluster cluster = Cluster.build().workerPoolSize(2)
+                .maxInProcessPerConnection(64)
+                .minInProcessPerConnection(32)
+                .maxConnectionPoolSize(16)
+                .minConnectionPoolSize(8).create();
         final Client client = cluster.connect();
 
         final Map<Integer, Integer> results = new ConcurrentHashMap<>();
@@ -991,8 +995,11 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         threads.forEach(FunctionUtils.wrapConsumer(Thread::join));
 
         for (int ix = 0; ix < results.size(); ix++) {
+            assertThat(results.containsKey(ix), is(true));
             assertEquals(1000 + ix, results.get(ix).intValue());
         }
+
+        cluster.close();
     }
 
     @Test


[12/12] tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-1352' into tp31

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP-1352' into tp31

Conflicts:
	CHANGELOG.asciidoc


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

Branch: refs/heads/tp31
Commit: c8c77afeb63f88d7b153738db2bddba12aeda969
Parents: bb9d718 565b2e8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 8 14:15:01 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 8 14:15:01 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  3 ++
 .../tinkerpop/gremlin/driver/Connection.java    |  5 ++-
 .../gremlin/driver/ConnectionPool.java          | 46 +++++++++-----------
 gremlin-server/conf/gremlin-server-neo4j.yaml   |  2 +-
 .../conf/gremlin-server-rest-secure.yaml        |  2 +-
 gremlin-server/conf/gremlin-server-secure.yaml  |  2 +-
 gremlin-server/conf/gremlin-server-spark.yaml   |  2 +-
 gremlin-server/conf/gremlin-server.yaml         |  2 +-
 .../tinkerpop/gremlin/server/GremlinServer.java |  2 +-
 .../server/op/AbstractEvalOpProcessor.java      | 11 ++++-
 .../gremlin/server/op/session/Session.java      |  4 ++
 .../server/op/session/SessionOpProcessor.java   |  1 -
 .../server/GremlinDriverIntegrateTest.java      |  9 +++-
 .../GremlinServerAuthOldIntegrateTest.java      |  4 +-
 .../GremlinServerSessionIntegrateTest.java      | 17 +++++---
 .../server/gremlin-server-integration.yaml      |  2 +-
 .../server/gremlin-server-performance.yaml      |  2 +-
 17 files changed, 70 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c8c77afe/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 881dbb3,7cf46f8..3499304
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,19 -26,15 +26,22 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* Enured calls to `Result.hasNext()` were idempotent.
  * Avoid hamcrest conflict by using mockito-core instead of mockito-all dependency in `gremlin-test`.
 +* Fixed bug in `GremlinExecutor` causing Gremlin Server to lock up when parallel requests were submitted on the same session if those parallel requests included a script that blocked indefinitely.
 +* Changed `GremlinExecutor` timeout scheduling so that the timer would not start until a time closer to the actual start of script evaluation.
  * Fixed bug in `SubgraphStrategy` where step labels were not being propogated properly to new steps injected by the strategy.
 +* Fix incorrect test `FeatureRequirement` annotations.
  * Defaulted to `Edge.DEFAULT` if no edge label was supplied in GraphML.
  * Fixed bug in `IoGraphTest` causing IllegalArgumentException: URI is not hierarchical error for external graph implementations.
 +* Fixed bug in `GremlinGroovyScriptEngineFileSandboxTest` resource loading
 +* Improved `TinkerGraph` performance when iterating vertices and edges.
  * Fixed a bug where timeout functions provided to the `GremlinExecutor` were not executing in the same thread as the script evaluation.
+ * Fixed a bug in the driver where many parallel requests over a session would sometimes force a connection to close and replace itself.
  * Optimized a few special cases in `RangeByIsCountStrategy`.
 +* Added more "invalid" variable bindings to the list used by Gremlin Server to validate incoming bindings on requests.
+ * Fixed a bug where the `ConnectionPool` in the driver would not grow with certain configuration options.
+ * Fixed a bug where pauses in Gremlin Server writing to an overtaxed client would generate unexpected `FastNoSuchElementException` errors.
  * Named the thread pool used by Gremlin Server sessions: "gremlin-server-session-$n".
  * Fixed a bug in `BulkSet.equals()` which made itself apparent when using `store()` and `aggregate()` with labeled `cap()`.
  * Fixed a bug where `Result.one()` could potentially block indefinitely under certain circumstances.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c8c77afe/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c8c77afe/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------


[04/12] tinkerpop git commit: Fixed bug in driver where the client would unecessarily replace Connections.

Posted by sp...@apache.org.
Fixed bug in driver where the client would unecessarily replace Connections.

Replacing the Connection was pretty transparent to the user in most cases, but it wasn't a good practice as there was a cost in doing that which was uncessary since the pool size for a session is always 1.


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

Branch: refs/heads/tp31
Commit: 989977f67c42d9ab44db3b055db907cd8ee251b0
Parents: bc397ec
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 30 17:14:57 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 30 17:14:57 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |    1 +
 .../tinkerpop/gremlin/driver/Connection.java    |    5 +-
 .../gremlin/driver/ConnectionPool.java          |    9 +-
 .../gremlin/server/op/session/Session.java      |    4 +
 .../server/op/session/SessionOpProcessor.java   |    1 -
 .../server/GremlinDriverIntegrateTest.java      | 2070 +++++++++---------
 .../GremlinServerSessionIntegrateTest.java      |   17 +-
 7 files changed, 1058 insertions(+), 1049 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index f2d4153..7cf46f8 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -31,6 +31,7 @@ TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
 * Defaulted to `Edge.DEFAULT` if no edge label was supplied in GraphML.
 * Fixed bug in `IoGraphTest` causing IllegalArgumentException: URI is not hierarchical error for external graph implementations.
 * Fixed a bug where timeout functions provided to the `GremlinExecutor` were not executing in the same thread as the script evaluation.
+* Fixed a bug in the driver where many parallel requests over a session would sometimes force a connection to close and replace itself.
 * Optimized a few special cases in `RangeByIsCountStrategy`.
 * Fixed a bug where the `ConnectionPool` in the driver would not grow with certain configuration options.
 * Fixed a bug where pauses in Gremlin Server writing to an overtaxed client would generate unexpected `FastNoSuchElementException` errors.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/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 cecfbc5..22e48fe 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
@@ -19,7 +19,6 @@
 package org.apache.tinkerpop.gremlin.driver;
 
 import io.netty.handler.codec.CodecException;
-import io.netty.handler.codec.CorruptedFrameException;
 import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import io.netty.bootstrap.Bootstrap;
@@ -120,7 +119,9 @@ final class Connection {
      * the maximum number of in-process requests less the number of pending responses.
      */
     public int availableInProcess() {
-        return maxInProcess - pending.size();
+        // no need for a negative available amount - not sure that the pending size can ever exceed maximum, but
+        // better to avoid the negatives that would ensue if it did
+        return Math.max(0, maxInProcess - pending.size());
     }
 
     public boolean isDead() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index 52c6b6a..e51662e 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -180,8 +180,10 @@ final class ConnectionPool {
 
             // destroy a connection that exceeds the minimum pool size - it does not have the right to live if it
             // isn't busy. replace a connection that has a low available in process count which likely means that
-            // it's backing up with requests that might never have returned. if neither of these scenarios are met
-            // then let the world know the connection is available.
+            // it's backing up with requests that might never have returned. consider the maxPoolSize in this condition
+            // because if it is equal to 1 (which it is for a session) then there is no need to replace the connection
+            // as it will be responsible for every single request. if neither of these scenarios are met then let the
+            // world know the connection is available.
             final int poolSize = connections.size();
             final int availableInProcess = connection.availableInProcess();
             if (poolSize > minPoolSize && borrowed <= minSimultaneousUsagePerConnection) {
@@ -189,7 +191,7 @@ final class ConnectionPool {
                     logger.debug("On {} pool size of {} > minPoolSize {} and borrowed of {} <= minSimultaneousUsagePerConnection {} so destroy {}",
                             host, poolSize, minPoolSize, borrowed, minSimultaneousUsagePerConnection, connection.getConnectionInfo());
                 destroyConnection(connection);
-            } else if (availableInProcess < minInProcess) {
+            } else if (availableInProcess < minInProcess && maxPoolSize > 1) {
                 if (logger.isDebugEnabled())
                     logger.debug("On {} availableInProcess {} < minInProcess {} so replace {}", host, availableInProcess, minInProcess, connection.getConnectionInfo());
                 replaceConnection(connection);
@@ -243,7 +245,6 @@ final class ConnectionPool {
     void replaceConnection(final Connection connection) {
         logger.debug("Replace {}", connection);
 
-        open.decrementAndGet();
         considerNewConnection();
         definitelyDestroyConnection(connection);
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
index 0ed2041..33b2752 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
@@ -100,6 +100,10 @@ public class Session {
         return executor;
     }
 
+    public String getSessionId() {
+        return session;
+    }
+
     public void touch() {
         // if the task of killing is cancelled successfully then reset the session monitor. otherwise this session
         // has already been killed and there's nothing left to do with this session.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
index 451c479..3497169 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/SessionOpProcessor.java
@@ -36,7 +36,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.script.Bindings;
-import javax.script.SimpleBindings;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;


[05/12] tinkerpop git commit: Uncommented some tests that were accidentally commented out.

Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/033a44d1/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index a5bdb2f..8515e8a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -129,843 +129,843 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         return settings;
     }
 
-//    @Test
-//    public void shouldEventuallySucceedAfterChannelLevelError() throws Exception {
-//        final Cluster cluster = Cluster.build().addContactPoint("localhost")
-//                .reconnectIntialDelay(500)
-//                .reconnectInterval(500)
-//                .maxContentLength(1024).create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("def x = '';(0..<1024).each{x = x + '$it'};x").all().get();
-//            fail("Request should have failed because it exceeded the max content length allowed");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root.getMessage(), containsString("Max frame length of 1024 has been exceeded."));
-//        }
-//
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldEventuallySucceedAfterMuchFailure() throws Exception {
-//        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
-//        final Client client = cluster.connect();
-//
-//        // tested independently to 10000 iterations but for speed, bumped back to 1000
-//        IntStream.range(0,1000).forEach(i -> {
-//            try {
-//                client.submit("1 + 9 9").all().join().get(0).getInt();
-//                fail("Should not have gone through due to syntax error");
-//            } catch (Exception ex) {
-//                final Throwable root = ExceptionUtils.getRootCause(ex);
-//                assertThat(root, instanceOf(ResponseException.class));
-//            }
-//        });
-//
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldEventuallySucceedOnSameServer() throws Exception {
-//        stopServer();
-//
-//        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("1+1").all().join().get(0).getInt();
-//            fail("Should not have gone through because the server is not running");
-//        } catch (Exception i) {
-//            final Throwable root = ExceptionUtils.getRootCause(i);
-//            assertThat(root, instanceOf(TimeoutException.class));
-//        }
-//
-//        startServer();
-//
-//        // default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
-//        // back to life
-//        TimeUnit.SECONDS.sleep(3);
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldEventuallySucceedWithRoundRobin() throws Exception {
-//        final String noGremlinServer = "74.125.225.19";
-//        final Cluster cluster = Cluster.build(noGremlinServer).addContactPoint("localhost").create();
-//        final Client client = cluster.connect();
-//
-//        // the first host is dead on init.  request should succeed on localhost
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldHandleResultsOfAllSizes() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final String script = "g.V().drop().iterate();\n" +
-//                "\n" +
-//                "List ids = new ArrayList();\n" +
-//                "\n" +
-//                "int ii = 0;\n" +
-//                "Vertex v = graph.addVertex();\n" +
-//                "v.property(\"ii\", ii);\n" +
-//                "v.property(\"sin\", Math.sin(ii));\n" +
-//                "ids.add(v.id());\n" +
-//                "\n" +
-//                "Random rand = new Random();\n" +
-//                "for (; ii < size; ii++) {\n" +
-//                "    v = graph.addVertex();\n" +
-//                "    v.property(\"ii\", ii);\n" +
-//                "    v.property(\"sin\", Math.sin(ii/5.0));\n" +
-//                "    Vertex u = g.V(ids.get(rand.nextInt(ids.size()))).next();\n" +
-//                "    v.addEdge(\"linked\", u);\n" +
-//                "    ids.add(u.id());\n" +
-//                "    ids.add(v.id());\n" +
-//                "}\n" +
-//                "g.V()";
-//
-//        final List<Integer> sizes = Arrays.asList(1, 10, 20, 50, 75, 100, 250, 500, 750, 1000, 5000, 10000);
-//        for (Integer size : sizes) {
-//            final Map<String, Object> params = new HashMap<>();
-//            params.put("size", size - 1);
-//            final ResultSet results = client.submit(script, params);
-//
-//            assertEquals(size.intValue(), results.all().get().size());
-//        }
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldFailWithBadClientSideSerialization() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("java.awt.Color.RED");
-//
-//        try {
-//            results.all().join();
-//            fail("Should have thrown exception over bad serialization");
-//        } catch (Exception ex) {
-//            final Throwable inner = ExceptionUtils.getRootCause(ex);
-//            assertTrue(inner instanceof RuntimeException);
-//            assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
-//        }
-//
-//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-//        // from time to time, especially in the console if you're just exploring.
-//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldFailWithScriptExecutionException() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("1/0");
-//
-//        try {
-//            results.all().join();
-//            fail("Should have thrown exception over bad serialization");
-//        } catch (Exception ex) {
-//            final Throwable inner = ExceptionUtils.getRootCause(ex);
-//            assertTrue(inner instanceof ResponseException);
-//            assertThat(inner.getMessage(), endsWith("Division by zero"));
-//        }
-//
-//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-//        // from time to time, especially in the console if you're just exploring.
-//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldProcessRequestsOutOfOrder() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
-//        final ResultSet rsZero = client.submit("'zero'");
-//
-//        final CompletableFuture<List<Result>> futureFive = rsFive.all();
-//        final CompletableFuture<List<Result>> futureZero = rsZero.all();
-//
-//        final long start = System.nanoTime();
-//        assertFalse(futureFive.isDone());
-//        assertEquals("zero", futureZero.get().get(0).getString());
-//
-//        logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
-//
-//        assertFalse(futureFive.isDone());
-//        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
-//
-//        logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
-//    }
-//
-//    @Test
-//    public void shouldProcessSessionRequestsInOrder() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
-//        final ResultSet rsZero = client.submit("'zero'");
-//
-//        final CompletableFuture<List<Result>> futureFive = rsFive.all();
-//        final CompletableFuture<List<Result>> futureZero = rsZero.all();
-//
-//        final AtomicBoolean hit = new AtomicBoolean(false);
-//        while (!futureFive.isDone()) {
-//            // futureZero can't finish before futureFive - racy business here?
-//            assertThat(futureZero.isDone(), is(false));
-//            hit.set(true);
-//        }
-//
-//        // should have entered the loop at least once and thus proven that futureZero didn't return ahead of
-//        // futureFive
-//        assertThat(hit.get(), is(true));
-//
-//        assertEquals("zero", futureZero.get().get(0).getString());
-//        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
-//    }
-//
-//    @Test
-//    public void shouldWaitForAllResultsToArrive() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final AtomicInteger checked = new AtomicInteger(0);
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        while (!results.allItemsAvailable()) {
-//            assertTrue(results.getAvailableItemCount() < 10);
-//            checked.incrementAndGet();
-//            Thread.sleep(100);
-//        }
-//
-//        assertTrue(checked.get() > 0);
-//        assertEquals(9, results.getAvailableItemCount());
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldWorkOverNioTransport() throws Exception {
-//        final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
-//        final Client client = cluster.connect();
-//
-//        final AtomicInteger checked = new AtomicInteger(0);
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        while (!results.allItemsAvailable()) {
-//            assertTrue(results.getAvailableItemCount() < 10);
-//            checked.incrementAndGet();
-//            Thread.sleep(100);
-//        }
-//
-//        assertTrue(checked.get() > 0);
-//        assertEquals(9, results.getAvailableItemCount());
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldStream() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        final AtomicInteger counter = new AtomicInteger(0);
-//        results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
-//        assertEquals(9, counter.get());
-//        assertThat(results.allItemsAvailable(), is(true));
-//
-//        // cant stream it again
-//        assertThat(results.stream().iterator().hasNext(), is(false));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldIterate() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        final Iterator<Result> itty = results.iterator();
-//        final AtomicInteger counter = new AtomicInteger(0);
-//        while (itty.hasNext()) {
-//            counter.incrementAndGet();
-//            assertEquals(counter.get(), itty.next().getInt());
-//        }
-//
-//        assertEquals(9, counter.get());
-//        assertThat(results.allItemsAvailable(), is(true));
-//
-//        // can't stream it again
-//        assertThat(results.iterator().hasNext(), is(false));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldGetSomeThenSomeMore() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        final CompletableFuture<List<Result>> batch1 = results.some(5);
-//        final CompletableFuture<List<Result>> batch2 = results.some(5);
-//        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
-//
-//        assertEquals(5, batch1.get().size());
-//        assertEquals(1, batch1.get().get(0).getInt());
-//        assertEquals(2, batch1.get().get(1).getInt());
-//        assertEquals(3, batch1.get().get(2).getInt());
-//        assertEquals(4, batch1.get().get(3).getInt());
-//        assertEquals(5, batch1.get().get(4).getInt());
-//
-//        assertEquals(4, batch2.get().size());
-//        assertEquals(6, batch2.get().get(0).getInt());
-//        assertEquals(7, batch2.get().get(1).getInt());
-//        assertEquals(8, batch2.get().get(2).getInt());
-//        assertEquals(9, batch2.get().get(3).getInt());
-//
-//        assertEquals(0, batchNothingLeft.get().size());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldGetOneThenSomeThenSomeMore() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-//        final Result one = results.one();
-//        final CompletableFuture<List<Result>> batch1 = results.some(4);
-//        final CompletableFuture<List<Result>> batch2 = results.some(5);
-//        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
-//
-//        assertEquals(1, one.getInt());
-//
-//        assertEquals(4, batch1.get().size());
-//        assertEquals(2, batch1.get().get(0).getInt());
-//        assertEquals(3, batch1.get().get(1).getInt());
-//        assertEquals(4, batch1.get().get(2).getInt());
-//        assertEquals(5, batch1.get().get(3).getInt());
-//
-//        assertEquals(4, batch2.get().size());
-//        assertEquals(6, batch2.get().get(0).getInt());
-//        assertEquals(7, batch2.get().get(1).getInt());
-//        assertEquals(8, batch2.get().get(2).getInt());
-//        assertEquals(9, batch2.get().get(3).getInt());
-//
-//        assertEquals(0, batchNothingLeft.get().size());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAvoidDeadlockOnCallToResultSetDotAll() throws Exception {
-//
-//        // This test arose from this issue: https://github.org/apache/tinkerpop/tinkerpop3/issues/515
-//        //
-//        // ResultSet.all returns a CompletableFuture that blocks on the worker pool until isExhausted returns false.
-//        // isExhausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
-//        // threads on the worker pool waiting for .all to finish such that you can't even get one to wait for
-//        // isExhausted to run.
-//        //
-//        // Note that all() doesn't work as described above anymore.  It waits for callback on readComplete rather
-//        // than blocking on isExhausted.
-//        final int workerPoolSizeForDriver = 2;
-//
-//        // the number of requests 4 times the size of the worker pool as this originally did produce the problem
-//        // described above in the javadoc of the test (though an equivalent number also produced it), but this has
-//        // been tested to much higher multiples and passes.  note that the maxWaitForConnection setting is high so
-//        // that the client doesn't timeout waiting for an available connection. obviously this can also be fixed
-//        // by increasing the maxConnectionPoolSize.
-//        final int requests = workerPoolSizeForDriver * 4;
-//        final Cluster cluster = Cluster.build()
-//                .workerPoolSize(workerPoolSizeForDriver)
-//                .maxWaitForConnection(300000)
-//                .create();
-//        final Client client = cluster.connect();
-//
-//        final CountDownLatch latch = new CountDownLatch(requests);
-//        final AtomicReference[] refs = new AtomicReference[requests];
-//        IntStream.range(0, requests).forEach(ix -> {
-//            refs[ix] = new AtomicReference();
-//            client.submitAsync("Thread.sleep(5000);[1,2,3,4,5,6,7,8,9]").thenAccept(rs ->
-//                    rs.all().thenAccept(refs[ix]::set).thenRun(latch::countDown));
-//        });
-//
-//        // countdown should have reached zero as results should have eventually been all returned and processed
-//        assertTrue(latch.await(20, TimeUnit.SECONDS));
-//
-//        final List<Integer> expected = IntStream.range(1, 10).boxed().collect(Collectors.toList());
-//        IntStream.range(0, requests).forEach(r ->
-//                assertTrue(expected.containsAll(((List<Result>) refs[r].get()).stream().map(resultItem -> new Integer(resultItem.getInt())).collect(Collectors.toList()))));
-//    }
-//
-//    @Test
-//    public void shouldCloseWithServerDown() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        cluster.connect().init();
-//
-//        stopServer();
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldMarkHostDeadSinceServerIsDown() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        assertEquals(0, cluster.availableHosts().size());
-//        cluster.connect().init();
-//        assertEquals(1, cluster.availableHosts().size());
-//
-//        stopServer();
-//
-//        cluster.connect().init();
-//        assertEquals(0, cluster.availableHosts().size());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldFailWithBadServerSideSerialization() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("TinkerGraph.open().variables()");
-//
-//        try {
-//            results.all().join();
-//            fail();
-//        } catch (Exception ex) {
-//            final Throwable inner = ExceptionUtils.getRootCause(ex);
-//            assertTrue(inner instanceof ResponseException);
-//            assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
-//        }
-//
-//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-//        // from time to time, especially in the console if you're just exploring.
-//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldSerializeToStringWhenRequested() throws Exception {
-//        final Map<String, Object> m = new HashMap<>();
-//        m.put("serializeResultToString", true);
-//        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
-//        serializer.configure(m, null);
-//
-//        final Cluster cluster = Cluster.build().serializer(serializer).create();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
-//        final List<Result> results = resultSet.all().join();
-//        assertEquals(1, results.size());
-//        assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldDeserializeWithCustomClasses() throws Exception {
-//        final Map<String, Object> m = new HashMap<>();
-//        m.put("custom", Arrays.asList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName())));
-//        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
-//        serializer.configure(m, null);
-//
-//        final Cluster cluster = Cluster.build().serializer(serializer).create();
-//        final Client client = cluster.connect();
-//
-//        final List<Result> json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join();
-//        assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString());
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldWorkWithGraphSONSerialization() throws Exception {
-//        final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRAPHSON_V1D0).create();
-//        final Client client = cluster.connect();
-//
-//        final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
-//        assertEquals(1, r.size());
-//
-//        final Map<String,Object> m = r.get(0).get(Map.class);
-//        assertEquals(4, m.size());
-//        assertEquals(1, m.get("id"));
-//        assertEquals("person", m.get("label"));
-//        assertEquals("vertex", m.get("type"));
-//
-//        final Map<String,Object> properties = (Map<String,Object>) m.get("properties");
-//        assertEquals(2, properties.size());
-//
-//        final List<Object> names = (List<Object>) properties.get("name");
-//        assertEquals(1, names.size());
-//
-//        final Map<String,Object> nameProperties = (Map<String,Object>) names.get(0);
-//        assertEquals(2, nameProperties.size());
-//        assertEquals(0l, nameProperties.get("id"));
-//        assertEquals("marko", nameProperties.get("value"));
-//
-//        final List<Object> ages = (List<Object>) properties.get("age");
-//        assertEquals(1, ages.size());
-//
-//        final Map<String,Object> ageProperties = (Map<String,Object>) ages.get(0);
-//        assertEquals(2, ageProperties.size());
-//        assertEquals(1l, ageProperties.get("id"));
-//        assertEquals(29, ageProperties.get("value"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    @org.junit.Ignore("Can't seem to make this test pass consistently")
-//    public void shouldHandleRequestSentThatNeverReturns() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
-//
-//        stopServer();
-//
-//        // give the server a chance to kill everything
-//        Thread.sleep(1000);
-//
-//        try {
-//            results.all().get(10000, TimeUnit.MILLISECONDS);
-//            fail("Server was stopped before the request could execute");
-//        } catch (TimeoutException toe) {
-//            fail("Should not have tossed a TimeOutException getting the result");
-//        } catch (Exception ex) {
-//            final Throwable cause = ExceptionUtils.getCause(ex);
-//            assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
-//        }
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldFailClientSideWithTooLargeAResponse() {
-//        final Cluster cluster = Cluster.build().maxContentLength(1).create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            final String fatty = IntStream.range(0, 100).mapToObj(String::valueOf).collect(Collectors.joining());
-//            client.submit("'" + fatty + "'").all().get();
-//            fail("Should throw an exception.");
-//        } catch (Exception re) {
-//            final Throwable root = ExceptionUtils.getRootCause(re);
-//            assertTrue(root.getMessage().equals("Max frame length of 1 has been exceeded."));
-//        } finally {
-//            cluster.close();
-//        }
-//    }
-//
-//    @Test
-//    public void shouldReturnNiceMessageFromOpSelector() {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            final Map m = new HashMap<>();
-//            m.put(null, "a null key will force a throw of OpProcessorException in message validation");
-//            client.submit("1+1", m).all().get();
-//            fail("Should throw an exception.");
-//        } catch (Exception re) {
-//            final Throwable root = ExceptionUtils.getRootCause(re);
-//            assertEquals("The [eval] message is using one or more invalid binding keys - they must be of type String and cannot be null", root.getMessage());
-//        } finally {
-//            cluster.close();
-//        }
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptInSession() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
-//        assertEquals(9, results1.all().get().size());
-//
-//        final ResultSet results2 = client.submit("x[0]+1");
-//        assertEquals(2, results2.all().get().get(0).getInt());
-//
-//        final ResultSet results3 = client.submit("x[1]+2");
-//        assertEquals(4, results3.all().get().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldNotThrowNoSuchElementException() throws Exception {
-//        final Cluster cluster = Cluster.open();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            // this should return "nothing" - there should be no exception
-//            assertNull(client.submit("g.V().has('name','kadfjaldjfla')").one());
-//        } finally {
-//            cluster.close();
-//        }
-//    }
-//
-//    @Test
-//    public void shouldCloseSession() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
-//        assertEquals(9, results1.all().get().size());
-//        final ResultSet results2 = client.submit("x[0]+1");
-//        assertEquals(2, results2.all().get().get(0).getInt());
-//
-//        client.close();
-//
-//        try {
-//            client.submit("x[0]+1");
-//            fail("Should have thrown an exception because the connection is closed");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ConnectionException.class));
-//        }
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptInSessionAssumingDefaultedImports() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final ResultSet results1 = client.submit("TinkerFactory.class.name");
-//        assertEquals(TinkerFactory.class.getName(), results1.all().get().get(0).getString());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptInSessionOnTransactionalGraph() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexBeforeTx.values("name").next());
-//
-//        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexFromV.values("name").next());
-//
-//        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexFromBinding.values("name").next());
-//
-//        final Vertex vertexAfterTx = client.submit("v.property(\"color\",\"blue\"); graph.tx().commit(); v").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexAfterTx.values("name").next());
-//        assertEquals("blue", vertexAfterTx.values("color").next());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//        final Client sessionlessClient = cluster.connect();
-//        client.submit("graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);null").all().get();
-//        client.submit("graph.tx().open()").all().get();
-//
-//        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexBeforeTx.values("name").next());
-//
-//        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexFromV.values("name").next());
-//
-//        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexFromBinding.values("name").next());
-//
-//        client.submit("v.property(\"color\",\"blue\")").all().get();
-//        client.submit("graph.tx().commit()").all().get();
-//
-//        // Run a sessionless request to change transaction.readWriteConsumer back to AUTO
-//        // The will make the next in session request fail if consumers aren't ThreadLocal
-//        sessionlessClient.submit("graph.vertices().next()").all().get();
-//
-//        client.submit("graph.tx().open()").all().get();
-//
-//        final Vertex vertexAfterTx = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexAfterTx.values("name").next());
-//        assertEquals("blue", vertexAfterTx.values("color").next());
-//
-//        client.submit("graph.tx().rollback()").all().get();
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client sessionClient = cluster.connect(name.getMethodName());
-//        final Client sessionlessClient = cluster.connect();
-//
-//        //open transaction in session, then add vertex and commit
-//        sessionClient.submit("graph.tx().open()").all().get();
-//        final Vertex vertexBeforeTx = sessionClient.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexBeforeTx.values("name").next());
-//        sessionClient.submit("graph.tx().commit()").all().get();
-//
-//        // check that session transaction is closed
-//        final boolean isOpen = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
-//        assertTrue("Transaction should be closed", !isOpen);
-//
-//        //run a sessionless read
-//        sessionlessClient.submit("graph.traversal().V()").all().get();
-//
-//        // check that session transaction is still closed
-//        final boolean isOpenAfterSessionless = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
-//        assertTrue("Transaction should stil be closed", !isOpenAfterSessionless);
-//
-//    }
-//
-//    @Test
-//    public void shouldExecuteSessionlessScriptOnTransactionalGraph() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        // this line is important because it tests GraphTraversal which has a certain transactional path
-//        final Vertex vertexRequest1 = client.submit("g.addV(\"name\",\"stephen\")").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexRequest1.values("name").next());
-//
-//        final Vertex vertexRequest2 = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-//        assertEquals("stephen", vertexRequest2.values("name").next());
-//
-//        // this line is important because it tests the other transactional path
-//        final Vertex vertexRequest3 = client.submit("graph.addVertex(\"name\",\"marko\")").all().get().get(0).getVertex();
-//        assertEquals("marko", vertexRequest3.values("name").next());
-//
-//        assertEquals(2, client.submit("g.V().count()").all().get().get(0).getLong());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptInSessionWithBindingsSavedOnServerBetweenRequests() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        final Map<String, Object> bindings1 = new HashMap<>();
-//        bindings1.put("a", 100);
-//        bindings1.put("b", 200);
-//        final ResultSet results1 = client.submit("x = a + b", bindings1);
-//        assertEquals(300, results1.one().getInt());
-//
-//        final Map<String, Object> bindings2 = new HashMap<>();
-//        bindings2.put("b", 100);
-//        final ResultSet results2 = client.submit("x + b + a", bindings2);
-//        assertEquals(500, results2.one().getInt());
-//
-//        final Map<String, Object> bindings3 = new HashMap<>();
-//        bindings3.put("x", 100);
-//        final ResultSet results3 = client.submit("x + b + a + 1", bindings3);
-//        assertEquals(301, results3.one().getInt());
-//
-//        final Map<String, Object> bindings4 = new HashMap<>();
-//        final ResultSet results4 = client.submit("x + b + a + 1", bindings4);
-//        assertEquals(301, results4.one().getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldExecuteScriptsInMultipleSession() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client1 = cluster.connect(name.getMethodName() + "1");
-//        final Client client2 = cluster.connect(name.getMethodName() + "2");
-//        final Client client3 = cluster.connect(name.getMethodName() + "3");
-//
-//        final ResultSet results11 = client1.submit("x = 1");
-//        final ResultSet results21 = client2.submit("x = 2");
-//        final ResultSet results31 = client3.submit("x = 3");
-//        assertEquals(1, results11.all().get().get(0).getInt());
-//        assertEquals(2, results21.all().get().get(0).getInt());
-//        assertEquals(3, results31.all().get().get(0).getInt());
-//
-//        final ResultSet results12 = client1.submit("x + 100");
-//        final ResultSet results22 = client2.submit("x * 2");
-//        final ResultSet results32 = client3.submit("x * 10");
-//        assertEquals(101, results12.all().get().get(0).getInt());
-//        assertEquals(4, results22.all().get().get(0).getInt());
-//        assertEquals(30, results32.all().get().get(0).getInt());
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldNotHaveKnowledgeOfBindingsBetweenRequestsWhenSessionless() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client1 = cluster.connect();
-//        final Client client2 = cluster.connect();
-//        final Client client3 = cluster.connect();
-//
-//        final ResultSet results11 = client1.submit("x = 1");
-//        final ResultSet results21 = client2.submit("x = 2");
-//        final ResultSet results31 = client3.submit("x = 3");
-//        assertEquals(1, results11.all().get().get(0).getInt());
-//        assertEquals(2, results21.all().get().get(0).getInt());
-//        assertEquals(3, results31.all().get().get(0).getInt());
-//
-//        try {
-//            client1.submit("x").all().get();
-//            fail("The variable 'x' should not be present on the new request.");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-//            assertThat(root.getMessage(), containsString("No such property: x for class"));
-//        }
-//
-//        try {
-//            client2.submit("x").all().get();
-//            fail("The variable 'x' should not be present on the new request.");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-//            assertThat(root.getMessage(), containsString("No such property: x for class"));
-//        }
-//
-//        try {
-//            client3.submit("x").all().get();
-//            fail("The variable 'x' should not be present on the new request.");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-//            assertThat(root.getMessage(), containsString("No such property: x for class"));
-//        }
-//
-//        cluster.close();
-//    }
+    @Test
+    public void shouldEventuallySucceedAfterChannelLevelError() throws Exception {
+        final Cluster cluster = Cluster.build().addContactPoint("localhost")
+                .reconnectIntialDelay(500)
+                .reconnectInterval(500)
+                .maxContentLength(1024).create();
+        final Client client = cluster.connect();
+
+        try {
+            client.submit("def x = '';(0..<1024).each{x = x + '$it'};x").all().get();
+            fail("Request should have failed because it exceeded the max content length allowed");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root.getMessage(), containsString("Max frame length of 1024 has been exceeded."));
+        }
+
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldEventuallySucceedAfterMuchFailure() throws Exception {
+        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
+        final Client client = cluster.connect();
+
+        // tested independently to 10000 iterations but for speed, bumped back to 1000
+        IntStream.range(0,1000).forEach(i -> {
+            try {
+                client.submit("1 + 9 9").all().join().get(0).getInt();
+                fail("Should not have gone through due to syntax error");
+            } catch (Exception ex) {
+                final Throwable root = ExceptionUtils.getRootCause(ex);
+                assertThat(root, instanceOf(ResponseException.class));
+            }
+        });
+
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldEventuallySucceedOnSameServer() throws Exception {
+        stopServer();
+
+        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
+        final Client client = cluster.connect();
+
+        try {
+            client.submit("1+1").all().join().get(0).getInt();
+            fail("Should not have gone through because the server is not running");
+        } catch (Exception i) {
+            final Throwable root = ExceptionUtils.getRootCause(i);
+            assertThat(root, instanceOf(TimeoutException.class));
+        }
+
+        startServer();
+
+        // default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
+        // back to life
+        TimeUnit.SECONDS.sleep(3);
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldEventuallySucceedWithRoundRobin() throws Exception {
+        final String noGremlinServer = "74.125.225.19";
+        final Cluster cluster = Cluster.build(noGremlinServer).addContactPoint("localhost").create();
+        final Client client = cluster.connect();
+
+        // the first host is dead on init.  request should succeed on localhost
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldHandleResultsOfAllSizes() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final String script = "g.V().drop().iterate();\n" +
+                "\n" +
+                "List ids = new ArrayList();\n" +
+                "\n" +
+                "int ii = 0;\n" +
+                "Vertex v = graph.addVertex();\n" +
+                "v.property(\"ii\", ii);\n" +
+                "v.property(\"sin\", Math.sin(ii));\n" +
+                "ids.add(v.id());\n" +
+                "\n" +
+                "Random rand = new Random();\n" +
+                "for (; ii < size; ii++) {\n" +
+                "    v = graph.addVertex();\n" +
+                "    v.property(\"ii\", ii);\n" +
+                "    v.property(\"sin\", Math.sin(ii/5.0));\n" +
+                "    Vertex u = g.V(ids.get(rand.nextInt(ids.size()))).next();\n" +
+                "    v.addEdge(\"linked\", u);\n" +
+                "    ids.add(u.id());\n" +
+                "    ids.add(v.id());\n" +
+                "}\n" +
+                "g.V()";
+
+        final List<Integer> sizes = Arrays.asList(1, 10, 20, 50, 75, 100, 250, 500, 750, 1000, 5000, 10000);
+        for (Integer size : sizes) {
+            final Map<String, Object> params = new HashMap<>();
+            params.put("size", size - 1);
+            final ResultSet results = client.submit(script, params);
+
+            assertEquals(size.intValue(), results.all().get().size());
+        }
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldFailWithBadClientSideSerialization() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("java.awt.Color.RED");
+
+        try {
+            results.all().join();
+            fail("Should have thrown exception over bad serialization");
+        } catch (Exception ex) {
+            final Throwable inner = ExceptionUtils.getRootCause(ex);
+            assertTrue(inner instanceof RuntimeException);
+            assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
+        }
+
+        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+        // from time to time, especially in the console if you're just exploring.
+        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldFailWithScriptExecutionException() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("1/0");
+
+        try {
+            results.all().join();
+            fail("Should have thrown exception over bad serialization");
+        } catch (Exception ex) {
+            final Throwable inner = ExceptionUtils.getRootCause(ex);
+            assertTrue(inner instanceof ResponseException);
+            assertThat(inner.getMessage(), endsWith("Division by zero"));
+        }
+
+        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+        // from time to time, especially in the console if you're just exploring.
+        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldProcessRequestsOutOfOrder() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
+        final ResultSet rsZero = client.submit("'zero'");
+
+        final CompletableFuture<List<Result>> futureFive = rsFive.all();
+        final CompletableFuture<List<Result>> futureZero = rsZero.all();
+
+        final long start = System.nanoTime();
+        assertFalse(futureFive.isDone());
+        assertEquals("zero", futureZero.get().get(0).getString());
+
+        logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
+
+        assertFalse(futureFive.isDone());
+        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
+
+        logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
+    }
+
+    @Test
+    public void shouldProcessSessionRequestsInOrder() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
+        final ResultSet rsZero = client.submit("'zero'");
+
+        final CompletableFuture<List<Result>> futureFive = rsFive.all();
+        final CompletableFuture<List<Result>> futureZero = rsZero.all();
+
+        final AtomicBoolean hit = new AtomicBoolean(false);
+        while (!futureFive.isDone()) {
+            // futureZero can't finish before futureFive - racy business here?
+            assertThat(futureZero.isDone(), is(false));
+            hit.set(true);
+        }
+
+        // should have entered the loop at least once and thus proven that futureZero didn't return ahead of
+        // futureFive
+        assertThat(hit.get(), is(true));
+
+        assertEquals("zero", futureZero.get().get(0).getString());
+        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
+    }
+
+    @Test
+    public void shouldWaitForAllResultsToArrive() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final AtomicInteger checked = new AtomicInteger(0);
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        while (!results.allItemsAvailable()) {
+            assertTrue(results.getAvailableItemCount() < 10);
+            checked.incrementAndGet();
+            Thread.sleep(100);
+        }
+
+        assertTrue(checked.get() > 0);
+        assertEquals(9, results.getAvailableItemCount());
+        cluster.close();
+    }
+
+    @Test
+    public void shouldWorkOverNioTransport() throws Exception {
+        final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
+        final Client client = cluster.connect();
+
+        final AtomicInteger checked = new AtomicInteger(0);
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        while (!results.allItemsAvailable()) {
+            assertTrue(results.getAvailableItemCount() < 10);
+            checked.incrementAndGet();
+            Thread.sleep(100);
+        }
+
+        assertTrue(checked.get() > 0);
+        assertEquals(9, results.getAvailableItemCount());
+        cluster.close();
+    }
+
+    @Test
+    public void shouldStream() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final AtomicInteger counter = new AtomicInteger(0);
+        results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+        assertEquals(9, counter.get());
+        assertThat(results.allItemsAvailable(), is(true));
+
+        // cant stream it again
+        assertThat(results.stream().iterator().hasNext(), is(false));
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldIterate() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final Iterator<Result> itty = results.iterator();
+        final AtomicInteger counter = new AtomicInteger(0);
+        while (itty.hasNext()) {
+            counter.incrementAndGet();
+            assertEquals(counter.get(), itty.next().getInt());
+        }
+
+        assertEquals(9, counter.get());
+        assertThat(results.allItemsAvailable(), is(true));
+
+        // can't stream it again
+        assertThat(results.iterator().hasNext(), is(false));
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldGetSomeThenSomeMore() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final CompletableFuture<List<Result>> batch1 = results.some(5);
+        final CompletableFuture<List<Result>> batch2 = results.some(5);
+        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+
+        assertEquals(5, batch1.get().size());
+        assertEquals(1, batch1.get().get(0).getInt());
+        assertEquals(2, batch1.get().get(1).getInt());
+        assertEquals(3, batch1.get().get(2).getInt());
+        assertEquals(4, batch1.get().get(3).getInt());
+        assertEquals(5, batch1.get().get(4).getInt());
+
+        assertEquals(4, batch2.get().size());
+        assertEquals(6, batch2.get().get(0).getInt());
+        assertEquals(7, batch2.get().get(1).getInt());
+        assertEquals(8, batch2.get().get(2).getInt());
+        assertEquals(9, batch2.get().get(3).getInt());
+
+        assertEquals(0, batchNothingLeft.get().size());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldGetOneThenSomeThenSomeMore() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final Result one = results.one();
+        final CompletableFuture<List<Result>> batch1 = results.some(4);
+        final CompletableFuture<List<Result>> batch2 = results.some(5);
+        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+
+        assertEquals(1, one.getInt());
+
+        assertEquals(4, batch1.get().size());
+        assertEquals(2, batch1.get().get(0).getInt());
+        assertEquals(3, batch1.get().get(1).getInt());
+        assertEquals(4, batch1.get().get(2).getInt());
+        assertEquals(5, batch1.get().get(3).getInt());
+
+        assertEquals(4, batch2.get().size());
+        assertEquals(6, batch2.get().get(0).getInt());
+        assertEquals(7, batch2.get().get(1).getInt());
+        assertEquals(8, batch2.get().get(2).getInt());
+        assertEquals(9, batch2.get().get(3).getInt());
+
+        assertEquals(0, batchNothingLeft.get().size());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldAvoidDeadlockOnCallToResultSetDotAll() throws Exception {
+
+        // This test arose from this issue: https://github.org/apache/tinkerpop/tinkerpop3/issues/515
+        //
+        // ResultSet.all returns a CompletableFuture that blocks on the worker pool until isExhausted returns false.
+        // isExhausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
+        // threads on the worker pool waiting for .all to finish such that you can't even get one to wait for
+        // isExhausted to run.
+        //
+        // Note that all() doesn't work as described above anymore.  It waits for callback on readComplete rather
+        // than blocking on isExhausted.
+        final int workerPoolSizeForDriver = 2;
+
+        // the number of requests 4 times the size of the worker pool as this originally did produce the problem
+        // described above in the javadoc of the test (though an equivalent number also produced it), but this has
+        // been tested to much higher multiples and passes.  note that the maxWaitForConnection setting is high so
+        // that the client doesn't timeout waiting for an available connection. obviously this can also be fixed
+        // by increasing the maxConnectionPoolSize.
+        final int requests = workerPoolSizeForDriver * 4;
+        final Cluster cluster = Cluster.build()
+                .workerPoolSize(workerPoolSizeForDriver)
+                .maxWaitForConnection(300000)
+                .create();
+        final Client client = cluster.connect();
+
+        final CountDownLatch latch = new CountDownLatch(requests);
+        final AtomicReference[] refs = new AtomicReference[requests];
+        IntStream.range(0, requests).forEach(ix -> {
+            refs[ix] = new AtomicReference();
+            client.submitAsync("Thread.sleep(5000);[1,2,3,4,5,6,7,8,9]").thenAccept(rs ->
+                    rs.all().thenAccept(refs[ix]::set).thenRun(latch::countDown));
+        });
+
+        // countdown should have reached zero as results should have eventually been all returned and processed
+        assertTrue(latch.await(20, TimeUnit.SECONDS));
+
+        final List<Integer> expected = IntStream.range(1, 10).boxed().collect(Collectors.toList());
+        IntStream.range(0, requests).forEach(r ->
+                assertTrue(expected.containsAll(((List<Result>) refs[r].get()).stream().map(resultItem -> new Integer(resultItem.getInt())).collect(Collectors.toList()))));
+    }
+
+    @Test
+    public void shouldCloseWithServerDown() throws Exception {
+        final Cluster cluster = Cluster.open();
+        cluster.connect().init();
+
+        stopServer();
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldMarkHostDeadSinceServerIsDown() throws Exception {
+        final Cluster cluster = Cluster.open();
+        assertEquals(0, cluster.availableHosts().size());
+        cluster.connect().init();
+        assertEquals(1, cluster.availableHosts().size());
+
+        stopServer();
+
+        cluster.connect().init();
+        assertEquals(0, cluster.availableHosts().size());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldFailWithBadServerSideSerialization() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("TinkerGraph.open().variables()");
+
+        try {
+            results.all().join();
+            fail();
+        } catch (Exception ex) {
+            final Throwable inner = ExceptionUtils.getRootCause(ex);
+            assertTrue(inner instanceof ResponseException);
+            assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
+        }
+
+        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+        // from time to time, especially in the console if you're just exploring.
+        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldSerializeToStringWhenRequested() throws Exception {
+        final Map<String, Object> m = new HashMap<>();
+        m.put("serializeResultToString", true);
+        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
+        serializer.configure(m, null);
+
+        final Cluster cluster = Cluster.build().serializer(serializer).create();
+        final Client client = cluster.connect();
+
+        final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
+        final List<Result> results = resultSet.all().join();
+        assertEquals(1, results.size());
+        assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldDeserializeWithCustomClasses() throws Exception {
+        final Map<String, Object> m = new HashMap<>();
+        m.put("custom", Arrays.asList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName())));
+        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
+        serializer.configure(m, null);
+
+        final Cluster cluster = Cluster.build().serializer(serializer).create();
+        final Client client = cluster.connect();
+
+        final List<Result> json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join();
+        assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString());
+        cluster.close();
+    }
+
+    @Test
+    public void shouldWorkWithGraphSONSerialization() throws Exception {
+        final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRAPHSON_V1D0).create();
+        final Client client = cluster.connect();
+
+        final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
+        assertEquals(1, r.size());
+
+        final Map<String,Object> m = r.get(0).get(Map.class);
+        assertEquals(4, m.size());
+        assertEquals(1, m.get("id"));
+        assertEquals("person", m.get("label"));
+        assertEquals("vertex", m.get("type"));
+
+        final Map<String,Object> properties = (Map<String,Object>) m.get("properties");
+        assertEquals(2, properties.size());
+
+        final List<Object> names = (List<Object>) properties.get("name");
+        assertEquals(1, names.size());
+
+        final Map<String,Object> nameProperties = (Map<String,Object>) names.get(0);
+        assertEquals(2, nameProperties.size());
+        assertEquals(0l, nameProperties.get("id"));
+        assertEquals("marko", nameProperties.get("value"));
+
+        final List<Object> ages = (List<Object>) properties.get("age");
+        assertEquals(1, ages.size());
+
+        final Map<String,Object> ageProperties = (Map<String,Object>) ages.get(0);
+        assertEquals(2, ageProperties.size());
+        assertEquals(1l, ageProperties.get("id"));
+        assertEquals(29, ageProperties.get("value"));
+
+        cluster.close();
+    }
+
+    @Test
+    @org.junit.Ignore("Can't seem to make this test pass consistently")
+    public void shouldHandleRequestSentThatNeverReturns() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
+
+        stopServer();
+
+        // give the server a chance to kill everything
+        Thread.sleep(1000);
+
+        try {
+            results.all().get(10000, TimeUnit.MILLISECONDS);
+            fail("Server was stopped before the request could execute");
+        } catch (TimeoutException toe) {
+            fail("Should not have tossed a TimeOutException getting the result");
+        } catch (Exception ex) {
+            final Throwable cause = ExceptionUtils.getCause(ex);
+            assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
+        }
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldFailClientSideWithTooLargeAResponse() {
+        final Cluster cluster = Cluster.build().maxContentLength(1).create();
+        final Client client = cluster.connect();
+
+        try {
+            final String fatty = IntStream.range(0, 100).mapToObj(String::valueOf).collect(Collectors.joining());
+            client.submit("'" + fatty + "'").all().get();
+            fail("Should throw an exception.");
+        } catch (Exception re) {
+            final Throwable root = ExceptionUtils.getRootCause(re);
+            assertTrue(root.getMessage().equals("Max frame length of 1 has been exceeded."));
+        } finally {
+            cluster.close();
+        }
+    }
+
+    @Test
+    public void shouldReturnNiceMessageFromOpSelector() {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect();
+
+        try {
+            final Map m = new HashMap<>();
+            m.put(null, "a null key will force a throw of OpProcessorException in message validation");
+            client.submit("1+1", m).all().get();
+            fail("Should throw an exception.");
+        } catch (Exception re) {
+            final Throwable root = ExceptionUtils.getRootCause(re);
+            assertEquals("The [eval] message is using one or more invalid binding keys - they must be of type String and cannot be null", root.getMessage());
+        } finally {
+            cluster.close();
+        }
+    }
+
+    @Test
+    public void shouldExecuteScriptInSession() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
+        assertEquals(9, results1.all().get().size());
+
+        final ResultSet results2 = client.submit("x[0]+1");
+        assertEquals(2, results2.all().get().get(0).getInt());
+
+        final ResultSet results3 = client.submit("x[1]+2");
+        assertEquals(4, results3.all().get().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldNotThrowNoSuchElementException() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        try {
+            // this should return "nothing" - there should be no exception
+            assertNull(client.submit("g.V().has('name','kadfjaldjfla')").one());
+        } finally {
+            cluster.close();
+        }
+    }
+
+    @Test
+    public void shouldCloseSession() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
+        assertEquals(9, results1.all().get().size());
+        final ResultSet results2 = client.submit("x[0]+1");
+        assertEquals(2, results2.all().get().get(0).getInt());
+
+        client.close();
+
+        try {
+            client.submit("x[0]+1");
+            fail("Should have thrown an exception because the connection is closed");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(ConnectionException.class));
+        }
+    }
+
+    @Test
+    public void shouldExecuteScriptInSessionAssumingDefaultedImports() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final ResultSet results1 = client.submit("TinkerFactory.class.name");
+        assertEquals(TinkerFactory.class.getName(), results1.all().get().get(0).getString());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldExecuteScriptInSessionOnTransactionalGraph() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexBeforeTx.values("name").next());
+
+        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexFromV.values("name").next());
+
+        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexFromBinding.values("name").next());
+
+        final Vertex vertexAfterTx = client.submit("v.property(\"color\",\"blue\"); graph.tx().commit(); v").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexAfterTx.values("name").next());
+        assertEquals("blue", vertexAfterTx.values("color").next());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+        final Client sessionlessClient = cluster.connect();
+        client.submit("graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);null").all().get();
+        client.submit("graph.tx().open()").all().get();
+
+        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexBeforeTx.values("name").next());
+
+        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexFromV.values("name").next());
+
+        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexFromBinding.values("name").next());
+
+        client.submit("v.property(\"color\",\"blue\")").all().get();
+        client.submit("graph.tx().commit()").all().get();
+
+        // Run a sessionless request to change transaction.readWriteConsumer back to AUTO
+        // The will make the next in session request fail if consumers aren't ThreadLocal
+        sessionlessClient.submit("graph.vertices().next()").all().get();
+
+        client.submit("graph.tx().open()").all().get();
+
+        final Vertex vertexAfterTx = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexAfterTx.values("name").next());
+        assertEquals("blue", vertexAfterTx.values("color").next());
+
+        client.submit("graph.tx().rollback()").all().get();
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final Cluster cluster = Cluster.build().create();
+        final Client sessionClient = cluster.connect(name.getMethodName());
+        final Client sessionlessClient = cluster.connect();
+
+        //open transaction in session, then add vertex and commit
+        sessionClient.submit("graph.tx().open()").all().get();
+        final Vertex vertexBeforeTx = sessionClient.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexBeforeTx.values("name").next());
+        sessionClient.submit("graph.tx().commit()").all().get();
+
+        // check that session transaction is closed
+        final boolean isOpen = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
+        assertTrue("Transaction should be closed", !isOpen);
+
+        //run a sessionless read
+        sessionlessClient.submit("graph.traversal().V()").all().get();
+
+        // check that session transaction is still closed
+        final boolean isOpenAfterSessionless = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
+        assertTrue("Transaction should stil be closed", !isOpenAfterSessionless);
+
+    }
+
+    @Test
+    public void shouldExecuteSessionlessScriptOnTransactionalGraph() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect();
+
+        // this line is important because it tests GraphTraversal which has a certain transactional path
+        final Vertex vertexRequest1 = client.submit("g.addV(\"name\",\"stephen\")").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexRequest1.values("name").next());
+
+        final Vertex vertexRequest2 = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+        assertEquals("stephen", vertexRequest2.values("name").next());
+
+        // this line is important because it tests the other transactional path
+        final Vertex vertexRequest3 = client.submit("graph.addVertex(\"name\",\"marko\")").all().get().get(0).getVertex();
+        assertEquals("marko", vertexRequest3.values("name").next());
+
+        assertEquals(2, client.submit("g.V().count()").all().get().get(0).getLong());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldExecuteScriptInSessionWithBindingsSavedOnServerBetweenRequests() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect(name.getMethodName());
+
+        final Map<String, Object> bindings1 = new HashMap<>();
+        bindings1.put("a", 100);
+        bindings1.put("b", 200);
+        final ResultSet results1 = client.submit("x = a + b", bindings1);
+        assertEquals(300, results1.one().getInt());
+
+        final Map<String, Object> bindings2 = new HashMap<>();
+        bindings2.put("b", 100);
+        final ResultSet results2 = client.submit("x + b + a", bindings2);
+        assertEquals(500, results2.one().getInt());
+
+        final Map<String, Object> bindings3 = new HashMap<>();
+        bindings3.put("x", 100);
+        final ResultSet results3 = client.submit("x + b + a + 1", bindings3);
+        assertEquals(301, results3.one().getInt());
+
+        final Map<String, Object> bindings4 = new HashMap<>();
+        final ResultSet results4 = client.submit("x + b + a + 1", bindings4);
+        assertEquals(301, results4.one().getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldExecuteScriptsInMultipleSession() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client1 = cluster.connect(name.getMethodName() + "1");
+        final Client client2 = cluster.connect(name.getMethodName() + "2");
+        final Client client3 = cluster.connect(name.getMethodName() + "3");
+
+        final ResultSet results11 = client1.submit("x = 1");
+        final ResultSet results21 = client2.submit("x = 2");
+        final ResultSet results31 = client3.submit("x = 3");
+        assertEquals(1, results11.all().get().get(0).getInt());
+        assertEquals(2, results21.all().get().get(0).getInt());
+        assertEquals(3, results31.all().get().get(0).getInt());
+
+        final ResultSet results12 = client1.submit("x + 100");
+        final ResultSet results22 = client2.submit("x * 2");
+        final ResultSet results32 = client3.submit("x * 10");
+        assertEquals(101, results12.all().get().get(0).getInt());
+        assertEquals(4, results22.all().get().get(0).getInt());
+        assertEquals(30, results32.all().get().get(0).getInt());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldNotHaveKnowledgeOfBindingsBetweenRequestsWhenSessionless() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client1 = cluster.connect();
+        final Client client2 = cluster.connect();
+        final Client client3 = cluster.connect();
+
+        final ResultSet results11 = client1.submit("x = 1");
+        final ResultSet results21 = client2.submit("x = 2");
+        final ResultSet results31 = client3.submit("x = 3");
+        assertEquals(1, results11.all().get().get(0).getInt());
+        assertEquals(2, results21.all().get().get(0).getInt());
+        assertEquals(3, results31.all().get().get(0).getInt());
+
+        try {
+            client1.submit("x").all().get();
+            fail("The variable 'x' should not be present on the new request.");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+            assertThat(root.getMessage(), containsString("No such property: x for class"));
+        }
+
+        try {
+            client2.submit("x").all().get();
+            fail("The variable 'x' should not be present on the new request.");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+            assertThat(root.getMessage(), containsString("No such property: x for class"));
+        }
+
+        try {
+            client3.submit("x").all().get();
+            fail("The variable 'x' should not be present on the new request.");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+            assertThat(root.getMessage(), containsString("No such property: x for class"));
+        }
+
+        cluster.close();
+    }
 
     @Test
     public void shouldBeThreadSafeToUseOneClient() throws Exception {
@@ -995,202 +995,202 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         }
     }
 
-//    @Test
-//    public void shouldRequireAliasedGraphVariablesInStrictTransactionMode() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("1+1").all().get();
-//            fail("Should have tossed an exception because strict mode is on and no aliasing was performed");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
-//        }
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAliasGraphVariablesInStrictTransactionMode() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-//            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
-//        }
-//
-//        // keep the testing here until "rebind" is completely removed
-//        final Client reboundLegacy = cluster.connect().rebind("graph");
-//        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-//        assertEquals("stephen", vLegacy.value("name"));
-//
-//        final Client rebound = cluster.connect().alias("graph");
-//        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-//        assertEquals("jason", v.value("name"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAliasGraphVariables() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-//            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
-//        }
-//
-//        // keep the testing here until "rebind" is completely removed
-//        final Client reboundLegacy = cluster.connect().rebind("graph");
-//        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-//        assertEquals("stephen", vLegacy.value("name"));
-//
-//        final Client rebound = cluster.connect().alias("graph");
-//        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-//        assertEquals("jason", v.value("name"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAliasTraversalSourceVariables() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//
-//        try {
-//            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-//            fail("Should have tossed an exception because \"g\" is readonly in this context");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
-//        }
-//
-//        // keep the testing here until "rebind" is completely removed
-//        final Client clientLegacy = client.rebind("g1");
-//        final Vertex vLegacy = clientLegacy.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-//        assertEquals("stephen", vLegacy.value("name"));
-//
-//        final Client clientAliased = client.alias("g1");
-//        final Vertex v = clientAliased.submit("g.addV('name','jason')").all().get().get(0).getVertex();
-//        assertEquals("jason", v.value("name"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAliasGraphVariablesInSession() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        try {
-//            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-//            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
-//        }
-//
-//        // keep the testing here until "rebind" is completely removed
-//        final Client reboundLegacy = client.rebind("graph");
-//        assertEquals("stephen", reboundLegacy.submit("n='stephen'").all().get().get(0).getString());
-//        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name',n)").all().get().get(0).getVertex();
-//        assertEquals("stephen", vLegacy.value("name"));
-//
-//        final Client aliased = client.alias("graph");
-//        assertEquals("jason", reboundLegacy.submit("n='jason'").all().get().get(0).getString());
-//        final Vertex v = aliased.submit("g.addVertex('name',n)").all().get().get(0).getVertex();
-//        assertEquals("jason", v.value("name"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldAliasTraversalSourceVariablesInSession() throws Exception {
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect(name.getMethodName());
-//
-//        try {
-//            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-//            fail("Should have tossed an exception because \"g\" is readonly in this context");
-//        } catch (Exception ex) {
-//            final Throwable root = ExceptionUtils.getRootCause(ex);
-//            assertThat(root, instanceOf(ResponseException.class));
-//            final ResponseException re = (ResponseException) root;
-//            assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
-//        }
-//
-//        // keep the testing here until "rebind" is completely removed
-//        final Client clientLegacy = client.rebind("g1");
-//        assertEquals("stephen", clientLegacy.submit("n='stephen'").all().get().get(0).getString());
-//        final Vertex vLegacy = clientLegacy.submit("g.addV('name',n)").all().get().get(0).getVertex();
-//        assertEquals("stephen", vLegacy.value("name"));
-//
-//        final Client clientAliased = client.alias("g1");
-//        assertEquals("jason", clientAliased.submit("n='jason'").all().get().get(0).getString());
-//        final Vertex v = clientAliased.submit("g.addV('name',n)").all().get().get(0).getVertex();
-//        assertEquals("jason", v.value("name"));
-//
-//        cluster.close();
-//    }
-//
-//    @Test
-//    public void shouldManageTransactionsInSession() throws Exception {
-//        assumeNeo4jIsPresent();
-//
-//        final Cluster cluster = Cluster.build().create();
-//        final Client client = cluster.connect();
-//        final Client sessionWithManagedTx = cluster.connect(name.getMethodName() + "-managed", true);
-//        final Client sessionWithoutManagedTx = cluster.connect(name.getMethodName() + "-not-managed");
-//
-//        // this should auto-commit
-//        final Vertex vStephen = sessionWithManagedTx.submit("v = g.addV('name','stephen').next()").all().get().get(0).getVertex();
-//        assertEquals("stephen", vStephen.value("name"));
-//
-//        // the other clients should see that change because of auto-commit
-//        assertThat(client.submit("g.V().has('name','stephen').hasNext()").all().get().get(0).getBoolean(), is(true));
-//        assertThat(sessionWithoutManagedTx.submit("g.V().has('name','stephen').hasNext()").all().get().get(0).getBoolean(), is(true));
-//
-//        // this should NOT auto-commit
-//        final Vertex vDaniel = sessionWithoutManagedTx.submit("v = g.addV('name','daniel').next()").all().get().get(0).getVertex();
-//        assertEquals("daniel", vDaniel.value("name"));
-//
-//        // the other clients should NOT see that change because of auto-commit
-//        assertThat(client.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(false));
-//        assertThat(sessionWithManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(false));
-//
-//        // but "v" should still be there
-//        final Vertex vDanielAgain = sessionWithoutManagedTx.submit("v").all().get().get(0).getVertex();
-//        assertEquals("daniel", vDanielAgain.value("name"));
-//
-//        // now commit manually
-//        sessionWithoutManagedTx.submit("g.tx().commit()").all().get();
-//
-//        // should be there for all now
-//        assertThat(client.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-//        assertThat(sessionWithManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-//        assertThat(sessionWithoutManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-//
-//        cluster.close();
-//    }
+    @Test
+    public void shouldRequireAliasedGraphVariablesInStrictTransactionMode() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect();
+
+        try {
+            client.submit("1+1").all().get();
+            fail("Should have tossed an exception because strict mode is on and no aliasing was performed");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(ResponseException.class));
+            final ResponseException re = (ResponseException) root;
+            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
+        }
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldAliasGraphVariablesInStrictTransactionMode() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect();
+
+        try {
+            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
+            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(ResponseException.class));
+            final ResponseException re = (ResponseException) root;
+            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
+        }
+
+        // keep the testing here until "rebind" is completely removed
+        final Client reboundLegacy = cluster.connect().rebind("graph");
+        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client rebound = cluster.connect().alias("graph");
+        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldAliasGraphVariables() throws Exception {
+        final Cluster cluster = Cluster.build().create();
+        final Client client = cluster.connect();
+
+        try {
+            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
+            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(ResponseException.class));
+            final ResponseException re = (ResponseException) root;
+            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
+        }
+
+        // keep the testing here until "rebind" is completely removed
+        final Client reboundLegacy = cluster.connect().rebind("graph");
+        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+        assertEquals("stephen", vLegacy.value("name"));
+
+        final Client rebound = cluster.connect().alias("graph");
+        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+        assertEquals("jason", v.value("name"));
+
+        cluster.close();
+ 

<TRUNCATED>

[07/12] tinkerpop git commit: Prevents connections from exceeding max size in the driver.

Posted by sp...@apache.org.
Prevents connections from exceeding max size in the driver.

A fix for TINKERPOP-1351 - see that issue for more details.


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

Branch: refs/heads/tp31
Commit: e66f2c98374e0ad53a38395091d72fb0e745f752
Parents: 033a44d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 30 17:39:28 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 30 17:39:28 2016 -0400

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/driver/ConnectionPool.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e66f2c98/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index e51662e..96cb81b 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -120,8 +120,12 @@ final class ConnectionPool {
         if (connections.isEmpty()) {
             logger.debug("Tried to borrow connection but the pool was empty for {} - scheduling pool creation and waiting for connection", host);
             for (int i = 0; i < minPoolSize; i++) {
-                scheduledForCreation.incrementAndGet();
-                newConnection();
+                // If many connections are borrowed at the same time there needs to be a check to make sure no
+                // additional ones get scheduled for creation
+                if (scheduledForCreation.get() < minPoolSize) {
+                    scheduledForCreation.incrementAndGet();
+                    newConnection();
+                }
             }
 
             return waitForConnection(timeout, unit);


[11/12] tinkerpop git commit: Removed assert that isn't consistent across kerberos configurations.

Posted by sp...@apache.org.
Removed assert that isn't consistent across kerberos configurations.


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

Branch: refs/heads/tp31
Commit: 565b2e847e59a20e565f618a52be2058859bbb06
Parents: f198ce1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 4 10:16:17 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 4 10:16:17 2016 -0400

----------------------------------------------------------------------
 .../gremlin/server/GremlinServerAuthOldIntegrateTest.java        | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/565b2e84/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthOldIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthOldIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthOldIntegrateTest.java
index 8f39c5e..f2e5622 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthOldIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthOldIntegrateTest.java
@@ -132,7 +132,9 @@ public class GremlinServerAuthOldIntegrateTest extends AbstractGremlinServerInte
         } catch(Exception ex) {
             final Throwable root = ExceptionUtils.getRootCause(ex);
             assertEquals(GSSException.class, root.getClass());
-            assertThat(root.getMessage(), startsWith("Invalid name provided"));
+
+            // removed this assert as the text of the message changes based on kerberos config - stupid kerberos
+            // assertThat(root.getMessage(), startsWith("Invalid name provided"));
         } finally {
             cluster.close();
         }


[03/12] tinkerpop git commit: Fixed bug in driver where the client would unecessarily replace Connections.

Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 8515e8a..a5bdb2f 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -129,843 +129,843 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         return settings;
     }
 
-    @Test
-    public void shouldEventuallySucceedAfterChannelLevelError() throws Exception {
-        final Cluster cluster = Cluster.build().addContactPoint("localhost")
-                .reconnectIntialDelay(500)
-                .reconnectInterval(500)
-                .maxContentLength(1024).create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("def x = '';(0..<1024).each{x = x + '$it'};x").all().get();
-            fail("Request should have failed because it exceeded the max content length allowed");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root.getMessage(), containsString("Max frame length of 1024 has been exceeded."));
-        }
-
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldEventuallySucceedAfterMuchFailure() throws Exception {
-        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
-        final Client client = cluster.connect();
-
-        // tested independently to 10000 iterations but for speed, bumped back to 1000
-        IntStream.range(0,1000).forEach(i -> {
-            try {
-                client.submit("1 + 9 9").all().join().get(0).getInt();
-                fail("Should not have gone through due to syntax error");
-            } catch (Exception ex) {
-                final Throwable root = ExceptionUtils.getRootCause(ex);
-                assertThat(root, instanceOf(ResponseException.class));
-            }
-        });
-
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldEventuallySucceedOnSameServer() throws Exception {
-        stopServer();
-
-        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("1+1").all().join().get(0).getInt();
-            fail("Should not have gone through because the server is not running");
-        } catch (Exception i) {
-            final Throwable root = ExceptionUtils.getRootCause(i);
-            assertThat(root, instanceOf(TimeoutException.class));
-        }
-
-        startServer();
-
-        // default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
-        // back to life
-        TimeUnit.SECONDS.sleep(3);
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldEventuallySucceedWithRoundRobin() throws Exception {
-        final String noGremlinServer = "74.125.225.19";
-        final Cluster cluster = Cluster.build(noGremlinServer).addContactPoint("localhost").create();
-        final Client client = cluster.connect();
-
-        // the first host is dead on init.  request should succeed on localhost
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldHandleResultsOfAllSizes() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final String script = "g.V().drop().iterate();\n" +
-                "\n" +
-                "List ids = new ArrayList();\n" +
-                "\n" +
-                "int ii = 0;\n" +
-                "Vertex v = graph.addVertex();\n" +
-                "v.property(\"ii\", ii);\n" +
-                "v.property(\"sin\", Math.sin(ii));\n" +
-                "ids.add(v.id());\n" +
-                "\n" +
-                "Random rand = new Random();\n" +
-                "for (; ii < size; ii++) {\n" +
-                "    v = graph.addVertex();\n" +
-                "    v.property(\"ii\", ii);\n" +
-                "    v.property(\"sin\", Math.sin(ii/5.0));\n" +
-                "    Vertex u = g.V(ids.get(rand.nextInt(ids.size()))).next();\n" +
-                "    v.addEdge(\"linked\", u);\n" +
-                "    ids.add(u.id());\n" +
-                "    ids.add(v.id());\n" +
-                "}\n" +
-                "g.V()";
-
-        final List<Integer> sizes = Arrays.asList(1, 10, 20, 50, 75, 100, 250, 500, 750, 1000, 5000, 10000);
-        for (Integer size : sizes) {
-            final Map<String, Object> params = new HashMap<>();
-            params.put("size", size - 1);
-            final ResultSet results = client.submit(script, params);
-
-            assertEquals(size.intValue(), results.all().get().size());
-        }
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldFailWithBadClientSideSerialization() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("java.awt.Color.RED");
-
-        try {
-            results.all().join();
-            fail("Should have thrown exception over bad serialization");
-        } catch (Exception ex) {
-            final Throwable inner = ExceptionUtils.getRootCause(ex);
-            assertTrue(inner instanceof RuntimeException);
-            assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
-        }
-
-        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-        // from time to time, especially in the console if you're just exploring.
-        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldFailWithScriptExecutionException() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("1/0");
-
-        try {
-            results.all().join();
-            fail("Should have thrown exception over bad serialization");
-        } catch (Exception ex) {
-            final Throwable inner = ExceptionUtils.getRootCause(ex);
-            assertTrue(inner instanceof ResponseException);
-            assertThat(inner.getMessage(), endsWith("Division by zero"));
-        }
-
-        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-        // from time to time, especially in the console if you're just exploring.
-        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldProcessRequestsOutOfOrder() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
-        final ResultSet rsZero = client.submit("'zero'");
-
-        final CompletableFuture<List<Result>> futureFive = rsFive.all();
-        final CompletableFuture<List<Result>> futureZero = rsZero.all();
-
-        final long start = System.nanoTime();
-        assertFalse(futureFive.isDone());
-        assertEquals("zero", futureZero.get().get(0).getString());
-
-        logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
-
-        assertFalse(futureFive.isDone());
-        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
-
-        logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
-    }
-
-    @Test
-    public void shouldProcessSessionRequestsInOrder() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
-        final ResultSet rsZero = client.submit("'zero'");
-
-        final CompletableFuture<List<Result>> futureFive = rsFive.all();
-        final CompletableFuture<List<Result>> futureZero = rsZero.all();
-
-        final AtomicBoolean hit = new AtomicBoolean(false);
-        while (!futureFive.isDone()) {
-            // futureZero can't finish before futureFive - racy business here?
-            assertThat(futureZero.isDone(), is(false));
-            hit.set(true);
-        }
-
-        // should have entered the loop at least once and thus proven that futureZero didn't return ahead of
-        // futureFive
-        assertThat(hit.get(), is(true));
-
-        assertEquals("zero", futureZero.get().get(0).getString());
-        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
-    }
-
-    @Test
-    public void shouldWaitForAllResultsToArrive() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final AtomicInteger checked = new AtomicInteger(0);
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        while (!results.allItemsAvailable()) {
-            assertTrue(results.getAvailableItemCount() < 10);
-            checked.incrementAndGet();
-            Thread.sleep(100);
-        }
-
-        assertTrue(checked.get() > 0);
-        assertEquals(9, results.getAvailableItemCount());
-        cluster.close();
-    }
-
-    @Test
-    public void shouldWorkOverNioTransport() throws Exception {
-        final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
-        final Client client = cluster.connect();
-
-        final AtomicInteger checked = new AtomicInteger(0);
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        while (!results.allItemsAvailable()) {
-            assertTrue(results.getAvailableItemCount() < 10);
-            checked.incrementAndGet();
-            Thread.sleep(100);
-        }
-
-        assertTrue(checked.get() > 0);
-        assertEquals(9, results.getAvailableItemCount());
-        cluster.close();
-    }
-
-    @Test
-    public void shouldStream() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        final AtomicInteger counter = new AtomicInteger(0);
-        results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
-        assertEquals(9, counter.get());
-        assertThat(results.allItemsAvailable(), is(true));
-
-        // cant stream it again
-        assertThat(results.stream().iterator().hasNext(), is(false));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldIterate() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        final Iterator<Result> itty = results.iterator();
-        final AtomicInteger counter = new AtomicInteger(0);
-        while (itty.hasNext()) {
-            counter.incrementAndGet();
-            assertEquals(counter.get(), itty.next().getInt());
-        }
-
-        assertEquals(9, counter.get());
-        assertThat(results.allItemsAvailable(), is(true));
-
-        // can't stream it again
-        assertThat(results.iterator().hasNext(), is(false));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldGetSomeThenSomeMore() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        final CompletableFuture<List<Result>> batch1 = results.some(5);
-        final CompletableFuture<List<Result>> batch2 = results.some(5);
-        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
-
-        assertEquals(5, batch1.get().size());
-        assertEquals(1, batch1.get().get(0).getInt());
-        assertEquals(2, batch1.get().get(1).getInt());
-        assertEquals(3, batch1.get().get(2).getInt());
-        assertEquals(4, batch1.get().get(3).getInt());
-        assertEquals(5, batch1.get().get(4).getInt());
-
-        assertEquals(4, batch2.get().size());
-        assertEquals(6, batch2.get().get(0).getInt());
-        assertEquals(7, batch2.get().get(1).getInt());
-        assertEquals(8, batch2.get().get(2).getInt());
-        assertEquals(9, batch2.get().get(3).getInt());
-
-        assertEquals(0, batchNothingLeft.get().size());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldGetOneThenSomeThenSomeMore() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
-        final Result one = results.one();
-        final CompletableFuture<List<Result>> batch1 = results.some(4);
-        final CompletableFuture<List<Result>> batch2 = results.some(5);
-        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
-
-        assertEquals(1, one.getInt());
-
-        assertEquals(4, batch1.get().size());
-        assertEquals(2, batch1.get().get(0).getInt());
-        assertEquals(3, batch1.get().get(1).getInt());
-        assertEquals(4, batch1.get().get(2).getInt());
-        assertEquals(5, batch1.get().get(3).getInt());
-
-        assertEquals(4, batch2.get().size());
-        assertEquals(6, batch2.get().get(0).getInt());
-        assertEquals(7, batch2.get().get(1).getInt());
-        assertEquals(8, batch2.get().get(2).getInt());
-        assertEquals(9, batch2.get().get(3).getInt());
-
-        assertEquals(0, batchNothingLeft.get().size());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAvoidDeadlockOnCallToResultSetDotAll() throws Exception {
-
-        // This test arose from this issue: https://github.org/apache/tinkerpop/tinkerpop3/issues/515
-        //
-        // ResultSet.all returns a CompletableFuture that blocks on the worker pool until isExhausted returns false.
-        // isExhausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
-        // threads on the worker pool waiting for .all to finish such that you can't even get one to wait for
-        // isExhausted to run.
-        //
-        // Note that all() doesn't work as described above anymore.  It waits for callback on readComplete rather
-        // than blocking on isExhausted.
-        final int workerPoolSizeForDriver = 2;
-
-        // the number of requests 4 times the size of the worker pool as this originally did produce the problem
-        // described above in the javadoc of the test (though an equivalent number also produced it), but this has
-        // been tested to much higher multiples and passes.  note that the maxWaitForConnection setting is high so
-        // that the client doesn't timeout waiting for an available connection. obviously this can also be fixed
-        // by increasing the maxConnectionPoolSize.
-        final int requests = workerPoolSizeForDriver * 4;
-        final Cluster cluster = Cluster.build()
-                .workerPoolSize(workerPoolSizeForDriver)
-                .maxWaitForConnection(300000)
-                .create();
-        final Client client = cluster.connect();
-
-        final CountDownLatch latch = new CountDownLatch(requests);
-        final AtomicReference[] refs = new AtomicReference[requests];
-        IntStream.range(0, requests).forEach(ix -> {
-            refs[ix] = new AtomicReference();
-            client.submitAsync("Thread.sleep(5000);[1,2,3,4,5,6,7,8,9]").thenAccept(rs ->
-                    rs.all().thenAccept(refs[ix]::set).thenRun(latch::countDown));
-        });
-
-        // countdown should have reached zero as results should have eventually been all returned and processed
-        assertTrue(latch.await(20, TimeUnit.SECONDS));
-
-        final List<Integer> expected = IntStream.range(1, 10).boxed().collect(Collectors.toList());
-        IntStream.range(0, requests).forEach(r ->
-                assertTrue(expected.containsAll(((List<Result>) refs[r].get()).stream().map(resultItem -> new Integer(resultItem.getInt())).collect(Collectors.toList()))));
-    }
-
-    @Test
-    public void shouldCloseWithServerDown() throws Exception {
-        final Cluster cluster = Cluster.open();
-        cluster.connect().init();
-
-        stopServer();
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldMarkHostDeadSinceServerIsDown() throws Exception {
-        final Cluster cluster = Cluster.open();
-        assertEquals(0, cluster.availableHosts().size());
-        cluster.connect().init();
-        assertEquals(1, cluster.availableHosts().size());
-
-        stopServer();
-
-        cluster.connect().init();
-        assertEquals(0, cluster.availableHosts().size());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldFailWithBadServerSideSerialization() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("TinkerGraph.open().variables()");
-
-        try {
-            results.all().join();
-            fail();
-        } catch (Exception ex) {
-            final Throwable inner = ExceptionUtils.getRootCause(ex);
-            assertTrue(inner instanceof ResponseException);
-            assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
-        }
-
-        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
-        // from time to time, especially in the console if you're just exploring.
-        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldSerializeToStringWhenRequested() throws Exception {
-        final Map<String, Object> m = new HashMap<>();
-        m.put("serializeResultToString", true);
-        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
-        serializer.configure(m, null);
-
-        final Cluster cluster = Cluster.build().serializer(serializer).create();
-        final Client client = cluster.connect();
-
-        final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
-        final List<Result> results = resultSet.all().join();
-        assertEquals(1, results.size());
-        assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldDeserializeWithCustomClasses() throws Exception {
-        final Map<String, Object> m = new HashMap<>();
-        m.put("custom", Arrays.asList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName())));
-        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
-        serializer.configure(m, null);
-
-        final Cluster cluster = Cluster.build().serializer(serializer).create();
-        final Client client = cluster.connect();
-
-        final List<Result> json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join();
-        assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString());
-        cluster.close();
-    }
-
-    @Test
-    public void shouldWorkWithGraphSONSerialization() throws Exception {
-        final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRAPHSON_V1D0).create();
-        final Client client = cluster.connect();
-
-        final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
-        assertEquals(1, r.size());
-
-        final Map<String,Object> m = r.get(0).get(Map.class);
-        assertEquals(4, m.size());
-        assertEquals(1, m.get("id"));
-        assertEquals("person", m.get("label"));
-        assertEquals("vertex", m.get("type"));
-
-        final Map<String,Object> properties = (Map<String,Object>) m.get("properties");
-        assertEquals(2, properties.size());
-
-        final List<Object> names = (List<Object>) properties.get("name");
-        assertEquals(1, names.size());
-
-        final Map<String,Object> nameProperties = (Map<String,Object>) names.get(0);
-        assertEquals(2, nameProperties.size());
-        assertEquals(0l, nameProperties.get("id"));
-        assertEquals("marko", nameProperties.get("value"));
-
-        final List<Object> ages = (List<Object>) properties.get("age");
-        assertEquals(1, ages.size());
-
-        final Map<String,Object> ageProperties = (Map<String,Object>) ages.get(0);
-        assertEquals(2, ageProperties.size());
-        assertEquals(1l, ageProperties.get("id"));
-        assertEquals(29, ageProperties.get("value"));
-
-        cluster.close();
-    }
-
-    @Test
-    @org.junit.Ignore("Can't seem to make this test pass consistently")
-    public void shouldHandleRequestSentThatNeverReturns() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
-
-        stopServer();
-
-        // give the server a chance to kill everything
-        Thread.sleep(1000);
-
-        try {
-            results.all().get(10000, TimeUnit.MILLISECONDS);
-            fail("Server was stopped before the request could execute");
-        } catch (TimeoutException toe) {
-            fail("Should not have tossed a TimeOutException getting the result");
-        } catch (Exception ex) {
-            final Throwable cause = ExceptionUtils.getCause(ex);
-            assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
-        }
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldFailClientSideWithTooLargeAResponse() {
-        final Cluster cluster = Cluster.build().maxContentLength(1).create();
-        final Client client = cluster.connect();
-
-        try {
-            final String fatty = IntStream.range(0, 100).mapToObj(String::valueOf).collect(Collectors.joining());
-            client.submit("'" + fatty + "'").all().get();
-            fail("Should throw an exception.");
-        } catch (Exception re) {
-            final Throwable root = ExceptionUtils.getRootCause(re);
-            assertTrue(root.getMessage().equals("Max frame length of 1 has been exceeded."));
-        } finally {
-            cluster.close();
-        }
-    }
-
-    @Test
-    public void shouldReturnNiceMessageFromOpSelector() {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        try {
-            final Map m = new HashMap<>();
-            m.put(null, "a null key will force a throw of OpProcessorException in message validation");
-            client.submit("1+1", m).all().get();
-            fail("Should throw an exception.");
-        } catch (Exception re) {
-            final Throwable root = ExceptionUtils.getRootCause(re);
-            assertEquals("The [eval] message is using one or more invalid binding keys - they must be of type String and cannot be null", root.getMessage());
-        } finally {
-            cluster.close();
-        }
-    }
-
-    @Test
-    public void shouldExecuteScriptInSession() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
-        assertEquals(9, results1.all().get().size());
-
-        final ResultSet results2 = client.submit("x[0]+1");
-        assertEquals(2, results2.all().get().get(0).getInt());
-
-        final ResultSet results3 = client.submit("x[1]+2");
-        assertEquals(4, results3.all().get().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldNotThrowNoSuchElementException() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect();
-
-        try {
-            // this should return "nothing" - there should be no exception
-            assertNull(client.submit("g.V().has('name','kadfjaldjfla')").one());
-        } finally {
-            cluster.close();
-        }
-    }
-
-    @Test
-    public void shouldCloseSession() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
-        assertEquals(9, results1.all().get().size());
-        final ResultSet results2 = client.submit("x[0]+1");
-        assertEquals(2, results2.all().get().get(0).getInt());
-
-        client.close();
-
-        try {
-            client.submit("x[0]+1");
-            fail("Should have thrown an exception because the connection is closed");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ConnectionException.class));
-        }
-    }
-
-    @Test
-    public void shouldExecuteScriptInSessionAssumingDefaultedImports() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final ResultSet results1 = client.submit("TinkerFactory.class.name");
-        assertEquals(TinkerFactory.class.getName(), results1.all().get().get(0).getString());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldExecuteScriptInSessionOnTransactionalGraph() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexBeforeTx.values("name").next());
-
-        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexFromV.values("name").next());
-
-        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexFromBinding.values("name").next());
-
-        final Vertex vertexAfterTx = client.submit("v.property(\"color\",\"blue\"); graph.tx().commit(); v").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexAfterTx.values("name").next());
-        assertEquals("blue", vertexAfterTx.values("color").next());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-        final Client sessionlessClient = cluster.connect();
-        client.submit("graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);null").all().get();
-        client.submit("graph.tx().open()").all().get();
-
-        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexBeforeTx.values("name").next());
-
-        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexFromV.values("name").next());
-
-        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexFromBinding.values("name").next());
-
-        client.submit("v.property(\"color\",\"blue\")").all().get();
-        client.submit("graph.tx().commit()").all().get();
-
-        // Run a sessionless request to change transaction.readWriteConsumer back to AUTO
-        // The will make the next in session request fail if consumers aren't ThreadLocal
-        sessionlessClient.submit("graph.vertices().next()").all().get();
-
-        client.submit("graph.tx().open()").all().get();
-
-        final Vertex vertexAfterTx = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexAfterTx.values("name").next());
-        assertEquals("blue", vertexAfterTx.values("color").next());
-
-        client.submit("graph.tx().rollback()").all().get();
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client sessionClient = cluster.connect(name.getMethodName());
-        final Client sessionlessClient = cluster.connect();
-
-        //open transaction in session, then add vertex and commit
-        sessionClient.submit("graph.tx().open()").all().get();
-        final Vertex vertexBeforeTx = sessionClient.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexBeforeTx.values("name").next());
-        sessionClient.submit("graph.tx().commit()").all().get();
-
-        // check that session transaction is closed
-        final boolean isOpen = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
-        assertTrue("Transaction should be closed", !isOpen);
-
-        //run a sessionless read
-        sessionlessClient.submit("graph.traversal().V()").all().get();
-
-        // check that session transaction is still closed
-        final boolean isOpenAfterSessionless = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
-        assertTrue("Transaction should stil be closed", !isOpenAfterSessionless);
-
-    }
-
-    @Test
-    public void shouldExecuteSessionlessScriptOnTransactionalGraph() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        // this line is important because it tests GraphTraversal which has a certain transactional path
-        final Vertex vertexRequest1 = client.submit("g.addV(\"name\",\"stephen\")").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexRequest1.values("name").next());
-
-        final Vertex vertexRequest2 = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
-        assertEquals("stephen", vertexRequest2.values("name").next());
-
-        // this line is important because it tests the other transactional path
-        final Vertex vertexRequest3 = client.submit("graph.addVertex(\"name\",\"marko\")").all().get().get(0).getVertex();
-        assertEquals("marko", vertexRequest3.values("name").next());
-
-        assertEquals(2, client.submit("g.V().count()").all().get().get(0).getLong());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldExecuteScriptInSessionWithBindingsSavedOnServerBetweenRequests() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        final Map<String, Object> bindings1 = new HashMap<>();
-        bindings1.put("a", 100);
-        bindings1.put("b", 200);
-        final ResultSet results1 = client.submit("x = a + b", bindings1);
-        assertEquals(300, results1.one().getInt());
-
-        final Map<String, Object> bindings2 = new HashMap<>();
-        bindings2.put("b", 100);
-        final ResultSet results2 = client.submit("x + b + a", bindings2);
-        assertEquals(500, results2.one().getInt());
-
-        final Map<String, Object> bindings3 = new HashMap<>();
-        bindings3.put("x", 100);
-        final ResultSet results3 = client.submit("x + b + a + 1", bindings3);
-        assertEquals(301, results3.one().getInt());
-
-        final Map<String, Object> bindings4 = new HashMap<>();
-        final ResultSet results4 = client.submit("x + b + a + 1", bindings4);
-        assertEquals(301, results4.one().getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldExecuteScriptsInMultipleSession() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client1 = cluster.connect(name.getMethodName() + "1");
-        final Client client2 = cluster.connect(name.getMethodName() + "2");
-        final Client client3 = cluster.connect(name.getMethodName() + "3");
-
-        final ResultSet results11 = client1.submit("x = 1");
-        final ResultSet results21 = client2.submit("x = 2");
-        final ResultSet results31 = client3.submit("x = 3");
-        assertEquals(1, results11.all().get().get(0).getInt());
-        assertEquals(2, results21.all().get().get(0).getInt());
-        assertEquals(3, results31.all().get().get(0).getInt());
-
-        final ResultSet results12 = client1.submit("x + 100");
-        final ResultSet results22 = client2.submit("x * 2");
-        final ResultSet results32 = client3.submit("x * 10");
-        assertEquals(101, results12.all().get().get(0).getInt());
-        assertEquals(4, results22.all().get().get(0).getInt());
-        assertEquals(30, results32.all().get().get(0).getInt());
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldNotHaveKnowledgeOfBindingsBetweenRequestsWhenSessionless() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client1 = cluster.connect();
-        final Client client2 = cluster.connect();
-        final Client client3 = cluster.connect();
-
-        final ResultSet results11 = client1.submit("x = 1");
-        final ResultSet results21 = client2.submit("x = 2");
-        final ResultSet results31 = client3.submit("x = 3");
-        assertEquals(1, results11.all().get().get(0).getInt());
-        assertEquals(2, results21.all().get().get(0).getInt());
-        assertEquals(3, results31.all().get().get(0).getInt());
-
-        try {
-            client1.submit("x").all().get();
-            fail("The variable 'x' should not be present on the new request.");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-            assertThat(root.getMessage(), containsString("No such property: x for class"));
-        }
-
-        try {
-            client2.submit("x").all().get();
-            fail("The variable 'x' should not be present on the new request.");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-            assertThat(root.getMessage(), containsString("No such property: x for class"));
-        }
-
-        try {
-            client3.submit("x").all().get();
-            fail("The variable 'x' should not be present on the new request.");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
-            assertThat(root.getMessage(), containsString("No such property: x for class"));
-        }
-
-        cluster.close();
-    }
+//    @Test
+//    public void shouldEventuallySucceedAfterChannelLevelError() throws Exception {
+//        final Cluster cluster = Cluster.build().addContactPoint("localhost")
+//                .reconnectIntialDelay(500)
+//                .reconnectInterval(500)
+//                .maxContentLength(1024).create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            client.submit("def x = '';(0..<1024).each{x = x + '$it'};x").all().get();
+//            fail("Request should have failed because it exceeded the max content length allowed");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root.getMessage(), containsString("Max frame length of 1024 has been exceeded."));
+//        }
+//
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldEventuallySucceedAfterMuchFailure() throws Exception {
+//        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
+//        final Client client = cluster.connect();
+//
+//        // tested independently to 10000 iterations but for speed, bumped back to 1000
+//        IntStream.range(0,1000).forEach(i -> {
+//            try {
+//                client.submit("1 + 9 9").all().join().get(0).getInt();
+//                fail("Should not have gone through due to syntax error");
+//            } catch (Exception ex) {
+//                final Throwable root = ExceptionUtils.getRootCause(ex);
+//                assertThat(root, instanceOf(ResponseException.class));
+//            }
+//        });
+//
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldEventuallySucceedOnSameServer() throws Exception {
+//        stopServer();
+//
+//        final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            client.submit("1+1").all().join().get(0).getInt();
+//            fail("Should not have gone through because the server is not running");
+//        } catch (Exception i) {
+//            final Throwable root = ExceptionUtils.getRootCause(i);
+//            assertThat(root, instanceOf(TimeoutException.class));
+//        }
+//
+//        startServer();
+//
+//        // default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
+//        // back to life
+//        TimeUnit.SECONDS.sleep(3);
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldEventuallySucceedWithRoundRobin() throws Exception {
+//        final String noGremlinServer = "74.125.225.19";
+//        final Cluster cluster = Cluster.build(noGremlinServer).addContactPoint("localhost").create();
+//        final Client client = cluster.connect();
+//
+//        // the first host is dead on init.  request should succeed on localhost
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//        assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldHandleResultsOfAllSizes() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final String script = "g.V().drop().iterate();\n" +
+//                "\n" +
+//                "List ids = new ArrayList();\n" +
+//                "\n" +
+//                "int ii = 0;\n" +
+//                "Vertex v = graph.addVertex();\n" +
+//                "v.property(\"ii\", ii);\n" +
+//                "v.property(\"sin\", Math.sin(ii));\n" +
+//                "ids.add(v.id());\n" +
+//                "\n" +
+//                "Random rand = new Random();\n" +
+//                "for (; ii < size; ii++) {\n" +
+//                "    v = graph.addVertex();\n" +
+//                "    v.property(\"ii\", ii);\n" +
+//                "    v.property(\"sin\", Math.sin(ii/5.0));\n" +
+//                "    Vertex u = g.V(ids.get(rand.nextInt(ids.size()))).next();\n" +
+//                "    v.addEdge(\"linked\", u);\n" +
+//                "    ids.add(u.id());\n" +
+//                "    ids.add(v.id());\n" +
+//                "}\n" +
+//                "g.V()";
+//
+//        final List<Integer> sizes = Arrays.asList(1, 10, 20, 50, 75, 100, 250, 500, 750, 1000, 5000, 10000);
+//        for (Integer size : sizes) {
+//            final Map<String, Object> params = new HashMap<>();
+//            params.put("size", size - 1);
+//            final ResultSet results = client.submit(script, params);
+//
+//            assertEquals(size.intValue(), results.all().get().size());
+//        }
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldFailWithBadClientSideSerialization() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("java.awt.Color.RED");
+//
+//        try {
+//            results.all().join();
+//            fail("Should have thrown exception over bad serialization");
+//        } catch (Exception ex) {
+//            final Throwable inner = ExceptionUtils.getRootCause(ex);
+//            assertTrue(inner instanceof RuntimeException);
+//            assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
+//        }
+//
+//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+//        // from time to time, especially in the console if you're just exploring.
+//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldFailWithScriptExecutionException() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("1/0");
+//
+//        try {
+//            results.all().join();
+//            fail("Should have thrown exception over bad serialization");
+//        } catch (Exception ex) {
+//            final Throwable inner = ExceptionUtils.getRootCause(ex);
+//            assertTrue(inner instanceof ResponseException);
+//            assertThat(inner.getMessage(), endsWith("Division by zero"));
+//        }
+//
+//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+//        // from time to time, especially in the console if you're just exploring.
+//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldProcessRequestsOutOfOrder() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
+//        final ResultSet rsZero = client.submit("'zero'");
+//
+//        final CompletableFuture<List<Result>> futureFive = rsFive.all();
+//        final CompletableFuture<List<Result>> futureZero = rsZero.all();
+//
+//        final long start = System.nanoTime();
+//        assertFalse(futureFive.isDone());
+//        assertEquals("zero", futureZero.get().get(0).getString());
+//
+//        logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
+//
+//        assertFalse(futureFive.isDone());
+//        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
+//
+//        logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
+//    }
+//
+//    @Test
+//    public void shouldProcessSessionRequestsInOrder() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
+//        final ResultSet rsZero = client.submit("'zero'");
+//
+//        final CompletableFuture<List<Result>> futureFive = rsFive.all();
+//        final CompletableFuture<List<Result>> futureZero = rsZero.all();
+//
+//        final AtomicBoolean hit = new AtomicBoolean(false);
+//        while (!futureFive.isDone()) {
+//            // futureZero can't finish before futureFive - racy business here?
+//            assertThat(futureZero.isDone(), is(false));
+//            hit.set(true);
+//        }
+//
+//        // should have entered the loop at least once and thus proven that futureZero didn't return ahead of
+//        // futureFive
+//        assertThat(hit.get(), is(true));
+//
+//        assertEquals("zero", futureZero.get().get(0).getString());
+//        assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
+//    }
+//
+//    @Test
+//    public void shouldWaitForAllResultsToArrive() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final AtomicInteger checked = new AtomicInteger(0);
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        while (!results.allItemsAvailable()) {
+//            assertTrue(results.getAvailableItemCount() < 10);
+//            checked.incrementAndGet();
+//            Thread.sleep(100);
+//        }
+//
+//        assertTrue(checked.get() > 0);
+//        assertEquals(9, results.getAvailableItemCount());
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldWorkOverNioTransport() throws Exception {
+//        final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
+//        final Client client = cluster.connect();
+//
+//        final AtomicInteger checked = new AtomicInteger(0);
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        while (!results.allItemsAvailable()) {
+//            assertTrue(results.getAvailableItemCount() < 10);
+//            checked.incrementAndGet();
+//            Thread.sleep(100);
+//        }
+//
+//        assertTrue(checked.get() > 0);
+//        assertEquals(9, results.getAvailableItemCount());
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldStream() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        final AtomicInteger counter = new AtomicInteger(0);
+//        results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+//        assertEquals(9, counter.get());
+//        assertThat(results.allItemsAvailable(), is(true));
+//
+//        // cant stream it again
+//        assertThat(results.stream().iterator().hasNext(), is(false));
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldIterate() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        final Iterator<Result> itty = results.iterator();
+//        final AtomicInteger counter = new AtomicInteger(0);
+//        while (itty.hasNext()) {
+//            counter.incrementAndGet();
+//            assertEquals(counter.get(), itty.next().getInt());
+//        }
+//
+//        assertEquals(9, counter.get());
+//        assertThat(results.allItemsAvailable(), is(true));
+//
+//        // can't stream it again
+//        assertThat(results.iterator().hasNext(), is(false));
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldGetSomeThenSomeMore() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        final CompletableFuture<List<Result>> batch1 = results.some(5);
+//        final CompletableFuture<List<Result>> batch2 = results.some(5);
+//        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+//
+//        assertEquals(5, batch1.get().size());
+//        assertEquals(1, batch1.get().get(0).getInt());
+//        assertEquals(2, batch1.get().get(1).getInt());
+//        assertEquals(3, batch1.get().get(2).getInt());
+//        assertEquals(4, batch1.get().get(3).getInt());
+//        assertEquals(5, batch1.get().get(4).getInt());
+//
+//        assertEquals(4, batch2.get().size());
+//        assertEquals(6, batch2.get().get(0).getInt());
+//        assertEquals(7, batch2.get().get(1).getInt());
+//        assertEquals(8, batch2.get().get(2).getInt());
+//        assertEquals(9, batch2.get().get(3).getInt());
+//
+//        assertEquals(0, batchNothingLeft.get().size());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldGetOneThenSomeThenSomeMore() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+//        final Result one = results.one();
+//        final CompletableFuture<List<Result>> batch1 = results.some(4);
+//        final CompletableFuture<List<Result>> batch2 = results.some(5);
+//        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+//
+//        assertEquals(1, one.getInt());
+//
+//        assertEquals(4, batch1.get().size());
+//        assertEquals(2, batch1.get().get(0).getInt());
+//        assertEquals(3, batch1.get().get(1).getInt());
+//        assertEquals(4, batch1.get().get(2).getInt());
+//        assertEquals(5, batch1.get().get(3).getInt());
+//
+//        assertEquals(4, batch2.get().size());
+//        assertEquals(6, batch2.get().get(0).getInt());
+//        assertEquals(7, batch2.get().get(1).getInt());
+//        assertEquals(8, batch2.get().get(2).getInt());
+//        assertEquals(9, batch2.get().get(3).getInt());
+//
+//        assertEquals(0, batchNothingLeft.get().size());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldAvoidDeadlockOnCallToResultSetDotAll() throws Exception {
+//
+//        // This test arose from this issue: https://github.org/apache/tinkerpop/tinkerpop3/issues/515
+//        //
+//        // ResultSet.all returns a CompletableFuture that blocks on the worker pool until isExhausted returns false.
+//        // isExhausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
+//        // threads on the worker pool waiting for .all to finish such that you can't even get one to wait for
+//        // isExhausted to run.
+//        //
+//        // Note that all() doesn't work as described above anymore.  It waits for callback on readComplete rather
+//        // than blocking on isExhausted.
+//        final int workerPoolSizeForDriver = 2;
+//
+//        // the number of requests 4 times the size of the worker pool as this originally did produce the problem
+//        // described above in the javadoc of the test (though an equivalent number also produced it), but this has
+//        // been tested to much higher multiples and passes.  note that the maxWaitForConnection setting is high so
+//        // that the client doesn't timeout waiting for an available connection. obviously this can also be fixed
+//        // by increasing the maxConnectionPoolSize.
+//        final int requests = workerPoolSizeForDriver * 4;
+//        final Cluster cluster = Cluster.build()
+//                .workerPoolSize(workerPoolSizeForDriver)
+//                .maxWaitForConnection(300000)
+//                .create();
+//        final Client client = cluster.connect();
+//
+//        final CountDownLatch latch = new CountDownLatch(requests);
+//        final AtomicReference[] refs = new AtomicReference[requests];
+//        IntStream.range(0, requests).forEach(ix -> {
+//            refs[ix] = new AtomicReference();
+//            client.submitAsync("Thread.sleep(5000);[1,2,3,4,5,6,7,8,9]").thenAccept(rs ->
+//                    rs.all().thenAccept(refs[ix]::set).thenRun(latch::countDown));
+//        });
+//
+//        // countdown should have reached zero as results should have eventually been all returned and processed
+//        assertTrue(latch.await(20, TimeUnit.SECONDS));
+//
+//        final List<Integer> expected = IntStream.range(1, 10).boxed().collect(Collectors.toList());
+//        IntStream.range(0, requests).forEach(r ->
+//                assertTrue(expected.containsAll(((List<Result>) refs[r].get()).stream().map(resultItem -> new Integer(resultItem.getInt())).collect(Collectors.toList()))));
+//    }
+//
+//    @Test
+//    public void shouldCloseWithServerDown() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        cluster.connect().init();
+//
+//        stopServer();
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldMarkHostDeadSinceServerIsDown() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        assertEquals(0, cluster.availableHosts().size());
+//        cluster.connect().init();
+//        assertEquals(1, cluster.availableHosts().size());
+//
+//        stopServer();
+//
+//        cluster.connect().init();
+//        assertEquals(0, cluster.availableHosts().size());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldFailWithBadServerSideSerialization() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("TinkerGraph.open().variables()");
+//
+//        try {
+//            results.all().join();
+//            fail();
+//        } catch (Exception ex) {
+//            final Throwable inner = ExceptionUtils.getRootCause(ex);
+//            assertTrue(inner instanceof ResponseException);
+//            assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
+//        }
+//
+//        // should not die completely just because we had a bad serialization error.  that kind of stuff happens
+//        // from time to time, especially in the console if you're just exploring.
+//        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldSerializeToStringWhenRequested() throws Exception {
+//        final Map<String, Object> m = new HashMap<>();
+//        m.put("serializeResultToString", true);
+//        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
+//        serializer.configure(m, null);
+//
+//        final Cluster cluster = Cluster.build().serializer(serializer).create();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
+//        final List<Result> results = resultSet.all().join();
+//        assertEquals(1, results.size());
+//        assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldDeserializeWithCustomClasses() throws Exception {
+//        final Map<String, Object> m = new HashMap<>();
+//        m.put("custom", Arrays.asList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderGryoSerializer.class.getCanonicalName())));
+//        final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
+//        serializer.configure(m, null);
+//
+//        final Cluster cluster = Cluster.build().serializer(serializer).create();
+//        final Client client = cluster.connect();
+//
+//        final List<Result> json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join();
+//        assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString());
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldWorkWithGraphSONSerialization() throws Exception {
+//        final Cluster cluster = Cluster.build("localhost").serializer(Serializers.GRAPHSON_V1D0).create();
+//        final Client client = cluster.connect();
+//
+//        final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
+//        assertEquals(1, r.size());
+//
+//        final Map<String,Object> m = r.get(0).get(Map.class);
+//        assertEquals(4, m.size());
+//        assertEquals(1, m.get("id"));
+//        assertEquals("person", m.get("label"));
+//        assertEquals("vertex", m.get("type"));
+//
+//        final Map<String,Object> properties = (Map<String,Object>) m.get("properties");
+//        assertEquals(2, properties.size());
+//
+//        final List<Object> names = (List<Object>) properties.get("name");
+//        assertEquals(1, names.size());
+//
+//        final Map<String,Object> nameProperties = (Map<String,Object>) names.get(0);
+//        assertEquals(2, nameProperties.size());
+//        assertEquals(0l, nameProperties.get("id"));
+//        assertEquals("marko", nameProperties.get("value"));
+//
+//        final List<Object> ages = (List<Object>) properties.get("age");
+//        assertEquals(1, ages.size());
+//
+//        final Map<String,Object> ageProperties = (Map<String,Object>) ages.get(0);
+//        assertEquals(2, ageProperties.size());
+//        assertEquals(1l, ageProperties.get("id"));
+//        assertEquals(29, ageProperties.get("value"));
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    @org.junit.Ignore("Can't seem to make this test pass consistently")
+//    public void shouldHandleRequestSentThatNeverReturns() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
+//
+//        stopServer();
+//
+//        // give the server a chance to kill everything
+//        Thread.sleep(1000);
+//
+//        try {
+//            results.all().get(10000, TimeUnit.MILLISECONDS);
+//            fail("Server was stopped before the request could execute");
+//        } catch (TimeoutException toe) {
+//            fail("Should not have tossed a TimeOutException getting the result");
+//        } catch (Exception ex) {
+//            final Throwable cause = ExceptionUtils.getCause(ex);
+//            assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
+//        }
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldFailClientSideWithTooLargeAResponse() {
+//        final Cluster cluster = Cluster.build().maxContentLength(1).create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            final String fatty = IntStream.range(0, 100).mapToObj(String::valueOf).collect(Collectors.joining());
+//            client.submit("'" + fatty + "'").all().get();
+//            fail("Should throw an exception.");
+//        } catch (Exception re) {
+//            final Throwable root = ExceptionUtils.getRootCause(re);
+//            assertTrue(root.getMessage().equals("Max frame length of 1 has been exceeded."));
+//        } finally {
+//            cluster.close();
+//        }
+//    }
+//
+//    @Test
+//    public void shouldReturnNiceMessageFromOpSelector() {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            final Map m = new HashMap<>();
+//            m.put(null, "a null key will force a throw of OpProcessorException in message validation");
+//            client.submit("1+1", m).all().get();
+//            fail("Should throw an exception.");
+//        } catch (Exception re) {
+//            final Throwable root = ExceptionUtils.getRootCause(re);
+//            assertEquals("The [eval] message is using one or more invalid binding keys - they must be of type String and cannot be null", root.getMessage());
+//        } finally {
+//            cluster.close();
+//        }
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptInSession() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
+//        assertEquals(9, results1.all().get().size());
+//
+//        final ResultSet results2 = client.submit("x[0]+1");
+//        assertEquals(2, results2.all().get().get(0).getInt());
+//
+//        final ResultSet results3 = client.submit("x[1]+2");
+//        assertEquals(4, results3.all().get().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldNotThrowNoSuchElementException() throws Exception {
+//        final Cluster cluster = Cluster.open();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            // this should return "nothing" - there should be no exception
+//            assertNull(client.submit("g.V().has('name','kadfjaldjfla')").one());
+//        } finally {
+//            cluster.close();
+//        }
+//    }
+//
+//    @Test
+//    public void shouldCloseSession() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
+//        assertEquals(9, results1.all().get().size());
+//        final ResultSet results2 = client.submit("x[0]+1");
+//        assertEquals(2, results2.all().get().get(0).getInt());
+//
+//        client.close();
+//
+//        try {
+//            client.submit("x[0]+1");
+//            fail("Should have thrown an exception because the connection is closed");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, instanceOf(ConnectionException.class));
+//        }
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptInSessionAssumingDefaultedImports() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final ResultSet results1 = client.submit("TinkerFactory.class.name");
+//        assertEquals(TinkerFactory.class.getName(), results1.all().get().get(0).getString());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptInSessionOnTransactionalGraph() throws Exception {
+//        assumeNeo4jIsPresent();
+//
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexBeforeTx.values("name").next());
+//
+//        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexFromV.values("name").next());
+//
+//        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexFromBinding.values("name").next());
+//
+//        final Vertex vertexAfterTx = client.submit("v.property(\"color\",\"blue\"); graph.tx().commit(); v").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexAfterTx.values("name").next());
+//        assertEquals("blue", vertexAfterTx.values("color").next());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptInSessionOnTransactionalWithManualTransactionsGraph() throws Exception {
+//        assumeNeo4jIsPresent();
+//
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//        final Client sessionlessClient = cluster.connect();
+//        client.submit("graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);null").all().get();
+//        client.submit("graph.tx().open()").all().get();
+//
+//        final Vertex vertexBeforeTx = client.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexBeforeTx.values("name").next());
+//
+//        final Vertex vertexFromV = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexFromV.values("name").next());
+//
+//        final Vertex vertexFromBinding = client.submit("v").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexFromBinding.values("name").next());
+//
+//        client.submit("v.property(\"color\",\"blue\")").all().get();
+//        client.submit("graph.tx().commit()").all().get();
+//
+//        // Run a sessionless request to change transaction.readWriteConsumer back to AUTO
+//        // The will make the next in session request fail if consumers aren't ThreadLocal
+//        sessionlessClient.submit("graph.vertices().next()").all().get();
+//
+//        client.submit("graph.tx().open()").all().get();
+//
+//        final Vertex vertexAfterTx = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexAfterTx.values("name").next());
+//        assertEquals("blue", vertexAfterTx.values("color").next());
+//
+//        client.submit("graph.tx().rollback()").all().get();
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransaction() throws Exception {
+//        assumeNeo4jIsPresent();
+//
+//        final Cluster cluster = Cluster.build().create();
+//        final Client sessionClient = cluster.connect(name.getMethodName());
+//        final Client sessionlessClient = cluster.connect();
+//
+//        //open transaction in session, then add vertex and commit
+//        sessionClient.submit("graph.tx().open()").all().get();
+//        final Vertex vertexBeforeTx = sessionClient.submit("v=graph.addVertex(\"name\",\"stephen\")").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexBeforeTx.values("name").next());
+//        sessionClient.submit("graph.tx().commit()").all().get();
+//
+//        // check that session transaction is closed
+//        final boolean isOpen = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
+//        assertTrue("Transaction should be closed", !isOpen);
+//
+//        //run a sessionless read
+//        sessionlessClient.submit("graph.traversal().V()").all().get();
+//
+//        // check that session transaction is still closed
+//        final boolean isOpenAfterSessionless = sessionClient.submit("graph.tx().isOpen()").all().get().get(0).getBoolean();
+//        assertTrue("Transaction should stil be closed", !isOpenAfterSessionless);
+//
+//    }
+//
+//    @Test
+//    public void shouldExecuteSessionlessScriptOnTransactionalGraph() throws Exception {
+//        assumeNeo4jIsPresent();
+//
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        // this line is important because it tests GraphTraversal which has a certain transactional path
+//        final Vertex vertexRequest1 = client.submit("g.addV(\"name\",\"stephen\")").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexRequest1.values("name").next());
+//
+//        final Vertex vertexRequest2 = client.submit("graph.vertices().next()").all().get().get(0).getVertex();
+//        assertEquals("stephen", vertexRequest2.values("name").next());
+//
+//        // this line is important because it tests the other transactional path
+//        final Vertex vertexRequest3 = client.submit("graph.addVertex(\"name\",\"marko\")").all().get().get(0).getVertex();
+//        assertEquals("marko", vertexRequest3.values("name").next());
+//
+//        assertEquals(2, client.submit("g.V().count()").all().get().get(0).getLong());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptInSessionWithBindingsSavedOnServerBetweenRequests() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect(name.getMethodName());
+//
+//        final Map<String, Object> bindings1 = new HashMap<>();
+//        bindings1.put("a", 100);
+//        bindings1.put("b", 200);
+//        final ResultSet results1 = client.submit("x = a + b", bindings1);
+//        assertEquals(300, results1.one().getInt());
+//
+//        final Map<String, Object> bindings2 = new HashMap<>();
+//        bindings2.put("b", 100);
+//        final ResultSet results2 = client.submit("x + b + a", bindings2);
+//        assertEquals(500, results2.one().getInt());
+//
+//        final Map<String, Object> bindings3 = new HashMap<>();
+//        bindings3.put("x", 100);
+//        final ResultSet results3 = client.submit("x + b + a + 1", bindings3);
+//        assertEquals(301, results3.one().getInt());
+//
+//        final Map<String, Object> bindings4 = new HashMap<>();
+//        final ResultSet results4 = client.submit("x + b + a + 1", bindings4);
+//        assertEquals(301, results4.one().getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldExecuteScriptsInMultipleSession() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client1 = cluster.connect(name.getMethodName() + "1");
+//        final Client client2 = cluster.connect(name.getMethodName() + "2");
+//        final Client client3 = cluster.connect(name.getMethodName() + "3");
+//
+//        final ResultSet results11 = client1.submit("x = 1");
+//        final ResultSet results21 = client2.submit("x = 2");
+//        final ResultSet results31 = client3.submit("x = 3");
+//        assertEquals(1, results11.all().get().get(0).getInt());
+//        assertEquals(2, results21.all().get().get(0).getInt());
+//        assertEquals(3, results31.all().get().get(0).getInt());
+//
+//        final ResultSet results12 = client1.submit("x + 100");
+//        final ResultSet results22 = client2.submit("x * 2");
+//        final ResultSet results32 = client3.submit("x * 10");
+//        assertEquals(101, results12.all().get().get(0).getInt());
+//        assertEquals(4, results22.all().get().get(0).getInt());
+//        assertEquals(30, results32.all().get().get(0).getInt());
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldNotHaveKnowledgeOfBindingsBetweenRequestsWhenSessionless() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client1 = cluster.connect();
+//        final Client client2 = cluster.connect();
+//        final Client client3 = cluster.connect();
+//
+//        final ResultSet results11 = client1.submit("x = 1");
+//        final ResultSet results21 = client2.submit("x = 2");
+//        final ResultSet results31 = client3.submit("x = 3");
+//        assertEquals(1, results11.all().get().get(0).getInt());
+//        assertEquals(2, results21.all().get().get(0).getInt());
+//        assertEquals(3, results31.all().get().get(0).getInt());
+//
+//        try {
+//            client1.submit("x").all().get();
+//            fail("The variable 'x' should not be present on the new request.");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+//            assertThat(root.getMessage(), containsString("No such property: x for class"));
+//        }
+//
+//        try {
+//            client2.submit("x").all().get();
+//            fail("The variable 'x' should not be present on the new request.");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+//            assertThat(root.getMessage(), containsString("No such property: x for class"));
+//        }
+//
+//        try {
+//            client3.submit("x").all().get();
+//            fail("The variable 'x' should not be present on the new request.");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, IsInstanceOf.instanceOf(ResponseException.class));
+//            assertThat(root.getMessage(), containsString("No such property: x for class"));
+//        }
+//
+//        cluster.close();
+//    }
 
     @Test
     public void shouldBeThreadSafeToUseOneClient() throws Exception {
@@ -995,202 +995,202 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         }
     }
 
-    @Test
-    public void shouldRequireAliasedGraphVariablesInStrictTransactionMode() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("1+1").all().get();
-            fail("Should have tossed an exception because strict mode is on and no aliasing was performed");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
-        }
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAliasGraphVariablesInStrictTransactionMode() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
-        }
-
-        // keep the testing here until "rebind" is completely removed
-        final Client reboundLegacy = cluster.connect().rebind("graph");
-        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", vLegacy.value("name"));
-
-        final Client rebound = cluster.connect().alias("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAliasGraphVariables() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
-        }
-
-        // keep the testing here until "rebind" is completely removed
-        final Client reboundLegacy = cluster.connect().rebind("graph");
-        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", vLegacy.value("name"));
-
-        final Client rebound = cluster.connect().alias("graph");
-        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAliasTraversalSourceVariables() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-
-        try {
-            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-            fail("Should have tossed an exception because \"g\" is readonly in this context");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
-        }
-
-        // keep the testing here until "rebind" is completely removed
-        final Client clientLegacy = client.rebind("g1");
-        final Vertex vLegacy = clientLegacy.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-        assertEquals("stephen", vLegacy.value("name"));
-
-        final Client clientAliased = client.alias("g1");
-        final Vertex v = clientAliased.submit("g.addV('name','jason')").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAliasGraphVariablesInSession() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        try {
-            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
-            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
-        }
-
-        // keep the testing here until "rebind" is completely removed
-        final Client reboundLegacy = client.rebind("graph");
-        assertEquals("stephen", reboundLegacy.submit("n='stephen'").all().get().get(0).getString());
-        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name',n)").all().get().get(0).getVertex();
-        assertEquals("stephen", vLegacy.value("name"));
-
-        final Client aliased = client.alias("graph");
-        assertEquals("jason", reboundLegacy.submit("n='jason'").all().get().get(0).getString());
-        final Vertex v = aliased.submit("g.addVertex('name',n)").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldAliasTraversalSourceVariablesInSession() throws Exception {
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect(name.getMethodName());
-
-        try {
-            client.submit("g.addV('name','stephen')").all().get().get(0).getVertex();
-            fail("Should have tossed an exception because \"g\" is readonly in this context");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(ResponseException.class));
-            final ResponseException re = (ResponseException) root;
-            assertEquals(ResponseStatusCode.SERVER_ERROR, re.getResponseStatusCode());
-        }
-
-        // keep the testing here until "rebind" is completely removed
-        final Client clientLegacy = client.rebind("g1");
-        assertEquals("stephen", clientLegacy.submit("n='stephen'").all().get().get(0).getString());
-        final Vertex vLegacy = clientLegacy.submit("g.addV('name',n)").all().get().get(0).getVertex();
-        assertEquals("stephen", vLegacy.value("name"));
-
-        final Client clientAliased = client.alias("g1");
-        assertEquals("jason", clientAliased.submit("n='jason'").all().get().get(0).getString());
-        final Vertex v = clientAliased.submit("g.addV('name',n)").all().get().get(0).getVertex();
-        assertEquals("jason", v.value("name"));
-
-        cluster.close();
-    }
-
-    @Test
-    public void shouldManageTransactionsInSession() throws Exception {
-        assumeNeo4jIsPresent();
-
-        final Cluster cluster = Cluster.build().create();
-        final Client client = cluster.connect();
-        final Client sessionWithManagedTx = cluster.connect(name.getMethodName() + "-managed", true);
-        final Client sessionWithoutManagedTx = cluster.connect(name.getMethodName() + "-not-managed");
-
-        // this should auto-commit
-        final Vertex vStephen = sessionWithManagedTx.submit("v = g.addV('name','stephen').next()").all().get().get(0).getVertex();
-        assertEquals("stephen", vStephen.value("name"));
-
-        // the other clients should see that change because of auto-commit
-        assertThat(client.submit("g.V().has('name','stephen').hasNext()").all().get().get(0).getBoolean(), is(true));
-        assertThat(sessionWithoutManagedTx.submit("g.V().has('name','stephen').hasNext()").all().get().get(0).getBoolean(), is(true));
-
-        // this should NOT auto-commit
-        final Vertex vDaniel = sessionWithoutManagedTx.submit("v = g.addV('name','daniel').next()").all().get().get(0).getVertex();
-        assertEquals("daniel", vDaniel.value("name"));
-
-        // the other clients should NOT see that change because of auto-commit
-        assertThat(client.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(false));
-        assertThat(sessionWithManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(false));
-
-        // but "v" should still be there
-        final Vertex vDanielAgain = sessionWithoutManagedTx.submit("v").all().get().get(0).getVertex();
-        assertEquals("daniel", vDanielAgain.value("name"));
-
-        // now commit manually
-        sessionWithoutManagedTx.submit("g.tx().commit()").all().get();
-
-        // should be there for all now
-        assertThat(client.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-        assertThat(sessionWithManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-        assertThat(sessionWithoutManagedTx.submit("g.V().has('name','daniel').hasNext()").all().get().get(0).getBoolean(), is(true));
-
-        cluster.close();
-    }
+//    @Test
+//    public void shouldRequireAliasedGraphVariablesInStrictTransactionMode() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            client.submit("1+1").all().get();
+//            fail("Should have tossed an exception because strict mode is on and no aliasing was performed");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, instanceOf(ResponseException.class));
+//            final ResponseException re = (ResponseException) root;
+//            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
+//        }
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldAliasGraphVariablesInStrictTransactionMode() throws Exception {
+//        assumeNeo4jIsPresent();
+//
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
+//            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, instanceOf(ResponseException.class));
+//            final ResponseException re = (ResponseException) root;
+//            assertEquals(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS, re.getResponseStatusCode());
+//        }
+//
+//        // keep the testing here until "rebind" is completely removed
+//        final Client reboundLegacy = cluster.connect().rebind("graph");
+//        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+//        assertEquals("stephen", vLegacy.value("name"));
+//
+//        final Client rebound = cluster.connect().alias("graph");
+//        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+//        assertEquals("jason", v.value("name"));
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldAliasGraphVariables() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            client.submit("g.addVertex('name','stephen');").all().get().get(0).getVertex();
+//            fail("Should have tossed an exception because \"g\" does not have the addVertex method under default config");
+//        } catch (Exception ex) {
+//            final Throwable root = ExceptionUtils.getRootCause(ex);
+//            assertThat(root, instanceOf(ResponseException.class));
+//            final ResponseException re = (ResponseException) root;
+//            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, re.getResponseStatusCode());
+//        }
+//
+//        // keep the testing here until "rebind" is completely removed
+//        final Client reboundLegacy = cluster.connect().rebind("graph");
+//        final Vertex vLegacy = reboundLegacy.submit("g.addVertex('name','stephen')").all().get().get(0).getVertex();
+//        assertEquals("stephen", vLegacy.value("name"));
+//
+//        final Client rebound = cluster.connect().alias("graph");
+//        final Vertex v = rebound.submit("g.addVertex('name','jason')").all().get().get(0).getVertex();
+//        assertEquals("jason", v.value("name"));
+//
+//        cluster.close();
+//    }
+//
+//    @Test
+//    public void shouldAliasTraversalSourceVariables() throws Exception {
+//        final Cluster cluster = Cluster.build().create();
+//        final Client client = cluster.connect();
+//
+//        try {
+//            cli

<TRUNCATED>

[10/12] tinkerpop git commit: Prevented driver from decrementing open connection count when replacing a connection

Posted by sp...@apache.org.
Prevented driver from decrementing open connection count when replacing a connection

Depending on the configuration and if connection replacement was high, this number could sometimes go negative.


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

Branch: refs/heads/tp31
Commit: f198ce1e714c9f2daa140e9832c6f97f29d866a8
Parents: e0b6dc4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 1 07:40:37 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 1 07:40:37 2016 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/ConnectionPool.java | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f198ce1e/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index 96cb81b..9955e82 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -232,10 +232,6 @@ final class ConnectionPool {
         return closeFuture.compareAndSet(null, future) ? future : closeFuture.get();
     }
 
-    public int opened() {
-        return open.get();
-    }
-
     private CompletableFuture[] killAvailableConnections() {
         final List<CompletableFuture<Void>> futures = new ArrayList<>(connections.size());
         for (Connection connection : connections) {
@@ -321,15 +317,18 @@ final class ConnectionPool {
     }
 
     private void definitelyDestroyConnection(final Connection connection) {
-        bin.add(connection);
-        connections.remove(connection);
-        open.decrementAndGet();
+        // only add to the bin for future removal if its not already there.
+        if (!bin.contains(connection)) {
+            bin.add(connection);
+            connections.remove(connection);
+            open.decrementAndGet();
+        }
 
-        if (connection.borrowed.get() == 0 && bin.remove(connection))
+        // only close the connection for good once it is done being borrowed
+        if (connection.borrowed.get() == 0 && bin.remove(connection)) {
             connection.closeAsync();
-
-        if (logger.isDebugEnabled())
             logger.debug("{} destroyed", connection.getConnectionInfo());
+        }
     }
 
     private Connection waitForConnection(final long timeout, final TimeUnit unit) throws TimeoutException, ConnectionException {


[02/12] tinkerpop git commit: Fixed bug in driver where the client would unecessarily replace Connections.

Posted by sp...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/989977f6/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
index 15b2c4b..8b34038 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
@@ -50,10 +50,8 @@ import java.util.stream.IntStream;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsCollectionContaining.hasItem;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
@@ -96,6 +94,9 @@ public class GremlinServerSessionIntegrateTest  extends AbstractGremlinServerInt
 
                 Logger.getRootLogger().setLevel(Level.INFO);
                 break;
+            case "shouldEnsureSessionBindingsAreThreadSafe":
+                settings.threadPoolWorker = 2;
+                break;
             case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient":
             case "shouldExecuteInSessionWithTransactionManagement":
             case "shouldRollbackOnEvalExceptionForManagedTransaction":
@@ -197,16 +198,15 @@ public class GremlinServerSessionIntegrateTest  extends AbstractGremlinServerInt
 
         assertEquals(1, recordingAppender.getMessages().stream()
                 .filter(msg -> msg.equals("INFO - Session shouldHaveTheSessionTimeout closed\n")).count());
-
     }
 
     @Test
     public void shouldEnsureSessionBindingsAreThreadSafe() throws Exception {
-        final Cluster cluster = Cluster.open();
+        final Cluster cluster = Cluster.build().minInProcessPerConnection(16).maxInProcessPerConnection(64).create();
         final Client client = cluster.connect(name.getMethodName());
 
         client.submitAsync("a=100;b=1000;c=10000;null");
-        final int requests = 1000;
+        final int requests = 10000;
         final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
         IntStream.range(0, requests).forEach(i -> {
             try {
@@ -218,12 +218,15 @@ public class GremlinServerSessionIntegrateTest  extends AbstractGremlinServerInt
 
         assertEquals(requests, futures.size());
 
+        int counter = 0;
         for(CompletableFuture<ResultSet> f : futures) {
-            final Result r = f.get().all().get(3000, TimeUnit.MILLISECONDS).get(0);
+            final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0);
             assertEquals(11100, r.getInt());
+            counter++;
         }
 
-        client.close();
+        assertEquals(requests, counter);
+
         cluster.close();
     }
 


[06/12] tinkerpop git commit: Uncommented some tests that were accidentally commented out.

Posted by sp...@apache.org.
Uncommented some tests that were accidentally commented out.


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

Branch: refs/heads/tp31
Commit: 033a44d1a4be741c0297a5f8c404a9c78c241f62
Parents: 989977f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 30 17:38:26 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 30 17:38:26 2016 -0400

----------------------------------------------------------------------
 .../server/GremlinDriverIntegrateTest.java      | 2070 +++++++++---------
 1 file changed, 1035 insertions(+), 1035 deletions(-)
----------------------------------------------------------------------



[09/12] tinkerpop git commit: Set high water mark first in Gremlin Server.

Posted by sp...@apache.org.
Set high water mark first in Gremlin Server.

If the low water mark is set first and exceeds the default for high watermark then errors ensue.


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

Branch: refs/heads/tp31
Commit: e0b6dc4e3660f9e78d099063bd10bbe5b228bf86
Parents: e14183c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 1 06:37:30 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 1 06:37:30 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/tinkerpop/gremlin/server/GremlinServer.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e0b6dc4e/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
index 49ce3bc..4d76e30 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
@@ -161,8 +161,8 @@ public class GremlinServer {
 
             // when high value is reached then the channel becomes non-writable and stays like that until the
             // low value is so that there is time to recover
-            b.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, settings.writeBufferLowWaterMark);
             b.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, settings.writeBufferHighWaterMark);
+            b.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, settings.writeBufferLowWaterMark);
             b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
 
             // fire off any lifecycle scripts that were provided by the user. hooks get initialized during