You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/03/09 20:46:08 UTC

[01/18] incubator-tinkerpop git commit: General fix to allow server-side fails to be reconnected.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master c06096b8d -> bd0493864


General fix to allow server-side fails to be reconnected.

If a server is responding to the driver in an expected fashion, then the server is still valid, but it may have killed the channel.  If it killed the channel and the driver tries to reconnect on that channel then future requests on that connection would immediately fail and the host would then get marked as dead (when it really wasn't).  Made some basic adjustments here to allow a Connection facing this situation to replace itself in the pool with a fresh connection which would open a new channel on the server and thus allow the next request using it to actually work.


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

Branch: refs/heads/master
Commit: fba51aa14afca428a1819685f8313be1b0ec3526
Parents: b2145cb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 1 15:44:44 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 1 15:44:44 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Connection.java    | 30 ++++++++++++++++++++
 .../gremlin/driver/ConnectionPool.java          |  2 +-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |  5 ++--
 .../server/GremlinServerIntegrateTest.java      | 15 +++++++---
 4 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fba51aa1/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 cb26781..9767fbd 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
@@ -27,6 +27,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.net.URI;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
@@ -185,6 +186,9 @@ final class Connection {
                     } else {
                         final LinkedBlockingQueue<Result> resultLinkedBlockingQueue = new LinkedBlockingQueue<>();
                         final CompletableFuture<Void> readCompleted = new CompletableFuture<>();
+
+                        // the callback for when the read was successful, meaning that ResultQueue.markComplete()
+                        // was called
                         readCompleted.thenAcceptAsync(v -> {
                             thisConnection.returnToPool();
 
@@ -194,6 +198,32 @@ final class Connection {
                                 shutdown(closeFuture.get());
                         }, cluster.executor());
 
+                        // the callback for when the read failed. a failed read means the request went to the server
+                        // and came back with a server-side error of some sort.  it means the server is responsive
+                        // so this isn't going to be like a dead host situation which is handled above on a failed
+                        // write operation.
+                        //
+                        // in the event of an IOException, that will typically mean that the Connection might have
+                        // been closed from the server side. this is typical in situations like when a request is
+                        // sent that exceeds maxContentLength (the server closes the channel on its side).  if the
+                        // Connection is simply returned to the pool then it will be used again on a future request
+                        // and the server will refuse it and make it appear as a dead host as the write will not
+                        // succeed. instead, the Connection gets replaced which destroys the dead channel on the
+                        // client and allows a new one to be reconstructed.
+                        readCompleted.exceptionally(t -> {
+                            if (t instanceof IOException)
+                                if (pool != null) pool.replaceConnection(thisConnection);
+                            else
+                                thisConnection.returnToPool();
+
+                            // close was signaled in closeAsync() but there were pending messages at that time. attempt
+                            // the shutdown if the returned result cleared up the last pending message
+                            if (isClosed() && pending.isEmpty())
+                                shutdown(closeFuture.get());
+
+                            return null;
+                        });
+
                         final ResultQueue handler = new ResultQueue(resultLinkedBlockingQueue, readCompleted);
                         pending.put(requestMessage.getRequestId(), handler);
                         future.complete(new ResultSet(handler, cluster.executor(), readCompleted));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fba51aa1/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 f18d25e..aab9646 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
@@ -248,7 +248,7 @@ final class ConnectionPool {
         return futures.toArray(new CompletableFuture[futures.size()]);
     }
 
-    private void replaceConnection(final Connection connection) {
+    void replaceConnection(final Connection connection) {
         logger.debug("Replace {}", connection);
 
         open.decrementAndGet();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fba51aa1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
index 0ee7640..1a55edc 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.driver;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.javatuples.Pair;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -110,9 +111,7 @@ final class ResultQueue {
 
     void markError(final Throwable throwable) {
         error.set(throwable);
-
-        // unsure if this should really complete exceptionally rather than just complete.
-        this.readComplete.complete(null);
+        this.readComplete.completeExceptionally(throwable);
         this.flushWaiting();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fba51aa1/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index 61c1a98..3ddaaf6 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -40,6 +40,7 @@ import org.apache.tinkerpop.gremlin.server.channel.NioChannelizer;
 import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
+import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -61,6 +62,7 @@ import java.util.stream.IntStream;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.hamcrest.core.IsNot.not;
 import static org.hamcrest.core.StringEndsWith.endsWith;
 import static org.hamcrest.core.StringStartsWith.startsWith;
@@ -552,7 +554,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             client.submit("def class C { def C getC(){return this}}; new C()").all().join();
             fail("Should throw an exception.");
         } catch (RuntimeException re) {
-            assertTrue(re.getCause().getCause().getMessage().startsWith("Error during serialization: Direct self-reference leading to cycle (through reference chain:"));
+            final Throwable root = ExceptionUtils.getRootCause(re);
+            assertThat(root.getMessage(), CoreMatchers.startsWith("Error during serialization: Direct self-reference leading to cycle (through reference chain:"));
 
             // validate that we can still send messages to the server
             assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
@@ -570,7 +573,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             client.submit("java.awt.Color.RED").all().join();
             fail("Should throw an exception.");
         } catch (RuntimeException re) {
-            assertTrue(re.getCause().getCause().getMessage().startsWith("Error during serialization: Class is not registered: java.awt.Color"));
+            final Throwable root = ExceptionUtils.getRootCause(re);
+            assertThat(root.getMessage(), CoreMatchers.startsWith("Error during serialization: Class is not registered: java.awt.Color"));
 
             // validate that we can still send messages to the server
             assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
@@ -599,6 +603,9 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         } catch (Exception re) {
             final Throwable root = ExceptionUtils.getRootCause(re);
             assertEquals("Connection reset by peer", root.getMessage());
+
+            // validate that we can still send messages to the server
+            assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
         } finally {
             cluster.close();
         }
@@ -659,8 +666,8 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             client.submit("x[1]+2").all().get();
             fail("Session should be dead");
         } catch (Exception ex) {
-            final Exception cause = (Exception) ex.getCause().getCause();
-            assertTrue(cause instanceof ResponseException);
+            final Throwable cause = ExceptionUtils.getCause(ex);
+            assertThat(cause, instanceOf(ResponseException.class));
             assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, ((ResponseException) cause).getResponseStatusCode());
 
             // validate that we can still send messages to the server


[07/18] incubator-tinkerpop git commit: Update upgrade docs around TINKERPOP-1160

Posted by ok...@apache.org.
Update upgrade docs around TINKERPOP-1160


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

Branch: refs/heads/master
Commit: 90b3117b29933741e0a4f29ec38abfb15f35bcb3
Parents: f0fc5e2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 15:53:28 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 15:53:28 2016 -0500

----------------------------------------------------------------------
 docs/src/upgrade/release-3.1.x-incubating.asciidoc | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/90b3117b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.1.x-incubating.asciidoc b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
index ab0d725..2652d03 100644
--- a/docs/src/upgrade/release-3.1.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.1.x-incubating.asciidoc
@@ -63,6 +63,15 @@ in a transaction. With this configuration of `client` there is no need to close
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1039[TINKERPOP-1039],
 link:http://tinkerpop.apache.org/docs/3.1.2-incubating/reference/#sessions[Reference Documentation - Considering Sessions]
 
+Session Timeout Setting
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The `gremlin-driver` now has a setting called `maxWaitForSessionClose` that allows control of how long it will wait for
+an in-session connection to respond to a close request before it simply times-out and moves on.  When that happens,
+the server will either eventually close the connection via at session expiration or at the time of shutdown.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1160[TINKERPOP-1160]
+
 Upgrading for Providers
 ~~~~~~~~~~~~~~~~~~~~~~~
 


[03/18] incubator-tinkerpop git commit: Ignored the shouldHandleRequestSentThatNeverReturns() test for driver.

Posted by ok...@apache.org.
Ignored the shouldHandleRequestSentThatNeverReturns() test for driver.

This test never wants to behave not matter is done to it to firm it up. It seems to rely a little too heavily on timing to be consistent.


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

Branch: refs/heads/master
Commit: 9e1b5b12da38f0c13573cbea25a94f18a4cab104
Parents: 4abb58b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 1 17:33:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 1 17:33:49 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9e1b5b12/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 609055f..9fc6930 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
@@ -596,6 +596,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @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();


[10/18] incubator-tinkerpop git commit: Add reference docs for all the driver settings.

Posted by ok...@apache.org.
Add reference docs for all the driver settings.


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

Branch: refs/heads/master
Commit: 5944ee6574b0feb9d2b257768d0dc3a1309697dd
Parents: 7ebd46c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 17:16:15 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 17:16:15 2016 -0500

----------------------------------------------------------------------
 .../src/reference/gremlin-applications.asciidoc | 39 +++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5944ee65/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index b7c8ac0..9810acd 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -532,6 +532,43 @@ In this case, they are streamed from the server as they arrive.
 <5> Parameterized request are considered the most efficient way to send Gremlin to the server as they can be cached,
 which will boost performance and reduce resources required on the server.
 
+Configuration
+^^^^^^^^^^^^^
+
+The following table describes the various configuration options for the Gremlin Driver:
+
+[width="100%",cols="3,10,^2",options="header"]
+|=========================================================
+|Key |Description |Default
+|connectionPool.channelizer |The fully qualified classname of the client `Channelizer` that defines how to connect to the server. |`Channelizer.WebSocketChannelizer`
+|connectionPool.enableSsl |Determines if SSL should be enabled or not. If enabled on the server then it must be enabled on the client. |false
+|connectionPool.maxContentLength |The maximum length in bytes that a message can be sent to the server. This number can be no greater than the setting of the same name in the server configuration. |65536
+|connectionPool.maxInProcessPerConnection |The maximum number of in-flight requests that can occur on a connection. |4
+|connectionPool.maxSimultaneousUsagePerConnection |The maximum number of times that a connection can be borrowed from the pool simultaneously. |16
+|connectionPool.maxSize |The maximum size of a connection pool for a host. |8
+|connectionPool.maxWaitForConnection |The amount of time in milliseconds to wait for a new connection before timing out. |3000
+|connectionPool.maxWaitForSessionClose |The amount of time in milliseconds to wait for a session to close before timing out (does not apply to sessionless connections). |3000
+|connectionPool.minInProcessPerConnection |The minimum number of in-flight requests that can occur on a connection. |1
+|connectionPool.minSimultaneousUsagePerConnection |The maximum number of times that a connection can be borrowed from the pool simultaneously. |8
+|connectionPool.minSize |The minimum size of a connection pool for a host. |2
+|connectionPool.reconnectInitialDelay |The amount of time in milliseconds to wait before trying to reconnect to a dead host for the first time. |1000
+|connectionPool.reconnectInterval |The amount of time in milliseconds to wait before trying to reconnect to a dead host. This interval occurs after the time specified by the `reconnectInitialDelay`. |1000
+|connectionPool.resultIterationBatchSize |The override value for the size of the result batches to be returned from the server. |64
+|connectionPool.trustCertChainFile |File location for a SSL Certificate Chain to use when SSL is enabled. If this value is not provided and SSL is enabled, the `TrustManager` will be established with a self-signed certificate which is NOT suitable for production purposes. |_none_
+|hosts |The list of hosts that the driver will connect to. |localhost
+|jaasEntry |Sets the `AuthProperties.Property.JAAS_ENTRY` properties for authentication to Gremlin Server. |_none_
+|nioPoolSize |Size of the pool for handling request/response operations. |available processors
+|password |The password to submit on requests that require authentication. |_none_
+|port |The port of the Gremlin Server to connect to. The same port will be applied for all hosts. |8192
+|protocol |Sets the `AuthProperties.Property.PROTOCOL` properties for authentication to Gremlin Server. |_none_
+|serializer.className |The fully qualified class name of the `MessageSerializer` that will be used to communicate with the server. Note that the serializer configured on the client should be supported by the server configuration. |`GryoMessageSerializerV1d0`
+|serializer.config |A `Map` of configuration settings for the serializer. |_none_
+|username |The username to submit on requests that require authentication. |_none_
+|workerPoolSize |Size of the pool for handling background work. |available processors * 2
+|=========================================================
+
+Please see the link:http://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/driver/Cluster.Builder.html[Cluster.Builder javadoc] to get more information on these settings.
+
 Aliases
 ^^^^^^^
 
@@ -693,7 +730,7 @@ The following table describes the various configuration options that Gremlin Ser
 |Key |Description |Default
 |authentication.className |The fully qualified classname of an `Authenticator` implementation to use.  If this setting is not present, then authentication is effectively disabled. |`AllowAllAuthenticator`
 |authentication.config |A `Map` of configuration settings to be passes to the `Authenticator` when it is constructed.  The settings available are dependent on the implementation. |_none_
-|channelizer |The fully qualified classname of the `Channelizer` implementation to use.  A `Channelizer` is a "channel initializer" which Gremlin Server uses to define the type of processing pipeline to use.  By allowing different `Channelizer` implementations, Gremlin Server can support different communication protocols (e.g. Websockets, Java NIO, etc.). |WebSocketChannelizer
+|channelizer |The fully qualified classname of the `Channelizer` implementation to use.  A `Channelizer` is a "channel initializer" which Gremlin Server uses to define the type of processing pipeline to use.  By allowing different `Channelizer` implementations, Gremlin Server can support different communication protocols (e.g. Websockets, Java NIO, etc.). |`WebSocketChannelizer`
 |graphs |A `Map` of `Graph` configuration files where the key of the `Map` becomes the name to which the `Graph` will be bound and the value is the file name of a `Graph` configuration file. |_none_
 |gremlinPool |The number of "Gremlin" threads available to execute actual scripts in a `ScriptEngine`. This pool represents the workers available to handle blocking operations in Gremlin Server. |8
 |host |The name of the host to bind the server to. |localhost


[02/18] incubator-tinkerpop git commit: Minor refactoring to extract Connection shutdown function.

Posted by ok...@apache.org.
Minor refactoring to extract Connection shutdown function.


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

Branch: refs/heads/master
Commit: 4abb58bf5df63b71d2ccab893f7f9f354e2391a1
Parents: fba51aa
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 1 16:52:27 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 1 16:52:27 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Connection.java      | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4abb58bf/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 9767fbd..10d3b89 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
@@ -191,11 +191,7 @@ final class Connection {
                         // was called
                         readCompleted.thenAcceptAsync(v -> {
                             thisConnection.returnToPool();
-
-                            // close was signaled in closeAsync() but there were pending messages at that time. attempt
-                            // the shutdown if the returned result cleared up the last pending message
-                            if (isClosed() && pending.isEmpty())
-                                shutdown(closeFuture.get());
+                            tryShutdown();
                         }, cluster.executor());
 
                         // the callback for when the read failed. a failed read means the request went to the server
@@ -218,8 +214,7 @@ final class Connection {
 
                             // close was signaled in closeAsync() but there were pending messages at that time. attempt
                             // the shutdown if the returned result cleared up the last pending message
-                            if (isClosed() && pending.isEmpty())
-                                shutdown(closeFuture.get());
+                            tryShutdown();
 
                             return null;
                         });
@@ -243,6 +238,15 @@ final class Connection {
         }
     }
 
+    /**
+     * Close was signaled in closeAsync() but there were pending messages at that time. This method attempts the
+     * shutdown if the returned result cleared up the last pending message.
+     */
+    private void tryShutdown() {
+        if (isClosed() && pending.isEmpty())
+            shutdown(closeFuture.get());
+    }
+
     private void shutdown(final CompletableFuture<Void> future) {
         // shutdown can be called directly from closeAsync() or after write() and therefore this method should only
         // be called once. once shutdown is initiated, it shoudln't be executed a second time or else it sends more


[06/18] incubator-tinkerpop git commit: Update changelog.

Posted by ok...@apache.org.
Update changelog.


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

Branch: refs/heads/master
Commit: f0fc5e27ba8248396919c6175abff55f9496978c
Parents: 29b0525
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 15:50:31 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 15:50:31 2016 -0500

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


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f0fc5e27/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 009b69b..6987b2e 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added `maxWaitForSessionClose` to the settings for Gremlin Driver.
 * Bumped to Netty 4.0.34.Final.
 * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
 * Bumped to Apache Groovy 2.4.6.


[15/18] incubator-tinkerpop git commit: Fixed a bug where OrderGlobalStep and OrderLocalStep were not incorporating their childrens traverser requirements. Add a test to CountTest that verifies that the bug is now fixed.

Posted by ok...@apache.org.
Fixed a bug where OrderGlobalStep and OrderLocalStep were not incorporating their childrens traverser requirements. Add a test to CountTest that verifies that the bug is now fixed.


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

Branch: refs/heads/master
Commit: 3eadf73f6653965356b2ec2b25d1b5f9c01545b2
Parents: b529398
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Mar 9 12:19:23 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Mar 9 12:19:23 2016 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../traversal/step/map/OrderGlobalStep.java     |  2 +-
 .../traversal/step/map/OrderLocalStep.java      |  2 +-
 .../traversal/step/map/GroovyCountTest.groovy   |  5 +++
 .../process/traversal/step/map/CountTest.java   | 35 ++++++++++++++++++--
 5 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3eadf73f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a39683a..54df044 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed a bug where `OrderGlobalStep` and `OrderLocalStep` were not incorporating their children's traverser requirements.
 * Fixed a compilation bug in `TraversalExplanation`.
 * Bumped to Netty 4.0.34.Final.
 * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3eadf73f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java
index 6b9a2cc..06d368b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java
@@ -87,7 +87,7 @@ public final class OrderGlobalStep<S> extends CollectingBarrierStep<S> implement
 
     @Override
     public Set<TraverserRequirement> getRequirements() {
-        return Collections.singleton(TraverserRequirement.OBJECT);
+        return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3eadf73f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java
index 35493cf..37d6c33 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java
@@ -91,7 +91,7 @@ public final class OrderLocalStep<S, M> extends MapStep<S, S> implements Compara
 
     @Override
     public Set<TraverserRequirement> getRequirements() {
-        return Collections.singleton(TraverserRequirement.OBJECT);
+        return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3eadf73f/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
index 016749f..d617a3d 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
@@ -67,5 +67,10 @@ public abstract class GroovyCountTest {
         public Traversal<Vertex, Long> get_g_V_fold_countXlocalX() {
             TraversalScriptHelper.compute("g.V.fold.count(local)", g);
         }
+
+        @Override
+        public Traversal<Vertex, String> get_g_V_both_both_order_byXcount_decrX_name() {
+            TraversalScriptHelper.compute("g.V.both.both.order.by(count(), decr).name", g);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3eadf73f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
index 320847c..046be1e 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
@@ -21,19 +21,22 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
-import org.apache.tinkerpop.gremlin.process.IgnoreEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
 import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.List;
+
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.GRATEFUL;
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -57,6 +60,8 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Long> get_g_V_fold_countXlocalX();
 
+    public abstract Traversal<Vertex, String> get_g_V_both_both_order_byXcount_decrX_name();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_count() {
@@ -138,6 +143,25 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
         assertFalse(traversal.hasNext());
     }
 
+    @Test
+    @LoadGraphWith
+    public void g_V_both_both_order_byXcount_decrX_name() {
+        final Traversal<Vertex, String> traversal = get_g_V_both_both_order_byXcount_decrX_name();
+        printTraversalForm(traversal);
+        final List<String> names = traversal.toList();
+        for (int i = 0; i < 7; i++) {
+            assertEquals("marko", names.get(i));
+        }
+        assertTrue(names.get(7).equals("josh") || names.get(7).equals("lop"));
+        assertEquals(7l, names.stream().filter(name -> name.equals("marko")).count());
+        assertEquals(7l, names.stream().filter(name -> name.equals("josh")).count());
+        assertEquals(7l, names.stream().filter(name -> name.equals("lop")).count());
+        assertEquals(3l, names.stream().filter(name -> name.equals("peter")).count());
+        assertEquals(3l, names.stream().filter(name -> name.equals("ripple")).count());
+        assertEquals(3l, names.stream().filter(name -> name.equals("vadas")).count());
+    }
+
+
     public static class Traversals extends CountTest {
 
         @Override
@@ -166,7 +190,7 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
         }
 
         @Override
-        public  Traversal<Vertex, Long> get_g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count() {
+        public Traversal<Vertex, Long> get_g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count() {
             return g.V().repeat(out()).times(5).as("a").out("writtenBy").as("b").select("a", "b").count();
         }
 
@@ -179,5 +203,10 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Long> get_g_V_fold_countXlocalX() {
             return g.V().fold().count(Scope.local);
         }
+
+        @Override
+        public Traversal<Vertex, String> get_g_V_both_both_order_byXcount_decrX_name() {
+            return g.V().both().both().order().by(__.count(), Order.decr).values("name");
+        }
     }
 }


[18/18] incubator-tinkerpop git commit: upmerged tp31 and tweaked given new master/ Groovy style using ScriptTraversal.

Posted by ok...@apache.org.
upmerged tp31 and tweaked given new master/ Groovy style using ScriptTraversal.


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

Branch: refs/heads/master
Commit: bd04938647a0986a250817e45bc230578c7be2fb
Parents: c4b9680
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Mar 9 12:46:01 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Mar 9 12:46:01 2016 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                                 | 1 +
 .../gremlin/process/traversal/step/map/GroovyCountTest.groovy      | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bd049386/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 06caba1..5231faf 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -24,6 +24,7 @@ TinkerPop 3.2.0 (XXX)
 TinkerPop 3.2.0 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed a `hashCode()`/`equals()` bug in `MessageScope`.
 * Fixed a severe `Traversal` cloning issue that caused inconsistent `TraversalSideEffects`.
 * `TraversalSideEffects` remain consistent and usable across multiple chained OLAP jobs.
 * Added `MemoryTraversalSideEffects` which wraps `Memory` in a `TraversalSideEffects` for use in OLAP.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bd049386/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
index 13515cd..0f81cce 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
@@ -70,7 +70,7 @@ public abstract class GroovyCountTest {
 
         @Override
         public Traversal<Vertex, String> get_g_V_both_both_order_byXcount_decrX_name() {
-            TraversalScriptHelper.compute("g.V.both.both.order.by(count(), decr).name", g);
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.order.by(count(), decr).name");
         }
     }
 }


[05/18] incubator-tinkerpop git commit: Added maxWaitForSessionClose to driver configuration.

Posted by ok...@apache.org.
Added maxWaitForSessionClose to driver configuration.

This setting configures how long the driver will wait to kill a session before it just lets the server handle it.  Added a bunch of javadoc to the driver settings.


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

Branch: refs/heads/master
Commit: 29b052598ecc90296a810b3a8fdb525afbabeb6d
Parents: 4247aa6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 15:48:52 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 15:48:52 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/driver/Client.java |   1 -
 .../tinkerpop/gremlin/driver/Connection.java    |  14 ++-
 .../tinkerpop/gremlin/driver/Settings.java      | 116 +++++++++++++++++++
 3 files changed, 127 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index 031d595..50de9d8 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -22,7 +22,6 @@ import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/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 cb26781..a3b8ff3 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
@@ -33,6 +33,8 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
@@ -55,6 +57,7 @@ final class Connection {
     public static final int MAX_IN_PROCESS = 4;
     public static final int MIN_IN_PROCESS = 1;
     public static final int MAX_WAIT_FOR_CONNECTION = 3000;
+    public static final int MAX_WAIT_FOR_SESSION_CLOSE = 3000;
     public static final int MAX_CONTENT_LENGTH = 65536;
     public static final int RECONNECT_INITIAL_DELAY = 1000;
     public static final int RECONNECT_INTERVAL = 1000;
@@ -215,7 +218,7 @@ final class Connection {
 
     private void shutdown(final CompletableFuture<Void> future) {
         // shutdown can be called directly from closeAsync() or after write() and therefore this method should only
-        // be called once. once shutdown is initiated, it shoudln't be executed a second time or else it sends more
+        // be called once. once shutdown is initiated, it shouldn't be executed a second time or else it sends more
         // messages at the server and leads to ugly log messages over there.
         if (shutdownInitiated.compareAndSet(false, true)) {
             if (client instanceof Client.SessionedClient) {
@@ -228,10 +231,15 @@ final class Connection {
                     // make sure we get a response here to validate that things closed as expected.  on error, we'll let
                     // the server try to clean up on its own.  the primary error here should probably be related to
                     // protocol issues which should not be something a user has to fuss with.
-                    closed.get();
+                    closed.get(cluster.connectionPoolSettings().maxWaitForSessionClose, TimeUnit.MILLISECONDS);
+                } catch (TimeoutException ex) {
+                    final String msg = String.format(
+                            "Timeout while trying to close connection on %s - force closing - server will close session on shutdown or expiration.",
+                            ((Client.SessionedClient) client).getSessionId());
+                    logger.warn(msg, ex);
                 } catch (Exception ex) {
                     final String msg = String.format(
-                            "Encountered an error trying to close connection on %s - force closing - server will close session on shutdown or timeout.",
+                            "Encountered an error trying to close connection on %s - force closing - server will close session on shutdown or expiration.",
                             ((Client.SessionedClient) client).getSessionId());
                     logger.warn(msg, ex);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
index 7a40d4f..fb85910 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
@@ -31,28 +31,62 @@ import java.util.Objects;
 import java.util.Optional;
 
 /**
+ * Settings for the {@link Cluster} and its related components.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 final class Settings {
 
+    /**
+     * The port of the Gremlin Server to connect to which defaults to {@code 8192}. The same port will be applied for
+     * all {@link #hosts}.
+     */
     public int port = 8182;
 
+    /**
+     * The list of hosts that the driver will connect to.
+     */
     public List<String> hosts = new ArrayList<>();
 
+    /**
+     * The serializer that will be used when communicating with the server. Note that serializer settings should match
+     * what is available on the server.
+     */
     public SerializerSettings serializer = new SerializerSettings();
 
+    /**
+     * Settings for connections and connection pool.
+     */
     public ConnectionPoolSettings connectionPool = new ConnectionPoolSettings();
 
+    /**
+     * The size of the thread pool defaulted to the number of available processors.
+     */
     public int nioPoolSize = Runtime.getRuntime().availableProcessors();
 
+    /**
+     * The number of worker threads defaulted to the number of available processors * 2.
+     */
     public int workerPoolSize = Runtime.getRuntime().availableProcessors() * 2;
 
+    /**
+     * The username to submit on requests that require authentication.
+     */
     public String username = null;
 
+    /**
+     * The password to submit on requests that require authentication.
+     */
     public String password = null;
 
+    /**
+     * The JAAS to submit on requests that require authentication.
+     */
     public String jaasEntry = null;
 
+    /**
+     * The JAAS protocol to submit on requests that require authentication.
+     */
     public String protocol = null;
 
     /**
@@ -74,19 +108,93 @@ final class Settings {
     }
 
     static class ConnectionPoolSettings {
+        /**
+         * Determines if SSL should be enabled or not. If enabled on the server then it must be enabled on the client.
+         */
         public boolean enableSsl = false;
+
+        /**
+         * The trusted certificate in PEM format.
+         */
         public String trustCertChainFile = null;
+
+        /**
+         * The minimum size of a connection pool for a {@link Host}. By default this is set to 2.
+         */
         public int minSize = ConnectionPool.MIN_POOL_SIZE;
+
+        /**
+         * The maximum size of a connection pool for a {@link Host}. By default this is set to 8.
+         */
         public int maxSize = ConnectionPool.MAX_POOL_SIZE;
+
+        /**
+         * A connection under low use can be destroyed. This setting determines the threshold for determining when
+         * that connection can be released and is defaulted to 8.
+         */
         public int minSimultaneousUsagePerConnection = ConnectionPool.MIN_SIMULTANEOUS_USAGE_PER_CONNECTION;
+
+        /**
+         * If a connection is over used, then it might mean that is necessary to expand the pool by adding a new
+         * connection.  This setting determines the threshold for a connections over use and is defaulted to 16
+         */
         public int maxSimultaneousUsagePerConnection = ConnectionPool.MAX_SIMULTANEOUS_USAGE_PER_CONNECTION;
+
+        /**
+         * The maximum number of requests in flight on a connection where the default is 4.
+         */
         public int maxInProcessPerConnection = Connection.MAX_IN_PROCESS;
+
+        /**
+         * A connection has available in-process requests which is calculated by subtracting the number of current
+         * in-flight requests on a connection and subtracting that from the {@link #maxInProcessPerConnection}. When
+         * that number drops below this configuration setting, the connection is recommended for replacement. The
+         * default for this setting is 1.
+         */
         public int minInProcessPerConnection = Connection.MIN_IN_PROCESS;
+
+        /**
+         * The amount of time in milliseconds to wait for a new connection before timing out where the default value
+         * is 3000.
+         */
         public int maxWaitForConnection = Connection.MAX_WAIT_FOR_CONNECTION;
+
+        /**
+         * If the connection is using a "session" this setting represents the amount of time in milliseconds to wait
+         * for that session to close before timing out where the default value is 3000. Note that the server will
+         * eventually clean up dead sessions itself on expiration of the session or during shutdown.
+         */
+        public int maxWaitForSessionClose = Connection.MAX_WAIT_FOR_SESSION_CLOSE;
+
+        /**
+         * The maximum length in bytes that a message can be sent to the server. This number can be no greater than
+         * the setting of the same name in the server configuration. The default value is 65536.
+         */
         public int maxContentLength = Connection.MAX_CONTENT_LENGTH;
+
+        /**
+         * The amount of time in milliseconds to wait before trying to reconnect to a dead host. The default value is
+         * 1000. This interval occurs after the time specified by the {@link #reconnectInitialDelay}.
+         */
         public int reconnectInterval = Connection.RECONNECT_INTERVAL;
+
+        /**
+         * The amount of time in milliseconds to wait before trying to reconnect to a dead host for the first time.
+         * The default value is 1000.
+         */
         public int reconnectInitialDelay = Connection.RECONNECT_INITIAL_DELAY;
+
+        /**
+         * The override value for the size of the result batches to be returned from the server. This value is set to
+         * 64 by default.
+         */
         public int resultIterationBatchSize = Connection.RESULT_ITERATION_BATCH_SIZE;
+
+        /**
+         * The constructor for the channel that connects to the server. This value should be the fully qualified
+         * class name of a Gremlin Driver {@link Channelizer} implementation.  By default this value is set to
+         * {@link org.apache.tinkerpop.gremlin.driver.Channelizer.WebSocketChannelizer}.
+         */
         public String channelizer = Channelizer.WebSocketChannelizer.class.getName();
 
         /**
@@ -107,7 +215,15 @@ final class Settings {
     }
 
     public static class SerializerSettings {
+        /**
+         * The fully qualified class name of the {@link MessageSerializer} that will be used to communicate with the
+         * server. Note that the serializer configured on the client should be supported by the server configuration.
+         */
         public String className = GraphSONMessageSerializerV1d0.class.getCanonicalName();
+
+        /**
+         * The configuration for the specified serializer with the {@link #className}.
+         */
         public Map<String, Object> config = null;
 
         public MessageSerializer create() throws Exception {


[12/18] incubator-tinkerpop git commit: Fixed bug where session close was happening an extra time.

Posted by ok...@apache.org.
Fixed bug where session close was happening an extra time.

If a session was closed explicitly by the client, the scheduled job to close the session on expiration was not being cancelled leading to a second closing. The second closing really wasn't doing anything "bad" but it did generate extra logging that was confusing if the user had expected the session to already be closed.  Refactored some of the session "kill" operations to make them a bit more thread safe.


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

Branch: refs/heads/master
Commit: a27964821feaf733c3f39ef5432084414c66883e
Parents: 753038d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 4 08:43:38 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 8 09:18:25 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../gremlin/server/op/session/Session.java      |  37 ++-
 .../server/op/session/SessionOpProcessor.java   |   4 +-
 .../server/GremlinServerIntegrateTest.java      | 185 -----------
 .../GremlinServerSessionIntegrateTest.java      | 332 +++++++++++++++++++
 5 files changed, 362 insertions(+), 197 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2796482/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index aad3314..1a2e116 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -28,6 +28,7 @@ TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 
 * Bump to commons-collections 3.2.2.
 * Fixed a compilation bug in `TraversalExplanation`.
+* Fixed bug where a session explicitly closed was being closed again by session expiration.
 * Bumped to Netty 4.0.34.Final.
 * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
 * Bumped to Apache Groovy 2.4.6.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2796482/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 c29b45a..01e7bbd 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
@@ -99,21 +99,38 @@ public class 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.
-        final ScheduledFuture killFuture = kill.get();
-        if (null == killFuture || !killFuture.isDone()) {
-            if (killFuture != null) killFuture.cancel(false);
-            kill.set(this.scheduledExecutorService.schedule(() -> {
-                logger.info("Session {} has been idle for more than {} milliseconds - preparing to close",
-                        this.session, this.configuredSessionTimeout);
-                kill();
-            }, this.configuredSessionTimeout, TimeUnit.MILLISECONDS));
-        }
+        kill.updateAndGet(future -> {
+            if (null == future || !future.isDone()) {
+                if (future != null) future.cancel(false);
+                return this.scheduledExecutorService.schedule(() -> {
+                        logger.info("Session {} has been idle for more than {} milliseconds - preparing to close",
+                                this.session, this.configuredSessionTimeout);
+                        kill();
+                    }, this.configuredSessionTimeout, TimeUnit.MILLISECONDS);
+            }
+
+            return future;
+        });
+    }
+
+    /**
+     * Stops the session with call to {@link #kill()} but also stops the session expiration call which ensures that
+     * the session is only killed once.
+     */
+    public void manualKill() {
+        kill.get().cancel(true);
+        kill();
     }
 
     /**
      * Kills the session and rollback any uncommitted changes on transactional graphs.
      */
-    public void kill() {
+    public synchronized void kill() {
+        // if the session has already been removed then there's no need to do this process again.  it's possible that
+        // the manuallKill and the kill future could have both called kill at roughly the same time. this prevents
+        // kill() from being called more than once
+        if (!sessions.containsKey(session)) return;
+
         // when the session is killed open transaction should be rolled back
         graphManager.getGraphs().entrySet().forEach(kv -> {
             final Graph g = kv.getValue();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2796482/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 b7e0d06..42ec6f5 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
@@ -111,7 +111,7 @@ public class SessionOpProcessor extends AbstractEvalOpProcessor {
                     throw new OpProcessorException(msg, ResponseMessage.build(requestMessage).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create());
                 }
 
-                sessionToClose.kill();
+                sessionToClose.manualKill();
             });
         } else {
             return Optional.empty();
@@ -137,7 +137,7 @@ public class SessionOpProcessor extends AbstractEvalOpProcessor {
 
     @Override
     public void close() throws Exception {
-       sessions.values().forEach(Session::kill);
+       sessions.values().forEach(Session::manualKill);
     }
 
     protected void evalOp(final Context context) throws OpProcessorException {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2796482/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index c863c4e..477f4f7 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -641,36 +641,6 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
-    public void shouldHaveTheSessionTimeout() 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]");
-        final AtomicInteger counter = new AtomicInteger(0);
-        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
-
-        final ResultSet results2 = client.submit("x[0]+1");
-        assertEquals(2, results2.all().get().get(0).getInt());
-
-        // session times out in 3 seconds
-        Thread.sleep(3500);
-
-        try {
-            client.submit("x[1]+2").all().get();
-            fail("Session should be dead");
-        } catch (Exception ex) {
-            final Exception cause = (Exception) ex.getCause().getCause();
-            assertTrue(cause instanceof ResponseException);
-            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, ((ResponseException) cause).getResponseStatusCode());
-
-            // validate that we can still send messages to the server
-            assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
-        } finally {
-            cluster.close();
-        }
-    }
-
-    @Test
     public void shouldNotHavePartialContentWithOneResult() throws Exception {
         try (SimpleClient client = new WebSocketClient()) {
             final RequestMessage request = RequestMessage.build(Tokens.OPS_EVAL)
@@ -691,134 +661,6 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals(1, responses.size());
         }
     }
-    
-    @Test
-    @SuppressWarnings("unchecked")
-    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient() throws Exception {
-        assumeNeo4jIsPresent();
-        
-        try (final SimpleClient client = new WebSocketClient()) {
-
-            //open a transaction, create a vertex, commit
-            final RequestMessage openRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().open()")
-                    .create();
-            final List<ResponseMessage> openResponses = client.submit(openRequest);
-            assertEquals(1, openResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, openResponses.get(0).getStatus().getCode());
-
-            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
-                    .create();
-            final List<ResponseMessage> addResponses = client.submit(addRequest);
-            assertEquals(1, addResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
-
-            final RequestMessage commitRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().commit()")
-                    .create();
-            final List<ResponseMessage> commitResponses = client.submit(commitRequest);
-            assertEquals(1, commitResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, commitResponses.get(0).getStatus().getCode());
-
-            // Check to see if the transaction is closed.
-            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
-                    .create();
-            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
-            assertEquals(1, checkResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
-            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
-
-            //lets run a sessionless read
-            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V()")
-                    .create();
-            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
-            assertEquals(1, sessionlessResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
-
-            // Check to see if the transaction is still closed.
-            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
-                    .create();
-            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
-            assertEquals(1, checkAgainstResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
-            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
-        }
-    }
-
-    @Test
-    @SuppressWarnings("unchecked")
-    public void shouldExecuteInSessionWithTransactionManagement() throws Exception {
-        assumeNeo4jIsPresent();
-
-        try (final SimpleClient client = new WebSocketClient()) {
-            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
-                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
-                    .create();
-            final List<ResponseMessage> addResponses = client.submit(addRequest);
-            assertEquals(1, addResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
-
-            // Check to see if the transaction is closed.
-            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
-                    .create();
-            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
-            assertEquals(1, checkResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
-            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
-
-            // lets run a sessionless read and validate that the transaction was managed
-            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V().values('name')")
-                    .create();
-            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
-            assertEquals(1, sessionlessResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
-            assertEquals("stephen", ((List<String>) sessionlessResponses.get(0).getResult().getData()).get(0));
-
-            // make sure the session is intact
-            final RequestMessage getRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "v.values(\"name\")")
-                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
-                    .create();
-            final List<ResponseMessage> getResponses = client.submit(getRequest);
-            assertEquals(1, getResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, getResponses.get(0).getStatus().getCode());
-            assertEquals("stephen", ((List<String>) getResponses.get(0).getResult().getData()).get(0));
-
-            // Check to see if the transaction is still closed.
-            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
-                    .processor("session")
-                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
-                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
-                    .create();
-            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
-            assertEquals(1, checkAgainstResponses.size());
-            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
-            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
-        }
-    }
 
     @Test
     @SuppressWarnings("unchecked")
@@ -837,31 +679,4 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             assertEquals("jason", v.value("name"));
         }
     }
-
-    @Test
-    public void shouldEnsureSessionBindingsAreThreadSafe() throws Exception {
-        final Cluster cluster = Cluster.open();
-        final Client client = cluster.connect(name.getMethodName());
-
-        client.submitAsync("a=100;b=1000;c=10000;null");
-        final int requests = 1000;
-        final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
-        IntStream.range(0, requests).forEach(i -> {
-            try {
-                futures.add(client.submitAsync("a+b+c"));
-            } catch (Exception ex) {
-                throw new RuntimeException(ex);
-            }
-        });
-
-        assertEquals(requests, futures.size());
-
-        for(CompletableFuture<ResultSet> f : futures) {
-            final Result r = f.get().one();
-            assertEquals(11100, r.getInt());
-        }
-
-        client.close();
-        cluster.close();
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a2796482/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
new file mode 100644
index 0000000..cfdb877
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.server;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.Result;
+import org.apache.tinkerpop.gremlin.driver.ResultSet;
+import org.apache.tinkerpop.gremlin.driver.Tokens;
+import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
+import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.driver.simple.SimpleClient;
+import org.apache.tinkerpop.gremlin.driver.simple.WebSocketClient;
+import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
+import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
+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;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GremlinServerSessionIntegrateTest  extends AbstractGremlinServerIntegrationTest {
+    private Log4jRecordingAppender recordingAppender = null;
+    private Level originalLevel;
+
+    @Before
+    public void setupForEachTest() {
+        recordingAppender = new Log4jRecordingAppender();
+        final Logger rootLogger = Logger.getRootLogger();
+        rootLogger.addAppender(recordingAppender);
+        originalLevel = rootLogger.getLevel();
+    }
+
+    @After
+    public void teardownForEachTest() {
+        final Logger rootLogger = Logger.getRootLogger();
+        rootLogger.removeAppender(recordingAppender);
+        rootLogger.setLevel(originalLevel);
+    }
+
+    /**
+     * Configure specific Gremlin Server settings for specific tests.
+     */
+    @Override
+    public Settings overrideSettings(final Settings settings) {
+        final String nameOfTest = name.getMethodName();
+        switch (nameOfTest) {
+            case "shouldHaveTheSessionTimeout":
+            case "shouldCloseSessionOnceOnRequest":
+                settings.processors.clear();
+                final Settings.ProcessorSettings processorSettings = new Settings.ProcessorSettings();
+                processorSettings.className = SessionOpProcessor.class.getCanonicalName();
+                processorSettings.config = new HashMap<>();
+                processorSettings.config.put(SessionOpProcessor.CONFIG_SESSION_TIMEOUT, 3000L);
+                settings.processors.add(processorSettings);
+
+                Logger.getRootLogger().setLevel(Level.INFO);
+                break;
+            case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient":
+            case "shouldExecuteInSessionWithTransactionManagement":
+                deleteDirectory(new File("/tmp/neo4j"));
+                settings.graphs.put("graph", "conf/neo4j-empty.properties");
+                break;
+        }
+
+        return settings;
+    }
+
+    @Test
+    public void shouldCloseSessionOnceOnRequest() 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]");
+        final AtomicInteger counter = new AtomicInteger(0);
+        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+
+        final ResultSet results2 = client.submit("x[0]+1");
+        assertEquals(2, results2.all().get().get(0).getInt());
+
+        // explicitly close the session
+        client.close();
+
+        // wait past automatic session expiration
+        Thread.sleep(3500);
+
+        try {
+            // the original session should be dead so this call will open a new session with the same name but fail
+            // because the state is now gone - x is an invalid property
+            client.submit("x[1]+2").all().get();
+            fail("Session should be dead");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(ConnectionException.class));
+        } finally {
+            cluster.close();
+        }
+
+        assertEquals(1, recordingAppender.getMessages().stream()
+                .filter(msg -> msg.equals("INFO - Session shouldCloseSessionOnceOnRequest closed\n")).count());
+    }
+
+    @Test
+    public void shouldHaveTheSessionTimeout() 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]");
+        final AtomicInteger counter = new AtomicInteger(0);
+        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+
+        final ResultSet results2 = client.submit("x[0]+1");
+        assertEquals(2, results2.all().get().get(0).getInt());
+
+        // session times out in 3 seconds
+        Thread.sleep(3500);
+
+        try {
+            // the original session should be dead so this call will open a new session with the same name but fail
+            // because the state is now gone - x is an invalid property
+            client.submit("x[1]+2").all().get();
+            fail("Session should be dead");
+        } catch (Exception ex) {
+            final Exception cause = (Exception) ex.getCause().getCause();
+            assertTrue(cause instanceof ResponseException);
+            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, ((ResponseException) cause).getResponseStatusCode());
+
+            // validate that we can still send messages to the server
+            assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
+        } finally {
+            cluster.close();
+        }
+
+        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 Client client = cluster.connect(name.getMethodName());
+
+        client.submitAsync("a=100;b=1000;c=10000;null");
+        final int requests = 1000;
+        final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
+        IntStream.range(0, requests).forEach(i -> {
+            try {
+                futures.add(client.submitAsync("a+b+c"));
+            } catch (Exception ex) {
+                throw new RuntimeException(ex);
+            }
+        });
+
+        assertEquals(requests, futures.size());
+
+        for(CompletableFuture<ResultSet> f : futures) {
+            final Result r = f.get().one();
+            assertEquals(11100, r.getInt());
+        }
+
+        client.close();
+        cluster.close();
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient() throws Exception {
+        assumeNeo4jIsPresent();
+
+        try (final SimpleClient client = new WebSocketClient()) {
+
+            //open a transaction, create a vertex, commit
+            final RequestMessage openRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().open()")
+                    .create();
+            final List<ResponseMessage> openResponses = client.submit(openRequest);
+            assertEquals(1, openResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, openResponses.get(0).getStatus().getCode());
+
+            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
+                    .create();
+            final List<ResponseMessage> addResponses = client.submit(addRequest);
+            assertEquals(1, addResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
+
+            final RequestMessage commitRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().commit()")
+                    .create();
+            final List<ResponseMessage> commitResponses = client.submit(commitRequest);
+            assertEquals(1, commitResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, commitResponses.get(0).getStatus().getCode());
+
+            // Check to see if the transaction is closed.
+            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
+                    .create();
+            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
+            assertEquals(1, checkResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
+            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
+
+            //lets run a sessionless read
+            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V()")
+                    .create();
+            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
+            assertEquals(1, sessionlessResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
+
+            // Check to see if the transaction is still closed.
+            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
+                    .create();
+            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
+            assertEquals(1, checkAgainstResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
+            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
+        }
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void shouldExecuteInSessionWithTransactionManagement() throws Exception {
+        assumeNeo4jIsPresent();
+
+        try (final SimpleClient client = new WebSocketClient()) {
+            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
+                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
+                    .create();
+            final List<ResponseMessage> addResponses = client.submit(addRequest);
+            assertEquals(1, addResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
+
+            // Check to see if the transaction is closed.
+            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
+                    .create();
+            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
+            assertEquals(1, checkResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
+            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
+
+            // lets run a sessionless read and validate that the transaction was managed
+            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V().values('name')")
+                    .create();
+            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
+            assertEquals(1, sessionlessResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
+            assertEquals("stephen", ((List<String>) sessionlessResponses.get(0).getResult().getData()).get(0));
+
+            // make sure the session is intact
+            final RequestMessage getRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "v.values(\"name\")")
+                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
+                    .create();
+            final List<ResponseMessage> getResponses = client.submit(getRequest);
+            assertEquals(1, getResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, getResponses.get(0).getStatus().getCode());
+            assertEquals("stephen", ((List<String>) getResponses.get(0).getResult().getData()).get(0));
+
+            // Check to see if the transaction is still closed.
+            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
+                    .processor("session")
+                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
+                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
+                    .create();
+            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
+            assertEquals(1, checkAgainstResponses.size());
+            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
+            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
+        }
+    }
+}


[14/18] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-1160' into tp31

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

Conflicts:
	CHANGELOG.asciidoc


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

Branch: refs/heads/master
Commit: 712fca2515a0d619368393df12ec3d951b50a392
Parents: 9bac3f9 5944ee6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 8 14:39:49 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 8 14:39:49 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../src/reference/gremlin-applications.asciidoc |  39 +++++-
 .../upgrade/release-3.1.x-incubating.asciidoc   |   9 ++
 .../apache/tinkerpop/gremlin/driver/Client.java |   1 -
 .../tinkerpop/gremlin/driver/Cluster.java       |  12 ++
 .../tinkerpop/gremlin/driver/Connection.java    |  14 ++-
 .../tinkerpop/gremlin/driver/Settings.java      | 120 ++++++++++++++++++-
 7 files changed, 189 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/712fca25/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index c530023,6987b2e..dda6e80
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,10 -26,7 +26,11 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* Bump to commons-collections 3.2.2.
 +* Fixed a compilation bug in `TraversalExplanation`.
 +* Fixed bug where a session explicitly closed was being closed again by session expiration.
 +* Improved the recovery options for Gremlin Driver after failed requests to Gremlin Server.
+ * Added `maxWaitForSessionClose` to the settings for Gremlin Driver.
  * Bumped to Netty 4.0.34.Final.
  * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
  * Bumped to Apache Groovy 2.4.6.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/712fca25/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
----------------------------------------------------------------------
diff --cc gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
index 10d3b89,a3b8ff3..08ba352
--- 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
@@@ -238,18 -216,9 +241,18 @@@ final class Connection 
          }
      }
  
 +    /**
 +     * Close was signaled in closeAsync() but there were pending messages at that time. This method attempts the
 +     * shutdown if the returned result cleared up the last pending message.
 +     */
 +    private void tryShutdown() {
 +        if (isClosed() && pending.isEmpty())
 +            shutdown(closeFuture.get());
 +    }
 +
      private void shutdown(final CompletableFuture<Void> future) {
          // shutdown can be called directly from closeAsync() or after write() and therefore this method should only
-         // be called once. once shutdown is initiated, it shoudln't be executed a second time or else it sends more
+         // be called once. once shutdown is initiated, it shouldn't be executed a second time or else it sends more
          // messages at the server and leads to ugly log messages over there.
          if (shutdownInitiated.compareAndSet(false, true)) {
              if (client instanceof Client.SessionedClient) {


[11/18] incubator-tinkerpop git commit: Bump to commons-collections 3.2.2 TINKERPOP-1198 CTR

Posted by ok...@apache.org.
Bump to commons-collections 3.2.2 TINKERPOP-1198 CTR


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

Branch: refs/heads/master
Commit: 753038d1010f8bd5974924733579d3c0cfd9773e
Parents: b529398
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 8 07:15:35 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 8 07:15:35 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc     | 1 +
 gremlin-core/pom.xml   | 1 -
 gremlin-server/pom.xml | 1 -
 pom.xml                | 8 ++++++--
 4 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/753038d1/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a39683a..aad3314 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Bump to commons-collections 3.2.2.
 * Fixed a compilation bug in `TraversalExplanation`.
 * Bumped to Netty 4.0.34.Final.
 * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/753038d1/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index 16a0f89..c164750 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -95,7 +95,6 @@ limitations under the License.
         <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/753038d1/gremlin-server/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-server/pom.xml b/gremlin-server/pom.xml
index 2c9c1f8..37d830d 100644
--- a/gremlin-server/pom.xml
+++ b/gremlin-server/pom.xml
@@ -44,7 +44,6 @@ limitations under the License.
         <dependency>
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
-            <version>3.2.1</version>
         </dependency>
         <!-- METRICS -->
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/753038d1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f7bf141..acef6c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,7 +135,6 @@ limitations under the License.
         <skipPerformanceTests>true</skipPerformanceTests>
         <slf4j.version>1.7.12</slf4j.version>
         <hadoop.version>2.7.1</hadoop.version>
-        <commons.configuration.version>1.10</commons.configuration.version>
         <java.tuples.version>1.2</java.tuples.version>
         <javadoc-plugin.version>2.10.1</javadoc-plugin.version>
 
@@ -477,7 +476,7 @@ limitations under the License.
             <dependency>
                 <groupId>commons-configuration</groupId>
                 <artifactId>commons-configuration</artifactId>
-                <version>${commons.configuration.version}</version>
+                <version>1.10</version>
                 <exclusions>
                     <!-- self-conflict -->
                     <exclusion>
@@ -487,6 +486,11 @@ limitations under the License.
                 </exclusions>
             </dependency>
             <dependency>
+                <groupId>commons-collections</groupId>
+                <artifactId>commons-collections</artifactId>
+                <version>3.2.2</version>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-core</artifactId>
                 <version>1.2.1</version>


[04/18] incubator-tinkerpop git commit: Update changelog.

Posted by ok...@apache.org.
Update changelog.


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

Branch: refs/heads/master
Commit: 0ff4e8285a939e75c66636057c9cc287cc1cba64
Parents: 9e1b5b1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 1 17:56:42 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 1 17:56:42 2016 -0500

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


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0ff4e828/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 009b69b..a54fffd 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Improved the recovery options for Gremlin Driver after failed requests to Gremlin Server.
 * Bumped to Netty 4.0.34.Final.
 * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
 * Bumped to Apache Groovy 2.4.6.


[17/18] incubator-tinkerpop git commit: Merge branch 'tp31'

Posted by ok...@apache.org.
Merge branch 'tp31'


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

Branch: refs/heads/master
Commit: c4b968018cc2f9bdaf7a058cd12db3963b837e72
Parents: c06096b 24cae1f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Mar 9 12:30:45 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Mar 9 12:30:45 2016 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   5 +
 .../src/reference/gremlin-applications.asciidoc |  39 ++-
 .../upgrade/release-3.1.x-incubating.asciidoc   |   9 +
 gremlin-core/pom.xml                            |   1 -
 .../traversal/step/map/OrderGlobalStep.java     |   2 +-
 .../traversal/step/map/OrderLocalStep.java      |   2 +-
 .../apache/tinkerpop/gremlin/driver/Client.java |   1 -
 .../tinkerpop/gremlin/driver/Cluster.java       |  12 +
 .../tinkerpop/gremlin/driver/Connection.java    |  54 ++-
 .../gremlin/driver/ConnectionPool.java          |   2 +-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |   5 +-
 .../tinkerpop/gremlin/driver/Settings.java      | 120 ++++++-
 .../traversal/step/map/GroovyCountTest.groovy   |   5 +
 gremlin-server/pom.xml                          |   1 -
 .../gremlin/server/op/session/Session.java      |  37 ++-
 .../server/op/session/SessionOpProcessor.java   |   4 +-
 .../server/GremlinDriverIntegrateTest.java      |   1 +
 .../server/GremlinServerIntegrateTest.java      | 197 +----------
 .../GremlinServerSessionIntegrateTest.java      | 332 +++++++++++++++++++
 .../process/traversal/step/map/CountTest.java   |  35 +-
 pom.xml                                         |   8 +-
 21 files changed, 649 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/gremlin-core/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderGlobalStep.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/OrderLocalStep.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
----------------------------------------------------------------------
diff --cc gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
index 898f16c,d617a3d..13515cd
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
@@@ -65,7 -65,12 +65,12 @@@ public abstract class GroovyCountTest 
  
          @Override
          public Traversal<Vertex, Long> get_g_V_fold_countXlocalX() {
 -            TraversalScriptHelper.compute("g.V.fold.count(local)", g);
 +            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.fold.count(local)")
          }
+ 
+         @Override
+         public Traversal<Vertex, String> get_g_V_both_both_order_byXcount_decrX_name() {
+             TraversalScriptHelper.compute("g.V.both.both.order.by(count(), decr).name", g);
+         }
      }
  }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/gremlin-server/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c4b96801/pom.xml
----------------------------------------------------------------------


[13/18] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-956' into tp31

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

Conflicts:
	CHANGELOG.asciidoc
	gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java


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

Branch: refs/heads/master
Commit: 9bac3f96af8954bd66b1d99bbd064d43b3beebde
Parents: a279648 0ff4e82
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 8 11:06:09 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 8 11:06:09 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../tinkerpop/gremlin/driver/Connection.java    | 40 ++++++++++++++++++--
 .../gremlin/driver/ConnectionPool.java          |  2 +-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |  5 +--
 .../server/GremlinDriverIntegrateTest.java      |  1 +
 .../server/GremlinServerIntegrateTest.java      | 12 ++++--
 .../GremlinServerSessionIntegrateTest.java      |  4 +-
 7 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9bac3f96/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 1a2e116,a54fffd..c530023
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,9 -26,7 +26,10 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* Bump to commons-collections 3.2.2.
 +* Fixed a compilation bug in `TraversalExplanation`.
 +* Fixed bug where a session explicitly closed was being closed again by session expiration.
+ * Improved the recovery options for Gremlin Driver after failed requests to Gremlin Server.
  * Bumped to Netty 4.0.34.Final.
  * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
  * Bumped to Apache Groovy 2.4.6.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9bac3f96/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9bac3f96/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
----------------------------------------------------------------------
diff --cc gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSessionIntegrateTest.java
index cfdb877,0000000..70d9e97
mode 100644,000000..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
@@@ -1,332 -1,0 +1,332 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.tinkerpop.gremlin.server;
 +
 +import org.apache.commons.lang.exception.ExceptionUtils;
 +import org.apache.log4j.Level;
 +import org.apache.log4j.Logger;
 +import org.apache.tinkerpop.gremlin.driver.Client;
 +import org.apache.tinkerpop.gremlin.driver.Cluster;
 +import org.apache.tinkerpop.gremlin.driver.Result;
 +import org.apache.tinkerpop.gremlin.driver.ResultSet;
 +import org.apache.tinkerpop.gremlin.driver.Tokens;
 +import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
 +import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
 +import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 +import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 +import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 +import org.apache.tinkerpop.gremlin.driver.simple.SimpleClient;
 +import org.apache.tinkerpop.gremlin.driver.simple.WebSocketClient;
 +import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
 +import org.apache.tinkerpop.gremlin.util.Log4jRecordingAppender;
 +import org.junit.After;
 +import org.junit.Before;
 +import org.junit.Test;
 +
 +import java.io.File;
 +import java.util.ArrayList;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.concurrent.CompletableFuture;
 +import java.util.concurrent.atomic.AtomicInteger;
 +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;
 +
 +/**
 + * @author Stephen Mallette (http://stephen.genoprime.com)
 + */
 +public class GremlinServerSessionIntegrateTest  extends AbstractGremlinServerIntegrationTest {
 +    private Log4jRecordingAppender recordingAppender = null;
 +    private Level originalLevel;
 +
 +    @Before
 +    public void setupForEachTest() {
 +        recordingAppender = new Log4jRecordingAppender();
 +        final Logger rootLogger = Logger.getRootLogger();
 +        rootLogger.addAppender(recordingAppender);
 +        originalLevel = rootLogger.getLevel();
 +    }
 +
 +    @After
 +    public void teardownForEachTest() {
 +        final Logger rootLogger = Logger.getRootLogger();
 +        rootLogger.removeAppender(recordingAppender);
 +        rootLogger.setLevel(originalLevel);
 +    }
 +
 +    /**
 +     * Configure specific Gremlin Server settings for specific tests.
 +     */
 +    @Override
 +    public Settings overrideSettings(final Settings settings) {
 +        final String nameOfTest = name.getMethodName();
 +        switch (nameOfTest) {
 +            case "shouldHaveTheSessionTimeout":
 +            case "shouldCloseSessionOnceOnRequest":
 +                settings.processors.clear();
 +                final Settings.ProcessorSettings processorSettings = new Settings.ProcessorSettings();
 +                processorSettings.className = SessionOpProcessor.class.getCanonicalName();
 +                processorSettings.config = new HashMap<>();
 +                processorSettings.config.put(SessionOpProcessor.CONFIG_SESSION_TIMEOUT, 3000L);
 +                settings.processors.add(processorSettings);
 +
 +                Logger.getRootLogger().setLevel(Level.INFO);
 +                break;
 +            case "shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient":
 +            case "shouldExecuteInSessionWithTransactionManagement":
 +                deleteDirectory(new File("/tmp/neo4j"));
 +                settings.graphs.put("graph", "conf/neo4j-empty.properties");
 +                break;
 +        }
 +
 +        return settings;
 +    }
 +
 +    @Test
 +    public void shouldCloseSessionOnceOnRequest() 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]");
 +        final AtomicInteger counter = new AtomicInteger(0);
 +        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
 +
 +        final ResultSet results2 = client.submit("x[0]+1");
 +        assertEquals(2, results2.all().get().get(0).getInt());
 +
 +        // explicitly close the session
 +        client.close();
 +
 +        // wait past automatic session expiration
 +        Thread.sleep(3500);
 +
 +        try {
 +            // the original session should be dead so this call will open a new session with the same name but fail
 +            // because the state is now gone - x is an invalid property
 +            client.submit("x[1]+2").all().get();
 +            fail("Session should be dead");
 +        } catch (Exception ex) {
 +            final Throwable root = ExceptionUtils.getRootCause(ex);
 +            assertThat(root, instanceOf(ConnectionException.class));
 +        } finally {
 +            cluster.close();
 +        }
 +
 +        assertEquals(1, recordingAppender.getMessages().stream()
 +                .filter(msg -> msg.equals("INFO - Session shouldCloseSessionOnceOnRequest closed\n")).count());
 +    }
 +
 +    @Test
 +    public void shouldHaveTheSessionTimeout() 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]");
 +        final AtomicInteger counter = new AtomicInteger(0);
 +        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
 +
 +        final ResultSet results2 = client.submit("x[0]+1");
 +        assertEquals(2, results2.all().get().get(0).getInt());
 +
 +        // session times out in 3 seconds
 +        Thread.sleep(3500);
 +
 +        try {
 +            // the original session should be dead so this call will open a new session with the same name but fail
 +            // because the state is now gone - x is an invalid property
 +            client.submit("x[1]+2").all().get();
 +            fail("Session should be dead");
 +        } catch (Exception ex) {
-             final Exception cause = (Exception) ex.getCause().getCause();
-             assertTrue(cause instanceof ResponseException);
++            final Throwable cause = ExceptionUtils.getCause(ex);
++            assertThat(cause, instanceOf(ResponseException.class));
 +            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, ((ResponseException) cause).getResponseStatusCode());
 +
 +            // validate that we can still send messages to the server
 +            assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
 +        } finally {
 +            cluster.close();
 +        }
 +
 +        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 Client client = cluster.connect(name.getMethodName());
 +
 +        client.submitAsync("a=100;b=1000;c=10000;null");
 +        final int requests = 1000;
 +        final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
 +        IntStream.range(0, requests).forEach(i -> {
 +            try {
 +                futures.add(client.submitAsync("a+b+c"));
 +            } catch (Exception ex) {
 +                throw new RuntimeException(ex);
 +            }
 +        });
 +
 +        assertEquals(requests, futures.size());
 +
 +        for(CompletableFuture<ResultSet> f : futures) {
 +            final Result r = f.get().one();
 +            assertEquals(11100, r.getInt());
 +        }
 +
 +        client.close();
 +        cluster.close();
 +    }
 +
 +    @Test
 +    @SuppressWarnings("unchecked")
 +    public void shouldExecuteInSessionAndSessionlessWithoutOpeningTransactionWithSingleClient() throws Exception {
 +        assumeNeo4jIsPresent();
 +
 +        try (final SimpleClient client = new WebSocketClient()) {
 +
 +            //open a transaction, create a vertex, commit
 +            final RequestMessage openRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().open()")
 +                    .create();
 +            final List<ResponseMessage> openResponses = client.submit(openRequest);
 +            assertEquals(1, openResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, openResponses.get(0).getStatus().getCode());
 +
 +            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
 +                    .create();
 +            final List<ResponseMessage> addResponses = client.submit(addRequest);
 +            assertEquals(1, addResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
 +
 +            final RequestMessage commitRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().commit()")
 +                    .create();
 +            final List<ResponseMessage> commitResponses = client.submit(commitRequest);
 +            assertEquals(1, commitResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, commitResponses.get(0).getStatus().getCode());
 +
 +            // Check to see if the transaction is closed.
 +            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
 +                    .create();
 +            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
 +            assertEquals(1, checkResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
 +            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
 +
 +            //lets run a sessionless read
 +            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V()")
 +                    .create();
 +            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
 +            assertEquals(1, sessionlessResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
 +
 +            // Check to see if the transaction is still closed.
 +            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
 +                    .create();
 +            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
 +            assertEquals(1, checkAgainstResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
 +            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
 +        }
 +    }
 +
 +    @Test
 +    @SuppressWarnings("unchecked")
 +    public void shouldExecuteInSessionWithTransactionManagement() throws Exception {
 +        assumeNeo4jIsPresent();
 +
 +        try (final SimpleClient client = new WebSocketClient()) {
 +            final RequestMessage addRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "v=graph.addVertex(\"name\",\"stephen\")")
 +                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
 +                    .create();
 +            final List<ResponseMessage> addResponses = client.submit(addRequest);
 +            assertEquals(1, addResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, addResponses.get(0).getStatus().getCode());
 +
 +            // Check to see if the transaction is closed.
 +            final RequestMessage checkRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
 +                    .create();
 +            final List<ResponseMessage> checkResponses = client.submit(checkRequest);
 +            assertEquals(1, checkResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, checkResponses.get(0).getStatus().getCode());
 +            assertThat(((List<Boolean>) checkResponses.get(0).getResult().getData()).get(0), is(false));
 +
 +            // lets run a sessionless read and validate that the transaction was managed
 +            final RequestMessage sessionlessRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.traversal().V().values('name')")
 +                    .create();
 +            final List<ResponseMessage> sessionlessResponses = client.submit(sessionlessRequest);
 +            assertEquals(1, sessionlessResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, sessionlessResponses.get(0).getStatus().getCode());
 +            assertEquals("stephen", ((List<String>) sessionlessResponses.get(0).getResult().getData()).get(0));
 +
 +            // make sure the session is intact
 +            final RequestMessage getRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "v.values(\"name\")")
 +                    .addArg(Tokens.ARGS_MANAGE_TRANSACTION, true)
 +                    .create();
 +            final List<ResponseMessage> getResponses = client.submit(getRequest);
 +            assertEquals(1, getResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, getResponses.get(0).getStatus().getCode());
 +            assertEquals("stephen", ((List<String>) getResponses.get(0).getResult().getData()).get(0));
 +
 +            // Check to see if the transaction is still closed.
 +            final RequestMessage checkAgainRequest = RequestMessage.build(Tokens.OPS_EVAL)
 +                    .processor("session")
 +                    .addArg(Tokens.ARGS_SESSION, name.getMethodName())
 +                    .addArg(Tokens.ARGS_GREMLIN, "graph.tx().isOpen()")
 +                    .create();
 +            final List<ResponseMessage> checkAgainstResponses = client.submit(checkAgainRequest);
 +            assertEquals(1, checkAgainstResponses.size());
 +            assertEquals(ResponseStatusCode.SUCCESS, checkAgainstResponses.get(0).getStatus().getCode());
 +            assertThat(((List<Boolean>) checkAgainstResponses.get(0).getResult().getData()).get(0), is(false));
 +        }
 +    }
 +}


[16/18] incubator-tinkerpop git commit: remerged.

Posted by ok...@apache.org.
remerged.


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

Branch: refs/heads/master
Commit: 24cae1f5633aa731f26f616ae00708d05e21ca78
Parents: 3eadf73 712fca2
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Mar 9 12:19:58 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Mar 9 12:19:58 2016 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   4 +
 .../src/reference/gremlin-applications.asciidoc |  39 ++-
 .../upgrade/release-3.1.x-incubating.asciidoc   |   9 +
 gremlin-core/pom.xml                            |   1 -
 .../apache/tinkerpop/gremlin/driver/Client.java |   1 -
 .../tinkerpop/gremlin/driver/Cluster.java       |  12 +
 .../tinkerpop/gremlin/driver/Connection.java    |  54 ++-
 .../gremlin/driver/ConnectionPool.java          |   2 +-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |   5 +-
 .../tinkerpop/gremlin/driver/Settings.java      | 120 ++++++-
 gremlin-server/pom.xml                          |   1 -
 .../gremlin/server/op/session/Session.java      |  37 ++-
 .../server/op/session/SessionOpProcessor.java   |   4 +-
 .../server/GremlinDriverIntegrateTest.java      |   1 +
 .../server/GremlinServerIntegrateTest.java      | 197 +----------
 .../GremlinServerSessionIntegrateTest.java      | 332 +++++++++++++++++++
 pom.xml                                         |   8 +-
 17 files changed, 609 insertions(+), 218 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/24cae1f5/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 54df044,dda6e80..1829c5c
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,8 -26,11 +26,12 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* Fixed a bug where `OrderGlobalStep` and `OrderLocalStep` were not incorporating their children's traverser requirements.
+ * Bump to commons-collections 3.2.2.
  * Fixed a compilation bug in `TraversalExplanation`.
+ * Fixed bug where a session explicitly closed was being closed again by session expiration.
+ * Improved the recovery options for Gremlin Driver after failed requests to Gremlin Server.
+ * Added `maxWaitForSessionClose` to the settings for Gremlin Driver.
  * Bumped to Netty 4.0.34.Final.
  * Added "interpreter mode" for the `ScriptEngine` and Gremlin Server which allows variables defined with `def` or a type to be recognized as "global".
  * Bumped to Apache Groovy 2.4.6.


[09/18] incubator-tinkerpop git commit: Allowed maxWaitForSessionClose to get assigned from the Cluster builder.

Posted by ok...@apache.org.
Allowed maxWaitForSessionClose to get assigned from the Cluster builder.

This setting was defined through Settings but were not passed along to the Cluster builder.


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

Branch: refs/heads/master
Commit: 7ebd46cd5fc78e6ce0e6ea58ba1d2cb999284c10
Parents: d07eb59
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 16:34:14 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 16:34:14 2016 -0500

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/driver/Cluster.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7ebd46cd/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
index b29cc95..02181e2 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
@@ -278,6 +278,7 @@ public final class Cluster {
         private int maxInProcessPerConnection = Connection.MAX_IN_PROCESS;
         private int minInProcessPerConnection = Connection.MIN_IN_PROCESS;
         private int maxWaitForConnection = Connection.MAX_WAIT_FOR_CONNECTION;
+        private int maxWaitForSessionClose = Connection.MAX_WAIT_FOR_SESSION_CLOSE;
         private int maxContentLength = Connection.MAX_CONTENT_LENGTH;
         private int reconnectInitialDelay = Connection.RECONNECT_INITIAL_DELAY;
         private int reconnectInterval = Connection.RECONNECT_INTERVAL;
@@ -442,6 +443,16 @@ public final class Cluster {
         }
 
         /**
+         * If the connection is using a "session" this setting represents the amount of time in milliseconds to wait
+         * for that session to close before timing out where the default value is 3000. Note that the server will
+         * eventually clean up dead sessions itself on expiration of the session or during shutdown.
+         */
+        public Builder maxWaitForSessionClose(final int maxWait) {
+            this.maxWaitForSessionClose = maxWait;
+            return this;
+        }
+
+        /**
          * The maximum size in bytes of any request sent to the server.   This number should not exceed the same
          * setting defined on the server.
          */
@@ -569,6 +580,7 @@ public final class Cluster {
             connectionPoolSettings.maxSize = this.maxConnectionPoolSize;
             connectionPoolSettings.minSize = this.minConnectionPoolSize;
             connectionPoolSettings.maxWaitForConnection = this.maxWaitForConnection;
+            connectionPoolSettings.maxWaitForSessionClose = this.maxWaitForSessionClose;
             connectionPoolSettings.maxContentLength = this.maxContentLength;
             connectionPoolSettings.reconnectInitialDelay = this.reconnectInitialDelay;
             connectionPoolSettings.reconnectInterval = this.reconnectInterval;


[08/18] incubator-tinkerpop git commit: The default serializer for settings was not congruent with Cluster.

Posted by ok...@apache.org.
The default serializer for settings was not congruent with Cluster.

Made the default for Settings to be gryo like Cluster.


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

Branch: refs/heads/master
Commit: d07eb59b6633bba3ba27b4a6f26acc5f4ca64c23
Parents: 90b3117
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 2 16:32:46 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Mar 2 16:32:46 2016 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/tinkerpop/gremlin/driver/Settings.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d07eb59b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
index fb85910..4daa223 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
@@ -18,7 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.driver;
 
-import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
 import org.yaml.snakeyaml.TypeDescription;
 import org.yaml.snakeyaml.Yaml;
 import org.yaml.snakeyaml.constructor.Constructor;
@@ -219,7 +219,7 @@ final class Settings {
          * The fully qualified class name of the {@link MessageSerializer} that will be used to communicate with the
          * server. Note that the serializer configured on the client should be supported by the server configuration.
          */
-        public String className = GraphSONMessageSerializerV1d0.class.getCanonicalName();
+        public String className = GryoMessageSerializerV1d0.class.getCanonicalName();
 
         /**
          * The configuration for the specified serializer with the {@link #className}.