You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/09/25 00:07:51 UTC

[01/22] tinkerpop git commit: Fixes incorrect usage of

Repository: tinkerpop
Updated Branches:
  refs/heads/master 897174158 -> d1a3fa147


Fixes incorrect usage of <inheritdoc />


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

Branch: refs/heads/master
Commit: 5eac32efb135520f2d0c844bd085df5204b7920c
Parents: cbc2b68
Author: Patrik Husfloen <re...@redoz.com>
Authored: Thu Sep 13 23:58:32 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5eac32ef/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 62a0b3c..55a8661 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -51,19 +51,19 @@ namespace Gremlin.Net.Driver
             this.StatusAttributes = attributes;
         }
 
-        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
+        /// <inheritdoc />
         public IEnumerator<T> GetEnumerator()
         {
             return _data.GetEnumerator();
         }
 
-        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
+        /// <inheritdoc />
         IEnumerator IEnumerable.GetEnumerator()
         {
             return _data.GetEnumerator();
         }
 
-        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
+        /// <inheritdoc />
         public int Count => _data.Count;
     }
 }


[08/22] tinkerpop git commit: Tweaks xml doc comment formatting to match existing code.

Posted by sp...@apache.org.
Tweaks xml doc comment formatting to match existing code.


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

Branch: refs/heads/master
Commit: cbc2b68959842a3a01b9f776ed42486d3a135684
Parents: c720dba
Author: Patrik Husfloen <re...@redoz.com>
Authored: Thu Sep 13 23:39:19 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../Driver/Exceptions/ResponseException.cs      |  6 ++--
 .../Driver/Messages/ResponseStatusCode.cs       | 34 +++++++++++++-------
 .../src/Gremlin.Net/Driver/ResultSet.cs         | 17 ++++------
 3 files changed, 32 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbc2b689/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
index f9020d2..59ac1aa 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
@@ -42,17 +42,17 @@ namespace Gremlin.Net.Driver.Exceptions
                                  IReadOnlyDictionary<string, object> statusAttributes,
                                  string message) : base(message)
         {
-            StatusAttributes = statusAttributes;
             StatusCode = statusCode;
+            StatusAttributes = statusAttributes;
         }
 
         /// <summary>
-        /// Gets the status code returned from the server.
+        ///     Gets the status code returned from the server.
         /// </summary>
         public ResponseStatusCode StatusCode { get; }
 
         /// <summary>
-        /// Gets the status attributes from the gremlin response
+        ///     Gets the status attributes from the gremlin response
         /// </summary>
         public IReadOnlyDictionary<string, object> StatusAttributes { get; }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbc2b689/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
index 1c5d088..78f8759 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
@@ -26,62 +26,72 @@ using System;
 namespace Gremlin.Net.Driver.Messages
 {
     /// <summary>
-    /// Represents the various status codes that Gremlin Server returns.
+    ///     Represents the various status codes that Gremlin Server returns.
     /// </summary>
     public enum ResponseStatusCode
     {
         /// <summary>
-        /// The server successfully processed a request to completion - there are no messages remaining in this stream.
+        ///     The server successfully processed a request to completion - there are no messages remaining in this
+        ///     stream.
         /// </summary>
         Success = 200,
         
         /// <summary>
-        /// The server processed the request but there is no result to return (e.g. an Iterator with no elements) - there are no messages remaining in this stream.
+        ///     The server processed the request but there is no result to return (e.g. an Iterator with no elements)
+        ///     - there are no messages remaining in this stream.
         /// </summary>
         NoContent = 204,
         
         /// <summary>
-        /// The server successfully returned some content, but there is more in the stream to arrive - wait for a SUCCESS to signify the end of the stream.
+        ///     The server successfully returned some content, but there is more in the stream to arrive - wait for a
+        ///     SUCCESS to signify the end of the stream.
         /// </summary>
         PartialContent = 206,
 
         /// <summary>
-        /// The request attempted to access resources that the requesting user did not have access to.
+        ///     The request attempted to access resources that the requesting user did not have access to.
         /// </summary>
         Unauthorized = 401,
 
         /// <summary>
-        /// A challenge from the server for the client to authenticate its request.
+        ///     A challenge from the server for the client to authenticate its request.
         /// </summary>
         Authenticate = 407,
 
         /// <summary>
-        /// The request message was not properly formatted which means it could not be parsed at all or the "op" code was not recognized such that Gremlin Server could properly route it for processing. Check the message format and retry the request.
+        ///     The request message was not properly formatted which means it could not be parsed at all or the "op" code
+        ///     was not recognized such that Gremlin Server could properly route it for processing. Check the message format
+        ///     and retry the request.
         /// </summary>
         MalformedRequest = 498,
 
         /// <summary>
-        /// The request message was parseable, but the arguments supplied in the message were in conflict or incomplete. Check the message format and retry the request.
+        ///     The request message was parseable, but the arguments supplied in the message were in conflict or incomplete.
+        ///     Check the message format and retry the request.
         /// </summary>
         InvalidRequestArguments = 499,
 
         /// <summary>
-        /// A general server error occurred that prevented the request from being processed.
+        ///     A general server error occurred that prevented the request from being processed.
         /// </summary>
         ServerError = 500,
 
         /// <summary>
-        /// The script submitted for processing evaluated in the ScriptEngine with errors and could not be processed. Check the script submitted for syntax errors or other problems and then resubmit.
+        ///     The script submitted for processing evaluated in the ScriptEngine with errors and could not be processed.
+        ///     Check the script submitted for syntax errors or other problems and then resubmit.
         /// </summary>
         ScriptEvaluationError = 597,
 
         /// <summary>
-        /// The server exceeded one of the timeout settings for the request and could therefore only partially responded or did not respond at all.
+        ///     The server exceeded one of the timeout settings for the request and could therefore only partially responded
+        ///     or did not respond at all.
         /// </summary>
         ServerTimeout = 598,
 
         /// <summary>
-        /// The server was not capable of serializing an object that was returned from the script supplied on the request. Either transform the object into something Gremlin Server can process within the script or install mapper serialization classes to Gremlin Server.
+        ///     The server was not capable of serializing an object that was returned from the script supplied on the request.
+        ///     Either transform the object into something Gremlin Server can process within the script or install mapper
+        ///     serialization classes to Gremlin Server.
         /// </summary>
         ServerSerializationError = 599
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbc2b689/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 00a24d3..62a0b3c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -27,8 +27,8 @@ using System.Collections.Generic;
 namespace Gremlin.Net.Driver
 {
     /// <summary>
-    /// A ResultSet is returned from the submission of a Gremlin script to the server and represents the results provided by the server
-    /// ResultSet includes enumerable data and status attributes.
+    ///     A ResultSet is returned from the submission of a Gremlin script to the server and represents the results
+    ///     provided by the server. ResultSet includes enumerable data and status attributes.
     /// </summary>
     /// <typeparam name="T">Type of the result elements</typeparam>
     public sealed class ResultSet<T> : IReadOnlyCollection<T>
@@ -36,12 +36,12 @@ namespace Gremlin.Net.Driver
         private readonly IReadOnlyCollection<T> _data;
 
         /// <summary>
-        /// Gets or sets the status attributes from the gremlin response
+        ///     Gets or sets the status attributes from the gremlin response
         /// </summary>
         public IReadOnlyDictionary<string, object> StatusAttributes { get; }
 
         /// <summary>
-        /// Initializes a new instance of the ResultSet class for the specified data and status attributes.
+        ///     Initializes a new instance of the ResultSet class for the specified data and status attributes.
         /// </summary>
         /// <param name="data"></param>
         /// <param name="attributes"></param>
@@ -51,22 +51,19 @@ namespace Gremlin.Net.Driver
             this.StatusAttributes = attributes;
         }
 
-        /// <summary>Returns an enumerator that iterates through the collection.</summary>
-        /// <returns>An enumerator that can be used to iterate through the collection.</returns>
+        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
         public IEnumerator<T> GetEnumerator()
         {
             return _data.GetEnumerator();
         }
 
-        /// <summary>Returns an enumerator that iterates through a collection.</summary>
-        /// <returns>An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.</returns>
+        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
         IEnumerator IEnumerable.GetEnumerator()
         {
             return _data.GetEnumerator();
         }
 
-        /// <summary>Gets the number of elements in the collection.</summary>
-        /// <returns>The number of elements in the collection. </returns>
+        /// <inheritdoc cref="IReadOnlyCollection{T}"/>
         public int Count => _data.Count;
     }
 }


[19/22] tinkerpop git commit: TINKERPOP-1913 GremlinServerError for python has status attributes now

Posted by sp...@apache.org.
TINKERPOP-1913 GremlinServerError for python has status attributes now


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

Branch: refs/heads/master
Commit: d457d7cba5a4a136597127c2793014bafa47b843
Parents: 49b1507
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 15:38:44 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 15:38:44 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                       |  1 +
 .../src/main/jython/gremlin_python/driver/protocol.py    | 11 ++++++++---
 .../src/main/jython/tests/driver/test_client.py          | 10 ++++++++++
 3 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d457d7cb/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 386f0d9..a151bc7 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -42,6 +42,7 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Modified remote traversals to retrieve status attributes from traversal side-effects.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
 * Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
+* Modified Python `GremlinServerError` to include status attributes.
 * Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
 * Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d457d7cb/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index 96174e0..c8e3e4a 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -31,7 +31,13 @@ __author__ = 'David M. Brown (davebshow@gmail.com)'
 
 
 class GremlinServerError(Exception):
-    pass
+    def __init__(self, status):
+        super(GremlinServerError, self).__init__("{0}: {1}".format(status["code"], status["message"]))
+        self._status_attributes = status["attributes"]
+
+    @property
+    def status_attributes(self):
+        return self._status_attributes        
 
 
 @six.add_metaclass(abc.ABCMeta)
@@ -95,5 +101,4 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
             return status_code
         else:
             del results_dict[request_id]
-            raise GremlinServerError(
-                "{0}: {1}".format(status_code, message["status"]["message"]))
+            raise GremlinServerError(message["status"])

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d457d7cb/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 44dc3a7..42e2c07 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -52,6 +52,16 @@ def test_client_eval_traversal(client):
     assert len(client.submit('g.V()').all().result()) == 6
 
 
+def test_client_error(client):
+    try:
+        # should fire an exception
+        client.submit('1/0').all().result()
+        assert False
+    except GremlinServerError as ex:
+        assert 'exceptions' in ex.status_attributes
+        assert 'stackTrace' in ex.status_attributes
+
+
 def test_client_bytecode(client):
     g = Graph().traversal()
     t = g.V()


[07/22] tinkerpop git commit: TINKERPOP-1913 Fixed compile error after rebase on master

Posted by sp...@apache.org.
TINKERPOP-1913 Fixed compile error after rebase on master


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

Branch: refs/heads/master
Commit: f7193c90a3cd1433961028e2e5ad7e330b08c339
Parents: 24e08d2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 16 09:24:21 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f7193c90/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java
index aba1603..8a3cc6d 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessorTest.java
@@ -39,7 +39,7 @@ public class AbstractOpProcessorTest {
 
         try {
             // Induce a NullPointerException to validate error response message writing
-            AbstractOpProcessor.makeFrame(ctx, request, null, true, null, ResponseStatusCode.PARTIAL_CONTENT, null);
+            AbstractOpProcessor.makeFrame(ctx, request, null, true, null, ResponseStatusCode.PARTIAL_CONTENT, null, null);
             fail("Expected a NullPointerException");
         } catch (NullPointerException expected) {
             // nop


[13/22] tinkerpop git commit: TINKERPOP-1913 ResponseException will have status attributes present

Posted by sp...@apache.org.
TINKERPOP-1913 ResponseException will have status attributes present


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

Branch: refs/heads/master
Commit: 956b177f7a62b45713bd7111f139c1140c974915
Parents: f7193c9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 16 10:38:48 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Handler.java       | 12 +++++++-
 .../driver/exception/ResponseException.java     | 31 +++++++++++++++-----
 2 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/956b177f/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
index 4a82f24..d79bed5 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
@@ -256,7 +256,7 @@ final class Handler {
                         final List<String> exceptions = attributes.containsKey(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS) ?
                                 (List<String>) attributes.get(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS) : null;
                         queue.markError(new ResponseException(response.getStatus().getCode(), response.getStatus().getMessage(),
-                                exceptions, stackTrace));
+                                exceptions, stackTrace, cleanStatusAttributes(attributes)));
                     }
                 }
 
@@ -270,6 +270,7 @@ final class Handler {
 
                 // as this is a non-PARTIAL_CONTENT code - the stream is done.
                 if (statusCode != ResponseStatusCode.PARTIAL_CONTENT) {
+                    queue.statusAttributes = response.getStatus().getAttributes();
                     pending.remove(response.getRequestId()).markComplete();
                 }
             } finally {
@@ -294,6 +295,15 @@ final class Handler {
             if (!IteratorUtils.anyMatch(ExceptionUtils.getThrowableList(cause).iterator(), t -> t instanceof SerializationException))
                 if (ctx.channel().isActive()) ctx.close();
         }
+
+        private Map<String,Object> cleanStatusAttributes(final Map<String,Object> statusAttributes) {
+            final Map<String,Object> m = new HashMap<>();
+            statusAttributes.forEach((k,v) -> {
+                if (!k.equals(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS) && !k.equals(Tokens.STATUS_ATTRIBUTE_STACK_TRACE))
+                    m.put(k,v);
+            });
+            return m;
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/956b177f/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/exception/ResponseException.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/exception/ResponseException.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/exception/ResponseException.java
index 51e748a..a960d44 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/exception/ResponseException.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/exception/ResponseException.java
@@ -20,27 +20,37 @@ package org.apache.tinkerpop.gremlin.driver.exception;
 
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class ResponseException extends Exception {
-    private ResponseStatusCode responseStatusCode;
-    private String remoteStackTrace = null;
-    private List<String> remoteExceptionHierarchy = null;
+    private final ResponseStatusCode responseStatusCode;
+    private final String remoteStackTrace;
+    private final List<String> remoteExceptionHierarchy;
+    private final Map<String,Object> attributes;
 
     public ResponseException(final ResponseStatusCode responseStatusCode, final String serverMessage) {
-        super(serverMessage);
-        this.responseStatusCode = responseStatusCode;
+        this(responseStatusCode, serverMessage, null, null);
     }
 
     public ResponseException(final ResponseStatusCode responseStatusCode, final String serverMessage,
                              final List<String> remoteExceptionHierarchy, final String remoteStackTrace) {
-        this(responseStatusCode, serverMessage);
-        this.remoteExceptionHierarchy = remoteExceptionHierarchy;
+        this(responseStatusCode, serverMessage, remoteExceptionHierarchy, remoteStackTrace, null);
+    }
+
+    public ResponseException(final ResponseStatusCode responseStatusCode, final String serverMessage,
+                             final List<String> remoteExceptionHierarchy, final String remoteStackTrace,
+                             final Map<String,Object> statusAttributes) {
+        super(serverMessage);
+        this.responseStatusCode = responseStatusCode;
+        this.remoteExceptionHierarchy = remoteExceptionHierarchy != null ? Collections.unmodifiableList(remoteExceptionHierarchy) : null;
         this.remoteStackTrace = remoteStackTrace;
+        this.attributes = statusAttributes != null ? Collections.unmodifiableMap(statusAttributes) : null;
     }
 
     public ResponseStatusCode getResponseStatusCode() {
@@ -61,4 +71,11 @@ public class ResponseException extends Exception {
     public Optional<List<String>> getRemoteExceptionHierarchy() {
         return Optional.ofNullable(remoteExceptionHierarchy);
     }
+
+    /**
+     * Gets any status attributes from the response.
+     */
+    public Optional<Map<String, Object>> getStatusAttributes() {
+        return Optional.ofNullable(attributes);
+    }
 }
\ No newline at end of file


[10/22] tinkerpop git commit: TINKERPOP-1913 Made status attributes available to the ResultSet

Posted by sp...@apache.org.
TINKERPOP-1913 Made status attributes available to the ResultSet


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

Branch: refs/heads/master
Commit: fb3984aad10b1aa78a75a8d4d370e89fa384bac1
Parents: da3c601
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 7 10:29:11 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Handler.java       | 13 ++++-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |  2 +
 .../tinkerpop/gremlin/driver/ResultSet.java     | 12 +++++
 .../tinkerpop/gremlin/driver/ResultSetTest.java | 25 +++++++++
 .../gremlin/server/op/AbstractOpProcessor.java  | 56 ++++++++++++++++----
 .../op/traversal/TraversalOpProcessor.java      | 10 +++-
 .../server/GremlinResultSetIntegrateTest.java   |  9 ++++
 7 files changed, 115 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
index ecd92e9..4a82f24 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
@@ -260,9 +260,18 @@ final class Handler {
                     }
                 }
 
-                // as this is a non-PARTIAL_CONTENT code - the stream is done
-                if (response.getStatus().getCode() != ResponseStatusCode.PARTIAL_CONTENT)
+                // the last message in a OK stream could have meta-data that is useful to the result. note that error
+                // handling of the status attributes is handled separately above
+                if (statusCode == ResponseStatusCode.SUCCESS || statusCode == ResponseStatusCode.NO_CONTENT) {
+                    // in 3.4.0 this should get refactored. i think the that the markComplete() could just take the
+                    // status attributes as its argument - need to investigate that further
+                    queue.statusAttributes = response.getStatus().getAttributes();
+                }
+
+                // as this is a non-PARTIAL_CONTENT code - the stream is done.
+                if (statusCode != ResponseStatusCode.PARTIAL_CONTENT) {
                     pending.remove(response.getRequestId()).markComplete();
+                }
             } finally {
                 // in the event of an exception above the exception is tossed and handled by whatever channelpipeline
                 // error handling is at play.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/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 e21e265..7340763 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
@@ -56,6 +56,8 @@ final class ResultQueue {
 
     private final Queue<Pair<CompletableFuture<List<Result>>,Integer>> waiting = new ConcurrentLinkedQueue<>();
 
+    Map<String,Object> statusAttributes = null;
+
     public ResultQueue(final LinkedBlockingQueue<Result> resultLinkedBlockingQueue, final CompletableFuture<Void> readComplete) {
         this.resultLinkedBlockingQueue = resultLinkedBlockingQueue;
         this.readComplete = readComplete;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
index f82876c..f608f06 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
@@ -21,8 +21,10 @@ package org.apache.tinkerpop.gremlin.driver;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Spliterator;
 import java.util.Spliterators;
@@ -74,6 +76,16 @@ public final class ResultSet implements Iterable<Result> {
     }
 
     /**
+     * Returns a future that will complete when {@link #allItemsAvailable()} is {@code true} and will contain the
+     * attributes from the response.
+     */
+    public CompletableFuture<Map<String,Object>> statusAttributes() {
+        final CompletableFuture<Map<String,Object>> attrs = new CompletableFuture<>();
+        readCompleted.thenRun(() -> attrs.complete(null == resultQueue.statusAttributes ? Collections.emptyMap() : resultQueue.statusAttributes));
+        return attrs;
+    }
+
+    /**
      * Determines if all items have been returned to the client.
      */
     public boolean allItemsAvailable() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
index 0cf4fb5..3163ffe 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
@@ -22,8 +22,10 @@ import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
@@ -49,6 +51,29 @@ public class ResultSetTest extends AbstractResultQueueTest {
     }
 
     @Test
+    public void shouldReturnResponseAttributes() throws Exception {
+        resultQueue.statusAttributes = new HashMap<String,Object>() {{
+            put("test",123);
+            put("junk","here");
+        }};
+
+        final CompletableFuture<Map<String,Object>> attrs = resultSet.statusAttributes();
+        readCompleted.complete(null);
+
+        final Map<String,Object> m = attrs.get();
+        assertEquals(123, m.get("test"));
+        assertEquals("here", m.get("junk"));
+        assertEquals(2, m.size());
+    }
+
+    @Test
+    public void shouldReturnEmptyMapForNoResponseAttributes() throws Exception {
+        final CompletableFuture<Map<String,Object>> attrs = resultSet.statusAttributes();
+        readCompleted.complete(null);
+        assertThat(attrs.get().isEmpty(), is(true));
+    }
+
+    @Test
     public void shouldHaveAllItemsAvailableAsynchronouslyOnReadComplete() {
         final CompletableFuture<Void> all = resultSet.allItemsAvailableAsync();
         assertThat(all.isDone(), is(false));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
index 331b762..767445a 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -67,7 +68,6 @@ public abstract class AbstractOpProcessor implements OpProcessor {
      *
      * @param context The Gremlin Server {@link Context} object containing settings, request message, etc.
      * @param itty The result to iterator
-     * @throws TimeoutException if the time taken to serialize the entire result set exceeds the allowable time.
      * @see #handleIterator(ResponseHandlerContext, Iterator)
      */
     protected void handleIterator(final Context context, final Iterator itty) throws InterruptedException {
@@ -146,7 +146,9 @@ public abstract class AbstractOpProcessor implements OpProcessor {
                     // thread that processed the eval of the script so, we have to push serialization down into that
                     Frame frame = null;
                     try {
-                        frame = makeFrame(rhc, msg, serializer, useBinary, aggregate, code, generateMetaData(ctx, msg, code, itty));
+                        frame = makeFrame(rhc, msg, serializer, useBinary, aggregate, code,
+                                generateResultMetaData(ctx, msg, code, itty, settings),
+                                generateStatusAttributes(ctx, msg, code, itty, settings));
                     } catch (Exception ex) {
                         // a frame may use a Bytebuf which is a countable release - if it does not get written
                         // downstream it needs to be released here
@@ -231,36 +233,71 @@ public abstract class AbstractOpProcessor implements OpProcessor {
     }
 
     /**
-     * Generates meta-data to put on a {@link ResponseMessage}.
+     * Generates response result meta-data to put on a {@link ResponseMessage}.
      *
      * @param itty a reference to the current {@link Iterator} of results - it is not meant to be forwarded in
      *             this method
+     * @deprecated As of release 3.3.2, replaced by {@link #generateResultMetaData(ChannelHandlerContext, RequestMessage, ResponseStatusCode, Iterator, Settings)}
      */
-    protected Map<String,Object> generateMetaData(final ChannelHandlerContext ctx, final RequestMessage msg,
-                                                  final ResponseStatusCode code, final Iterator itty) {
+    @Deprecated
+    protected Map<String, Object> generateMetaData(final ChannelHandlerContext ctx, final RequestMessage msg,
+                                                   final ResponseStatusCode code, final Iterator itty) {
         return Collections.emptyMap();
     }
 
     /**
-     * Caution: {@link #makeFrame(ResponseHandlerContext, RequestMessage, MessageSerializer, boolean, List, ResponseStatusCode, Map)}
+     * Generates response result meta-data to put on a {@link ResponseMessage}.
+     *
+     * @param itty a reference to the current {@link Iterator} of results - it is not meant to be forwarded in
+     *             this method
+     */
+    protected Map<String, Object> generateResultMetaData(final ChannelHandlerContext ctx, final RequestMessage msg,
+                                                         final ResponseStatusCode code, final Iterator itty,
+                                                         final Settings settings) {
+        return generateMetaData(ctx, msg, code, itty);
+    }
+
+    /**
+     * Generates response status meta-data to put on a {@link ResponseMessage}.
+     *
+     * @param itty a reference to the current {@link Iterator} of results - it is not meant to be forwarded in
+     *             this method
+     */
+    protected Map<String, Object> generateStatusAttributes(final ChannelHandlerContext ctx, final RequestMessage msg,
+                                                           final ResponseStatusCode code, final Iterator itty,
+                                                           final Settings settings) {
+        // only return server metadata on the last message
+        if (itty.hasNext()) return Collections.emptyMap();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put(Tokens.ARGS_HOST, ctx.channel().remoteAddress().toString());
+
+        return metaData;
+    }
+
+    /**
+     * Caution: {@link #makeFrame(ResponseHandlerContext, RequestMessage, MessageSerializer, boolean, List, ResponseStatusCode, Map, Map)}
      * should be used instead of this method whenever a {@link ResponseHandlerContext} is available.
      */
     protected static Frame makeFrame(final ChannelHandlerContext ctx, final RequestMessage msg,
                                      final MessageSerializer serializer, final boolean useBinary, final List<Object> aggregate,
-                                     final ResponseStatusCode code, final Map<String,Object> responseMetaData) throws Exception {
+                                     final ResponseStatusCode code, final Map<String,Object> responseMetaData,
+                                     final Map<String,Object> statusAttributes) throws Exception {
         final Context context = new Context(msg, ctx, null, null, null, null); // dummy context, good only for writing response messages to the channel
         final ResponseHandlerContext rhc = new ResponseHandlerContext(context);
-        return makeFrame(rhc, msg, serializer, useBinary, aggregate, code, responseMetaData);
+        return makeFrame(rhc, msg, serializer, useBinary, aggregate, code, responseMetaData, statusAttributes);
     }
 
     protected static Frame makeFrame(final ResponseHandlerContext rhc, final RequestMessage msg,
                                      final MessageSerializer serializer, final boolean useBinary, final List<Object> aggregate,
-                                     final ResponseStatusCode code, final Map<String,Object> responseMetaData) throws Exception {
+                                     final ResponseStatusCode code, final Map<String,Object> responseMetaData,
+                                     final Map<String,Object> statusAttributes) throws Exception {
         final ChannelHandlerContext ctx = rhc.getContext().getChannelHandlerContext();
         try {
             if (useBinary) {
                 return new Frame(serializer.serializeResponseAsBinary(ResponseMessage.build(msg)
                         .code(code)
+                        .statusAttributes(statusAttributes)
                         .responseMetaData(responseMetaData)
                         .result(aggregate).create(), ctx.alloc()));
             } else {
@@ -269,6 +306,7 @@ public abstract class AbstractOpProcessor implements OpProcessor {
                 final MessageTextSerializer textSerializer = (MessageTextSerializer) serializer;
                 return new Frame(textSerializer.serializeResponseAsString(ResponseMessage.build(msg)
                         .code(code)
+                        .statusAttributes(statusAttributes)
                         .responseMetaData(responseMetaData)
                         .result(aggregate).create()));
             }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 55ee941..9b73295 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -451,6 +451,9 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
     @Override
     protected Map<String, Object> generateMetaData(final ChannelHandlerContext ctx, final RequestMessage msg,
                                                    final ResponseStatusCode code, final Iterator itty) {
+        // leaving this overriding the deprecated version of this method because it provides a decent test to those
+        // who might have their own OpProcessor implementations that apply meta-data. leaving this alone helps validate
+        // that the upgrade path is clean. we can remove this in 3.4.0
         Map<String, Object> metaData = Collections.emptyMap();
         if (itty instanceof SideEffectIterator) {
             final SideEffectIterator traversalIterator = (SideEffectIterator) itty;
@@ -460,6 +463,9 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
                 metaData.put(Tokens.ARGS_SIDE_EFFECT_KEY, key);
                 metaData.put(Tokens.ARGS_AGGREGATE_TO, traversalIterator.getSideEffectAggregator());
             }
+        } else {
+            // this is a standard traversal iterator
+            metaData = super.generateMetaData(ctx, msg, code, itty);
         }
 
         return metaData;
@@ -532,7 +538,9 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
                     // thread that processed the eval of the script so, we have to push serialization down into that
                     Frame frame = null;
                     try {
-                        frame = makeFrame(ctx, msg, serializer, useBinary, aggregate, code, generateMetaData(ctx, msg, code, itty));
+                        frame = makeFrame(ctx, msg, serializer, useBinary, aggregate, code,
+                                generateResultMetaData(ctx, msg, code, itty, settings),
+                                generateStatusAttributes(ctx, msg, code, itty, settings));
                     } catch (Exception ex) {
                         // a frame may use a Bytebuf which is a countable release - if it does not get written
                         // downstream it needs to be released here

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fb3984aa/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
index 66e2c94..bd71f1b 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.driver.Cluster;
 import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
 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.ser.GryoMessageSerializerV3d0;
 import org.apache.tinkerpop.gremlin.driver.ser.Serializers;
 import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin;
@@ -53,6 +54,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.is;
@@ -88,6 +90,13 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat
     }
 
     @Test
+    public void shouldReturnResponseAttributes() throws Exception {
+        final ResultSet results = client.submit("g.V()");
+        final Map<String,Object> attr = results.statusAttributes().get(20000, TimeUnit.MILLISECONDS);
+        assertThat(attr.containsKey(Tokens.ARGS_HOST), is(true));
+    }
+
+    @Test
     public void shouldHandleVertexResultFromTraversalBulked() throws Exception {
         final Graph graph = TinkerGraph.open();
         final GraphTraversalSource g = graph.traversal();


[02/22] tinkerpop git commit: Updates GremlinClientExtension to pass through ResultSet from client.

Posted by sp...@apache.org.
Updates GremlinClientExtension to pass through ResultSet<T> from client.


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

Branch: refs/heads/master
Commit: 5de845462c61c81cdccf50088481ab5ac831ec4c
Parents: 137f365
Author: Patrik Husfloen <re...@redoz.com>
Authored: Thu Sep 6 23:16:56 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5de84546/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs
index 4aad73e..1b18241 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClientExtensions.cs
@@ -121,12 +121,12 @@ namespace Gremlin.Net.Driver
         /// <param name="gremlinClient">The <see cref="IGremlinClient" /> that submits the request.</param>
         /// <param name="requestScript">The Gremlin request script to send.</param>
         /// <param name="bindings">Bindings for parameters used in the requestScript.</param>
-        /// <returns>A collection of the data returned from the server.</returns>
+        /// <returns>A <see cref="ResultSet{T}"/> containing the data and status attributes returned from the server.</returns>
         /// <exception cref="Exceptions.ResponseException">
         ///     Thrown when a response is received from Gremlin Server that indicates
         ///     that an error occurred.
         /// </exception>
-        public static async Task<IReadOnlyCollection<T>> SubmitAsync<T>(this IGremlinClient gremlinClient,
+        public static async Task<ResultSet<T>> SubmitAsync<T>(this IGremlinClient gremlinClient,
             string requestScript,
             Dictionary<string, object> bindings = null)
         {


[05/22] tinkerpop git commit: TINKERPOP-1913 Added status attribute access to traversal side-effects

Posted by sp...@apache.org.
TINKERPOP-1913 Added status attribute access to traversal side-effects


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

Branch: refs/heads/master
Commit: 60883a109d493f39b0c0445582a199a65037d1ab
Parents: fb3984a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Mar 7 12:05:23 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../driver/remote/DriverRemoteTraversal.java    |  4 +---
 .../DriverRemoteTraversalSideEffects.java       | 25 ++++++++++++++++++++
 .../op/traversal/TraversalOpProcessor.java      |  1 +
 .../server/GremlinServerIntegrateTest.java      |  8 ++++++-
 4 files changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60883a10/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
index d991f21..46d1a2b 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversal.java
@@ -66,9 +66,7 @@ public class DriverRemoteTraversal<S, E> extends AbstractRemoteTraversal<S, E> {
         }
 
         this.rs = rs;
-        this.sideEffects = new DriverRemoteTraversalSideEffects(client,
-                rs.getOriginalRequestMessage().getRequestId(),
-                rs.getHost(), rs.allItemsAvailableAsync());
+        this.sideEffects = new DriverRemoteTraversalSideEffects(client,rs);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60883a10/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
index 791c70e..17ce082 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
@@ -22,6 +22,7 @@ import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.tinkerpop.gremlin.driver.Client;
 import org.apache.tinkerpop.gremlin.driver.Host;
 import org.apache.tinkerpop.gremlin.driver.Result;
+import org.apache.tinkerpop.gremlin.driver.ResultSet;
 import org.apache.tinkerpop.gremlin.driver.Tokens;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.AbstractRemoteTraversalSideEffects;
@@ -53,13 +54,37 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
     private boolean closed = false;
     private boolean retrievedAllKeys = false;
     private final CompletableFuture<Void> ready;
+    private final CompletableFuture<Map<String,Object>> statusAttributes;
 
+    /**
+     * @deprecated As of release 3.3.2, replaced by {@link #DriverRemoteTraversalSideEffects(Client, ResultSet)}
+     */
+    @Deprecated
     public DriverRemoteTraversalSideEffects(final Client client, final UUID serverSideEffect, final Host host,
                                             final CompletableFuture<Void> ready) {
         this.client = client;
         this.serverSideEffect = serverSideEffect;
         this.host = host;
         this.ready = ready;
+        this.statusAttributes = CompletableFuture.completedFuture(Collections.emptyMap());
+    }
+
+    public DriverRemoteTraversalSideEffects(final Client client, final ResultSet rs) {
+        this.client = client;
+        this.serverSideEffect = rs.getOriginalRequestMessage().getRequestId();
+        this.host = rs.getHost();
+        this.ready = rs.allItemsAvailableAsync();
+        this.statusAttributes = rs.statusAttributes();
+    }
+
+    /**
+     * Gets the status attributes from the response from the server. This method will block until all results have
+     * been retrieved.
+     */
+    public Map<String,Object> statusAttributes() {
+        // wait for the read to complete (i.e. iteration on the server) before allowing the caller to get the
+        // attribute. simply following the pattern from other methods here for now.
+        return statusAttributes.join();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60883a10/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 9b73295..1f18fcd 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -491,6 +491,7 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
             }
             ctx.writeAndFlush(ResponseMessage.build(msg)
                     .code(ResponseStatusCode.NO_CONTENT)
+                    .statusAttributes(generateStatusAttributes(ctx, msg, ResponseStatusCode.NO_CONTENT, itty, settings))
                     .create());
             return;
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60883a10/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 c5dd3b9..2126f7a 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
@@ -1174,7 +1174,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
-    public void shouldGetSideEffectKeysUsingWithRemote() throws Exception {
+    public void shouldGetSideEffectKeysAndStatusUsingWithRemote() throws Exception {
         final Graph graph = EmptyGraph.instance();
         final GraphTraversalSource g = graph.traversal().withRemote(conf);
         g.addV("person").property("age", 20).iterate();
@@ -1182,6 +1182,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
         final GraphTraversal traversal = g.V().aggregate("a").aggregate("b");
         traversal.iterate();
         final DriverRemoteTraversalSideEffects se = (DriverRemoteTraversalSideEffects) traversal.asAdmin().getSideEffects();
+        assertThat(se.statusAttributes().containsKey(Tokens.ARGS_HOST), is(true));
 
         // Get keys
         final Set<String> sideEffectKeys = se.keys();
@@ -1204,6 +1205,11 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
 
         final BulkSet localBSideEffects = se.get("b");
         assertThat(localBSideEffects.isEmpty(), is(false));
+
+        final GraphTraversal gdotv = g.V();
+        gdotv.toList();
+        final DriverRemoteTraversalSideEffects gdotvSe = (DriverRemoteTraversalSideEffects) gdotv.asAdmin().getSideEffects();
+        assertThat(gdotvSe.statusAttributes().containsKey(Tokens.ARGS_HOST), is(true));
     }
 
     @Test


[15/22] tinkerpop git commit: TINKERPOP-1913 Cleaned up deprecation messages

Posted by sp...@apache.org.
TINKERPOP-1913 Cleaned up deprecation messages


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

Branch: refs/heads/master
Commit: 9a8f57623a2482711007a840bf0c9ede247943f3
Parents: 55549cf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 12:47:43 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:43 2018 -0400

----------------------------------------------------------------------
 .../gremlin/driver/remote/DriverRemoteTraversalSideEffects.java    | 2 +-
 .../apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java    | 2 +-
 .../gremlin/server/op/traversal/TraversalOpProcessor.java          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9a8f5762/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
index 17ce082..7f34657 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
@@ -57,7 +57,7 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
     private final CompletableFuture<Map<String,Object>> statusAttributes;
 
     /**
-     * @deprecated As of release 3.3.2, replaced by {@link #DriverRemoteTraversalSideEffects(Client, ResultSet)}
+     * @deprecated As of release 3.4.0, replaced by {@link #DriverRemoteTraversalSideEffects(Client, ResultSet)}
      */
     @Deprecated
     public DriverRemoteTraversalSideEffects(final Client client, final UUID serverSideEffect, final Host host,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9a8f5762/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
index cdbb706..2cc0f57 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
@@ -238,7 +238,7 @@ public abstract class AbstractOpProcessor implements OpProcessor {
      *
      * @param itty a reference to the current {@link Iterator} of results - it is not meant to be forwarded in
      *             this method
-     * @deprecated As of release 3.3.2, replaced by {@link #generateResultMetaData(ChannelHandlerContext, RequestMessage, ResponseStatusCode, Iterator, Settings)}
+     * @deprecated As of release 3.4.0, replaced by {@link #generateResultMetaData(ChannelHandlerContext, RequestMessage, ResponseStatusCode, Iterator, Settings)}
      */
     @Deprecated
     protected Map<String, Object> generateMetaData(final ChannelHandlerContext ctx, final RequestMessage msg,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9a8f5762/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 1f18fcd..ff46e49 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -453,7 +453,7 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
                                                    final ResponseStatusCode code, final Iterator itty) {
         // leaving this overriding the deprecated version of this method because it provides a decent test to those
         // who might have their own OpProcessor implementations that apply meta-data. leaving this alone helps validate
-        // that the upgrade path is clean. we can remove this in 3.4.0
+        // that the upgrade path is clean.  it can be removed at the next breaking change 3.5.0
         Map<String, Object> metaData = Collections.emptyMap();
         if (itty instanceof SideEffectIterator) {
             final SideEffectIterator traversalIterator = (SideEffectIterator) itty;


[04/22] tinkerpop git commit: Adding comment

Posted by sp...@apache.org.
Adding comment


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

Branch: refs/heads/master
Commit: 705ce4ee3816884a57ee00aef9f5b65eafb0004a
Parents: fe5ae5c
Author: Ashwini Singh <as...@gmail.com>
Authored: Mon May 14 11:48:29 2018 -0700
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/705ce4ee/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 1dd4d7b..2b1edfb 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -28,7 +28,8 @@ using System.Collections.Generic;
 namespace Gremlin.Net.Driver
 {
     /// <summary>
-    /// Ashiwni
+    /// A ResultSet is returned from the submission of a Gremlin script to the server and represents the results provided by the server
+    /// ResultSet includes enumerable data and status attributes.
     /// </summary>
     /// <typeparam name="T"></typeparam>
     public sealed class ResultSet<T> : IReadOnlyCollection<T>


[12/22] tinkerpop git commit: status attribute for gremlin dotnet

Posted by sp...@apache.org.
status attribute for gremlin dotnet


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

Branch: refs/heads/master
Commit: fe5ae5c369d4724e2c44d74de5357bf894126b9a
Parents: 7fca7af
Author: Ashwini Singh <as...@gmail.com>
Authored: Mon May 14 11:42:54 2018 -0700
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../src/Gremlin.Net/Driver/Connection.cs        | 13 ++-
 .../src/Gremlin.Net/Driver/ResultSet.cs         | 87 ++++++++++++++++++++
 .../Driver/GremlinClientTests.cs                | 20 +++++
 3 files changed, 117 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe5ae5c3/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 279c708..3663191 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -80,6 +80,7 @@ namespace Gremlin.Net.Driver
 
         private async Task<IReadOnlyCollection<T>> ReceiveAsync<T>()
         {
+            ResultSet<T> resultSet = new ResultSet<T>();
             ResponseStatus status;
             IAggregator aggregator = null;
             var isAggregatingSideEffects = false;
@@ -114,11 +115,17 @@ namespace Gremlin.Net.Driver
                             result.Add(d);
                         }
                 }
+
+                if (status.Code == ResponseStatusCode.Success || status.Code == ResponseStatusCode.NoContent)
+                {
+                    resultSet.StatusAttributes = receivedMsg.Status.Attributes;
+                }
+
             } while (status.Code == ResponseStatusCode.PartialContent || status.Code == ResponseStatusCode.Authenticate);
 
-            if (isAggregatingSideEffects)
-                return new List<T> {(T) aggregator.GetAggregatedResult()};
-            return result;
+            resultSet.Data = isAggregatingSideEffects ? new List<T> {(T) aggregator.GetAggregatedResult()} : result;
+                
+            return resultSet;
         }
 
         private async Task AuthenticateAsync()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe5ae5c3/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
new file mode 100644
index 0000000..1dd4d7b
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -0,0 +1,87 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using Gremlin.Net.Driver.Exceptions;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Gremlin.Net.Driver
+{
+    /// <summary>
+    /// Ashiwni
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public sealed class ResultSet<T> : IReadOnlyCollection<T>
+    {
+        /// <summary>
+        ///  Gets and Sets the read only collection
+        /// </summary>
+        public IReadOnlyCollection<T> Data { get; set; }
+
+        /// <summary>
+        /// Gets or Sets the status attributes from the gremlin response
+        /// </summary>
+        public Dictionary<string, object> StatusAttributes { get; set; }
+
+        /// <summary>Returns an enumerator that iterates through the collection.</summary>
+        /// <returns>An enumerator that can be used to iterate through the collection.</returns>
+        public IEnumerator<T> GetEnumerator()
+        {
+            return this.Data.GetEnumerator();
+        }
+
+        /// <summary>Returns an enumerator that iterates through a collection.</summary>
+        /// <returns>An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.</returns>
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return this.GetEnumerator();
+        }
+
+        /// <summary>Gets the number of elements in the collection.</summary>
+        /// <returns>The number of elements in the collection. </returns>
+        public int Count => this.Data.Count;
+    }
+
+    /// <summary>
+    /// Extension for IReadOnlyCollection 
+    /// </summary>
+    public static class ResultSetExtensions
+    {
+        /// <summary>
+        /// Casts a IReadOnlyCollection to ResultSet
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="data"></param>
+        /// <returns></returns>
+        public static ResultSet<T> AsResultSet<T>(this IReadOnlyCollection<T> data)
+        {
+            if (!(data is ResultSet<T> resultSet))
+            {
+                throw new ResponseException($"IReadOnlyCollection is not of type ResultSet");
+            }
+
+            return resultSet;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe5ae5c3/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
index 351b83d..a7e191f 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
@@ -29,6 +29,7 @@ using Gremlin.Net.Driver.Exceptions;
 using Gremlin.Net.Driver.Messages;
 using Gremlin.Net.IntegrationTest.Util;
 using Xunit;
+using Gremlin.Net.Structure.IO.GraphSON;
 
 namespace Gremlin.Net.IntegrationTest.Driver
 {
@@ -168,6 +169,25 @@ namespace Gremlin.Net.IntegrationTest.Driver
         }
 
         [Fact]
+        public async Task ShouldReturnResponseAttributes()
+        {
+            var gremlinServer = new GremlinServer(TestHost, TestPort);
+            using (var gremlinClient = new GremlinClient(gremlinServer))
+            {
+                var expectedResult = new List<int> { 1, 2, 3, 4, 5 };
+                var requestMsg = $"{nameof(expectedResult)}";
+                var bindings = new Dictionary<string, object> { { nameof(expectedResult), expectedResult } };
+
+                var response = await gremlinClient.SubmitAsync<int>(requestMsg, bindings);
+
+                var resultSet = response.AsResultSet();
+
+                Assert.NotNull(resultSet.StatusAttributes);
+
+            }
+        }
+
+        [Fact]
         public async Task ShouldThrowOnExecutionOfSimpleInvalidScript()
         {
             var gremlinServer = new GremlinServer(TestHost, TestPort);


[17/22] tinkerpop git commit: TINKERPOP-1913 Upgrade docs for status attributes on responses

Posted by sp...@apache.org.
TINKERPOP-1913 Upgrade docs for status attributes on responses


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

Branch: refs/heads/master
Commit: bb01d96fbd7efdd4de30d7c0e570e48b91c0d490
Parents: 9a8f576
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 13:15:59 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 13:15:59 2018 -0400

----------------------------------------------------------------------
 docs/src/upgrade/release-3.4.x.asciidoc | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bb01d96f/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.4.x.asciidoc b/docs/src/upgrade/release-3.4.x.asciidoc
index e0484a8..69a2502 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -71,6 +71,16 @@ g.sparql("""SELECT ?name ?age
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1878[TINKERPOP-1878],
 link:http://tinkerpop.apache.org/docs/3.4.0/reference/#sparql-gremlin[Reference Documentation]
 
+==== Status Attributes
+
+The Gremlin Server protocol allows for status attributes to be returned in responses. These attributes were typically
+for internal use, but were designed with extensibility in mind so that providers could place return their own
+attributes to calling clients. Unfortunately, unless the client was being used with protocol level requests (which
+wasn't convenient) those attributes were essentially hidden from view. As of this version however, status attributes
+are fully retrievable for both successful requests and exceptions.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1913[TINKERPOP-1913]
+
 ==== with() Step
 
 This version of TinkerPop introduces the `with()`-step to Gremlin. It isn't really a step but is instead a step


[09/22] tinkerpop git commit: Adds StatusCode (of type ResponseStatusCode) property on ResponseException.

Posted by sp...@apache.org.
Adds StatusCode (of type ResponseStatusCode) property on ResponseException.


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

Branch: refs/heads/master
Commit: c720dba7ffa212fc8574af84f4fc90f1b7174b58
Parents: 5de8454
Author: Patrik Husfloen <re...@redoz.com>
Authored: Sat Sep 8 16:54:11 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../Driver/Exceptions/ResponseException.cs      | 16 +++++--
 .../Driver/Messages/ResponseStatus.cs           |  2 +-
 .../Driver/Messages/ResponseStatusCode.cs       | 48 +++++++++++++++++++-
 3 files changed, 61 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c720dba7/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
index 3c0d927..f9020d2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
@@ -23,6 +23,7 @@
 
 using System;
 using System.Collections.Generic;
+using Gremlin.Net.Driver.Messages;
 
 namespace Gremlin.Net.Driver.Exceptions
 {
@@ -34,15 +35,24 @@ namespace Gremlin.Net.Driver.Exceptions
         /// <summary>
         ///     Initializes a new instance of the <see cref="ResponseException" /> class.
         /// </summary>
-        /// <param name="statusAttributes">The status attributes as returned by the server.</param>
+        /// <param name="statusCode">The status code returned by the server.</param>
+        /// <param name="statusAttributes">The status attributes from the gremlin response.</param>
         /// <param name="message">The error message string.</param>
-        public ResponseException(IReadOnlyDictionary<string, object> statusAttributes, string message) : base(message)
+        public ResponseException(ResponseStatusCode statusCode,
+                                 IReadOnlyDictionary<string, object> statusAttributes,
+                                 string message) : base(message)
         {
             StatusAttributes = statusAttributes;
+            StatusCode = statusCode;
         }
 
         /// <summary>
-        /// Gets or sets the status attributes from the gremlin response
+        /// Gets the status code returned from the server.
+        /// </summary>
+        public ResponseStatusCode StatusCode { get; }
+
+        /// <summary>
+        /// Gets the status attributes from the gremlin response
         /// </summary>
         public IReadOnlyDictionary<string, object> StatusAttributes { get; }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c720dba7/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
index c436662..aa0b1b7 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
@@ -44,7 +44,7 @@ namespace Gremlin.Net.Driver.Messages
         public static void ThrowIfStatusIndicatesError(this ResponseStatus status)
         {
             if (status.Code.IndicatesError())
-                throw new ResponseException(status.Attributes, $"{status.Code}: {status.Message}");
+                throw new ResponseException(status.Code, status.Attributes, $"{status.Code}: {status.Message}");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c720dba7/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
index 558e4f6..1c5d088 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatusCode.cs
@@ -25,18 +25,64 @@ using System;
 
 namespace Gremlin.Net.Driver.Messages
 {
-    internal enum ResponseStatusCode
+    /// <summary>
+    /// Represents the various status codes that Gremlin Server returns.
+    /// </summary>
+    public enum ResponseStatusCode
     {
+        /// <summary>
+        /// The server successfully processed a request to completion - there are no messages remaining in this stream.
+        /// </summary>
         Success = 200,
+        
+        /// <summary>
+        /// The server processed the request but there is no result to return (e.g. an Iterator with no elements) - there are no messages remaining in this stream.
+        /// </summary>
         NoContent = 204,
+        
+        /// <summary>
+        /// The server successfully returned some content, but there is more in the stream to arrive - wait for a SUCCESS to signify the end of the stream.
+        /// </summary>
         PartialContent = 206,
+
+        /// <summary>
+        /// The request attempted to access resources that the requesting user did not have access to.
+        /// </summary>
         Unauthorized = 401,
+
+        /// <summary>
+        /// A challenge from the server for the client to authenticate its request.
+        /// </summary>
         Authenticate = 407,
+
+        /// <summary>
+        /// The request message was not properly formatted which means it could not be parsed at all or the "op" code was not recognized such that Gremlin Server could properly route it for processing. Check the message format and retry the request.
+        /// </summary>
         MalformedRequest = 498,
+
+        /// <summary>
+        /// The request message was parseable, but the arguments supplied in the message were in conflict or incomplete. Check the message format and retry the request.
+        /// </summary>
         InvalidRequestArguments = 499,
+
+        /// <summary>
+        /// A general server error occurred that prevented the request from being processed.
+        /// </summary>
         ServerError = 500,
+
+        /// <summary>
+        /// The script submitted for processing evaluated in the ScriptEngine with errors and could not be processed. Check the script submitted for syntax errors or other problems and then resubmit.
+        /// </summary>
         ScriptEvaluationError = 597,
+
+        /// <summary>
+        /// The server exceeded one of the timeout settings for the request and could therefore only partially responded or did not respond at all.
+        /// </summary>
         ServerTimeout = 598,
+
+        /// <summary>
+        /// The server was not capable of serializing an object that was returned from the script supplied on the request. Either transform the object into something Gremlin Server can process within the script or install mapper serialization classes to Gremlin Server.
+        /// </summary>
         ServerSerializationError = 599
     }
 


[14/22] tinkerpop git commit: TINKERPOP-1913 Refactored how response status attributes are set

Posted by sp...@apache.org.
TINKERPOP-1913 Refactored how response status attributes are set

Didn't seem necessary to set them directly into a member variable on ResultQueue when they could be passed more safely by just including them with the completion state update


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

Branch: refs/heads/master
Commit: 7fca7af74e5bd2695ba6035cf341543f9750fc4d
Parents: 956b177
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 16 11:38:09 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Handler.java       | 11 +------
 .../tinkerpop/gremlin/driver/ResultQueue.java   | 11 +++++--
 .../tinkerpop/gremlin/driver/ResultSet.java     |  2 +-
 .../gremlin/driver/AbstractResultQueueTest.java |  3 +-
 .../gremlin/driver/ResultQueueTest.java         | 30 +++++++++++++++-----
 .../tinkerpop/gremlin/driver/ResultSetTest.java | 28 +++++++-----------
 6 files changed, 46 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
index d79bed5..a77ec84 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java
@@ -260,18 +260,9 @@ final class Handler {
                     }
                 }
 
-                // the last message in a OK stream could have meta-data that is useful to the result. note that error
-                // handling of the status attributes is handled separately above
-                if (statusCode == ResponseStatusCode.SUCCESS || statusCode == ResponseStatusCode.NO_CONTENT) {
-                    // in 3.4.0 this should get refactored. i think the that the markComplete() could just take the
-                    // status attributes as its argument - need to investigate that further
-                    queue.statusAttributes = response.getStatus().getAttributes();
-                }
-
                 // as this is a non-PARTIAL_CONTENT code - the stream is done.
                 if (statusCode != ResponseStatusCode.PARTIAL_CONTENT) {
-                    queue.statusAttributes = response.getStatus().getAttributes();
-                    pending.remove(response.getRequestId()).markComplete();
+                    pending.remove(response.getRequestId()).markComplete(response.getStatus().getAttributes());
                 }
             } finally {
                 // in the event of an exception above the exception is tossed and handled by whatever channelpipeline

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/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 7340763..59b4617 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
@@ -26,6 +26,7 @@ import org.javatuples.Pair;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -56,7 +57,7 @@ final class ResultQueue {
 
     private final Queue<Pair<CompletableFuture<List<Result>>,Integer>> waiting = new ConcurrentLinkedQueue<>();
 
-    Map<String,Object> statusAttributes = null;
+    private Map<String,Object> statusAttributes = null;
 
     public ResultQueue(final LinkedBlockingQueue<Result> resultLinkedBlockingQueue, final CompletableFuture<Void> readComplete) {
         this.resultLinkedBlockingQueue = resultLinkedBlockingQueue;
@@ -165,12 +166,14 @@ final class ResultQueue {
         resultLinkedBlockingQueue.drainTo(collection);
     }
 
-    void markComplete() {
+    void markComplete(final Map<String,Object> statusAttributes) {
         // if there was some aggregation performed in the queue then the full object is hanging out waiting to be
         // added to the ResultSet
         if (aggregatedResult != null)
             add(new Result(aggregatedResult));
 
+        this.statusAttributes = null == statusAttributes ? Collections.emptyMap() : statusAttributes;
+
         this.readComplete.complete(null);
 
         this.drainAllWaiting();
@@ -182,6 +185,10 @@ final class ResultQueue {
         this.drainAllWaiting();
     }
 
+    Map<String,Object> getStatusAttributes() {
+        return statusAttributes;
+    }
+
     /**
      * Completes the next waiting future if there is one.
      */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
index f608f06..85c74f3 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
@@ -81,7 +81,7 @@ public final class ResultSet implements Iterable<Result> {
      */
     public CompletableFuture<Map<String,Object>> statusAttributes() {
         final CompletableFuture<Map<String,Object>> attrs = new CompletableFuture<>();
-        readCompleted.thenRun(() -> attrs.complete(null == resultQueue.statusAttributes ? Collections.emptyMap() : resultQueue.statusAttributes));
+        readCompleted.thenRun(() -> attrs.complete(null == resultQueue.getStatusAttributes() ? Collections.emptyMap() : resultQueue.getStatusAttributes()));
         return attrs;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java
index 3c84ca6..302fda9 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/AbstractResultQueueTest.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.driver;
 
 import org.junit.Before;
 
+import java.util.Collections;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -84,7 +85,7 @@ public abstract class AbstractResultQueueTest {
                 }
             }
 
-            if (markDone) resultQueue.markComplete();
+            if (markDone) resultQueue.markComplete(Collections.emptyMap());
 
         }, "ResultQueueTest-job-submitter");
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
index 43442be..436d659 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
@@ -45,6 +45,10 @@ import static org.junit.Assert.fail;
  */
 public class ResultQueueTest extends AbstractResultQueueTest {
 
+    private static final Map<String,Object> ATTRIBUTES = new HashMap<String,Object>() {{
+        put("this", "that");
+    }};
+
     @Test
     public void shouldGetSizeUntilError() throws Exception {
         final Thread t = addToQueue(100, 10, true, false, 1);
@@ -135,7 +139,7 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         resultQueue.add(new Result("test3"));
 
         assertThat(future.isDone(), is(false));
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
         assertThat(future.isDone(), is(true));
 
         final List<Result> results = future.get();
@@ -145,6 +149,7 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         assertEquals(3, results.size());
 
         assertThat(resultQueue.isEmpty(), is(true));
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -242,7 +247,7 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         resultQueue.add(new Result("test2"));
         resultQueue.add(new Result("test3"));
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         // you might want 30 but there are only three
         final CompletableFuture<List<Result>> future = resultQueue.await(30);
@@ -255,6 +260,7 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         assertEquals(3, results.size());
 
         assertThat(resultQueue.isEmpty(), is(true));
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -307,12 +313,14 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_BULKSET, new DefaultRemoteTraverser<>("belinda", 6));
         assertThat(o.isDone(), is(false));
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         assertThat(o.isDone(), is(true));
         final BulkSet<String> bulkSet = o.get().get(0).get(BulkSet.class);
         assertEquals(4, bulkSet.get("brian"));
         assertEquals(6, bulkSet.get("belinda"));
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -329,13 +337,15 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_LIST, "dave");
         assertThat(o.isDone(), is(false));
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         assertThat(o.isDone(), is(true));
         final List<String> list = o.get().get(0).get(ArrayList.class);
         assertEquals("stephen", list.get(0));
         assertEquals("daniel", list.get(1));
         assertEquals("dave", list.get(2));
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -352,13 +362,15 @@ public class ResultQueueTest extends AbstractResultQueueTest {
         resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_SET, "dave");
         assertThat(o.isDone(), is(false));
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         assertThat(o.isDone(), is(true));
         final Set<String> set = o.get().get(0).get(HashSet.class);
         assertThat(set.contains("stephen"), is(true));
         assertThat(set.contains("daniel"), is(true));
         assertThat(set.contains("dave"), is(true));
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -376,13 +388,15 @@ public class ResultQueueTest extends AbstractResultQueueTest {
             assertThat(o.isDone(), is(false));
         });
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         assertThat(o.isDone(), is(true));
         final Map<String, String> list = o.get().get(0).get(HashMap.class);
         assertEquals("stephen", list.get("s"));
         assertEquals("daniel", list.get("d"));
         assertEquals("marko", list.get("m"));
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
 
@@ -398,12 +412,14 @@ public class ResultQueueTest extends AbstractResultQueueTest {
 
         resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_NONE, m);
 
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         assertThat(o.isDone(), is(true));
         final Map<String, String> list = o.get().get(0).get(HashMap.class);
         assertEquals("stephen", list.get("s"));
         assertEquals("daniel", list.get("d"));
         assertEquals("marko", list.get("m"));
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fca7af7/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
index 3163ffe..44f13e4 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultSetTest.java
@@ -43,6 +43,10 @@ import static org.junit.Assert.fail;
  */
 public class ResultSetTest extends AbstractResultQueueTest {
 
+    private static final Map<String,Object> ATTRIBUTES = new HashMap<String,Object>() {{
+        put("this", "that");
+    }};
+
     private ResultSet resultSet;
 
     @Before
@@ -51,22 +55,6 @@ public class ResultSetTest extends AbstractResultQueueTest {
     }
 
     @Test
-    public void shouldReturnResponseAttributes() throws Exception {
-        resultQueue.statusAttributes = new HashMap<String,Object>() {{
-            put("test",123);
-            put("junk","here");
-        }};
-
-        final CompletableFuture<Map<String,Object>> attrs = resultSet.statusAttributes();
-        readCompleted.complete(null);
-
-        final Map<String,Object> m = attrs.get();
-        assertEquals(123, m.get("test"));
-        assertEquals("here", m.get("junk"));
-        assertEquals(2, m.size());
-    }
-
-    @Test
     public void shouldReturnEmptyMapForNoResponseAttributes() throws Exception {
         final CompletableFuture<Map<String,Object>> attrs = resultSet.statusAttributes();
         readCompleted.complete(null);
@@ -132,7 +120,7 @@ public class ResultSetTest extends AbstractResultQueueTest {
         resultQueue.add(new Result("test3"));
 
         assertThat(future.isDone(), is(false));
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
         assertThat(future.isDone(), is(true));
 
         final List<Result> results = future.get();
@@ -143,6 +131,8 @@ public class ResultSetTest extends AbstractResultQueueTest {
 
         assertThat(resultSet.allItemsAvailable(), is(true));
         assertEquals(0, resultSet.getAvailableItemCount());
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test
@@ -153,7 +143,7 @@ public class ResultSetTest extends AbstractResultQueueTest {
         resultQueue.add(new Result("test3"));
 
         assertThat(future.isDone(), is(false));
-        resultQueue.markComplete();
+        resultQueue.markComplete(ATTRIBUTES);
 
         final List<Result> results = future.get();
         assertEquals("test1", results.get(0).getString());
@@ -164,6 +154,8 @@ public class ResultSetTest extends AbstractResultQueueTest {
         assertThat(future.isDone(), is(true));
         assertThat(resultSet.allItemsAvailable(), is(true));
         assertEquals(0, resultSet.getAvailableItemCount());
+
+        assertEquals("that", resultQueue.getStatusAttributes().get("this"));
     }
 
     @Test


[20/22] tinkerpop git commit: TINKERPOP-1913 Retrieve status attributes through side-effects in python

Posted by sp...@apache.org.
TINKERPOP-1913 Retrieve status attributes through side-effects in python


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

Branch: refs/heads/master
Commit: 3aacd06fa84c4250505aad3809265a578cfc3d8f
Parents: d457d7c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 15:51:32 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 15:51:32 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                           | 2 +-
 .../jython/gremlin_python/driver/driver_remote_connection.py | 8 ++++----
 .../main/jython/gremlin_python/driver/remote_connection.py   | 7 ++++++-
 .../jython/tests/driver/test_driver_remote_connection.py     | 4 ++++
 4 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a151bc7..32094ea 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -39,7 +39,7 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Spark 2.3.1.
 * Modified Gremlin Server to return a "host" status attribute on responses.
 * Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retrieve status attributes from traversal side-effects.
+* Modified remote traversals to retrieve status attributes from traversal side-effects in Python and Java drivers.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
 * Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
 * Modified Python `GremlinServerError` to include status attributes.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index d447cbd..dcd2fa3 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -52,8 +52,8 @@ class DriverRemoteConnection(RemoteConnection):
     def submit(self, bytecode):
         result_set = self._client.submit(bytecode)
         results = result_set.all().result()
-        side_effects = RemoteTraversalSideEffects(result_set.request_id,
-                                                  self._client)
+        side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,
+                                                  result_set.status_attributes)
         return RemoteTraversal(iter(results), side_effects)
 
     def submitAsync(self, bytecode):
@@ -64,8 +64,8 @@ class DriverRemoteConnection(RemoteConnection):
             try:
                 result_set = f.result()
                 results = result_set.all().result()
-                side_effects = RemoteTraversalSideEffects(result_set.request_id,
-                                                          self._client)
+                side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,
+                                                          result_set.status_attributes)
                 future.set_result(RemoteTraversal(iter(results), side_effects))
             except Exception as e:
                 future.set_exception(e)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index b9ec4e5..e9b52a5 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -63,12 +63,17 @@ class RemoteTraversal(traversal.Traversal):
 
 
 class RemoteTraversalSideEffects(traversal.TraversalSideEffects):
-    def __init__(self, side_effect, client):
+    def __init__(self, side_effect, client, status_attributes):
         self._side_effect = side_effect
         self._client = client
         self._keys = set()
         self._side_effects = {}
         self._closed = False
+        self._status_attributes = status_attributes
+
+    @property
+    def status_attributes(self):
+        return self._status_attributes
 
     def keys(self):
         if not self._closed:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3aacd06f/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 627fbe4..0ef20c1 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -183,6 +183,10 @@ class TestDriverRemoteConnection(object):
         assert 1 == m["ripple"]
         assert isinstance(m["lop"], long)
         assert isinstance(m["ripple"], long)
+
+        # check status attributes
+        assert "host" in t.side_effects.status_attributes
+
         ##
         t = g.V().out("created").groupCount("m").by("name").name.aggregate("n")
         results = t.toSet()


[11/22] tinkerpop git commit: TINKERPOP-1913 Corrected status attributes messages after rebase

Posted by sp...@apache.org.
TINKERPOP-1913 Corrected status attributes messages after rebase

Test graphs are now named differently given the refactoring that went into improving integration configurations. Also fixed a bug in NO_CONTENT messages and added a test.


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

Branch: refs/heads/master
Commit: 24e08d2b99d77ae634576acc6cd0c4061d1b0bac
Parents: 60883a1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 16 08:08:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/server/op/AbstractOpProcessor.java |  1 +
 .../gremlin/server/GremlinResultSetIntegrateTest.java    | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/24e08d2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
index 767445a..cdbb706 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractOpProcessor.java
@@ -99,6 +99,7 @@ public abstract class AbstractOpProcessor implements OpProcessor {
             if (managedTransactionsForRequest) attemptCommit(msg, context.getGraphManager(), settings.strictTransactionManagement);
             rhc.writeAndFlush(ResponseMessage.build(msg)
                     .code(ResponseStatusCode.NO_CONTENT)
+                    .statusAttributes(generateStatusAttributes(ctx, msg, ResponseStatusCode.NO_CONTENT, itty, settings))
                     .create());
             return;
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/24e08d2b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
index bd71f1b..de17eb6 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
@@ -90,8 +90,15 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat
     }
 
     @Test
-    public void shouldReturnResponseAttributes() throws Exception {
-        final ResultSet results = client.submit("g.V()");
+    public void shouldReturnResponseAttributesViaNoContent() throws Exception {
+        final ResultSet results = client.submit("[]");
+        final Map<String,Object> attr = results.statusAttributes().get(20000, TimeUnit.MILLISECONDS);
+        assertThat(attr.containsKey(Tokens.ARGS_HOST), is(true));
+    }
+
+    @Test
+    public void shouldReturnResponseAttributesViaSuccess() throws Exception {
+        final ResultSet results = client.submit("gmodern.V()");
         final Map<String,Object> attr = results.statusAttributes().get(20000, TimeUnit.MILLISECONDS);
         assertThat(attr.containsKey(Tokens.ARGS_HOST), is(true));
     }


[22/22] tinkerpop git commit: Merge branch 'TINKERPOP-1913'

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1913'


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

Branch: refs/heads/master
Commit: d1a3fa147d1f009ae57274827c9b59426dfc6e58
Parents: 8971741 4e1b7e3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Sep 24 19:28:22 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Sep 24 19:28:22 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  5 ++
 docs/src/upgrade/release-3.4.x.asciidoc         | 10 +++
 .../src/Gremlin.Net/Driver/Connection.cs        | 19 ++++--
 .../Driver/Exceptions/ResponseException.cs      | 20 +++++-
 .../src/Gremlin.Net/Driver/GremlinClient.cs     |  2 +-
 .../Driver/GremlinClientExtensions.cs           |  4 +-
 .../src/Gremlin.Net/Driver/IConnection.cs       |  2 +-
 .../src/Gremlin.Net/Driver/IGremlinClient.cs    |  4 +-
 .../Driver/Messages/ResponseStatus.cs           |  2 +-
 .../Driver/Messages/ResponseStatusCode.cs       | 58 +++++++++++++++-
 .../src/Gremlin.Net/Driver/ProxyConnection.cs   |  2 +-
 .../src/Gremlin.Net/Driver/ResultSet.cs         | 69 ++++++++++++++++++++
 .../Driver/GremlinClientTests.cs                | 19 ++++++
 .../tinkerpop/gremlin/driver/Handler.java       | 18 +++--
 .../tinkerpop/gremlin/driver/ResultQueue.java   | 11 +++-
 .../tinkerpop/gremlin/driver/ResultSet.java     | 12 ++++
 .../driver/exception/ResponseException.java     | 31 +++++++--
 .../driver/remote/DriverRemoteTraversal.java    |  4 +-
 .../DriverRemoteTraversalSideEffects.java       | 25 +++++++
 .../gremlin/driver/AbstractResultQueueTest.java |  3 +-
 .../gremlin/driver/ResultQueueTest.java         | 30 +++++++--
 .../tinkerpop/gremlin/driver/ResultSetTest.java | 21 +++++-
 .../driver/driver_remote_connection.py          |  8 +--
 .../jython/gremlin_python/driver/protocol.py    | 12 +++-
 .../gremlin_python/driver/remote_connection.py  |  7 +-
 .../jython/gremlin_python/driver/resultset.py   |  9 +++
 .../src/main/jython/tests/driver/test_client.py | 13 ++++
 .../driver/test_driver_remote_connection.py     |  4 ++
 .../gremlin/server/op/AbstractOpProcessor.java  | 57 +++++++++++++---
 .../op/traversal/TraversalOpProcessor.java      | 11 +++-
 .../server/GremlinResultSetIntegrateTest.java   | 16 +++++
 .../server/GremlinServerIntegrateTest.java      |  8 ++-
 .../server/op/AbstractOpProcessorTest.java      |  2 +-
 33 files changed, 458 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


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


[03/22] tinkerpop git commit: Addressing review comments

Posted by sp...@apache.org.
Addressing review comments


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

Branch: refs/heads/master
Commit: 6310dabb7fc33c44b97ef75e9a8663aa17e51319
Parents: 705ce4e
Author: Ashwini Singh <as...@gmail.com>
Authored: Wed May 16 12:14:01 2018 -0700
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../src/Gremlin.Net/Driver/Connection.cs        | 10 +++++---
 .../src/Gremlin.Net/Driver/ResultSet.cs         | 27 ++++++++++++++------
 .../Driver/GremlinClientTests.cs                | 12 ++++-----
 3 files changed, 31 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 3663191..5b4be20 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -78,9 +78,10 @@ namespace Gremlin.Net.Driver
             await _webSocketConnection.SendMessageAsync(serializedMsg).ConfigureAwait(false);
         }
 
-        private async Task<IReadOnlyCollection<T>> ReceiveAsync<T>()
+        private async Task<ResultSet<T>> ReceiveAsync<T>()
         {
-            ResultSet<T> resultSet = new ResultSet<T>();
+            ResultSet<T> resultSet = null;
+            Dictionary<string, object> statusAttributes = null;
             ResponseStatus status;
             IAggregator aggregator = null;
             var isAggregatingSideEffects = false;
@@ -118,12 +119,13 @@ namespace Gremlin.Net.Driver
 
                 if (status.Code == ResponseStatusCode.Success || status.Code == ResponseStatusCode.NoContent)
                 {
-                    resultSet.StatusAttributes = receivedMsg.Status.Attributes;
+                    statusAttributes = receivedMsg.Status.Attributes;
                 }
 
             } while (status.Code == ResponseStatusCode.PartialContent || status.Code == ResponseStatusCode.Authenticate);
 
-            resultSet.Data = isAggregatingSideEffects ? new List<T> {(T) aggregator.GetAggregatedResult()} : result;
+
+            resultSet = new ResultSet<T>(isAggregatingSideEffects ? new List<T> { (T)aggregator.GetAggregatedResult() } : result, statusAttributes);
                 
             return resultSet;
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 2b1edfb..5d4a145 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -31,18 +31,29 @@ namespace Gremlin.Net.Driver
     /// A ResultSet is returned from the submission of a Gremlin script to the server and represents the results provided by the server
     /// ResultSet includes enumerable data and status attributes.
     /// </summary>
-    /// <typeparam name="T"></typeparam>
+    /// <typeparam name="T">Type of the result elements</typeparam>
     public sealed class ResultSet<T> : IReadOnlyCollection<T>
     {
         /// <summary>
-        ///  Gets and Sets the read only collection
+        ///  Gets or sets the data from the response
         /// </summary>
-        public IReadOnlyCollection<T> Data { get; set; }
+        public IReadOnlyCollection<T> Data { get; }
 
         /// <summary>
-        /// Gets or Sets the status attributes from the gremlin response
+        /// Gets or sets the status attributes from the gremlin response
         /// </summary>
-        public Dictionary<string, object> StatusAttributes { get; set; }
+        public Dictionary<string, object> StatusAttributes { get; }
+
+        /// <summary>
+        /// Initializes a new instance of the ResultSet class for the specified data and status attributes.
+        /// </summary>
+        /// <param name="data"></param>
+        /// <param name="attributes"></param>
+        public ResultSet(IReadOnlyCollection<T> data, Dictionary<string, object> attributes)
+        {
+            this.Data = data;
+            this.StatusAttributes = attributes;
+        }
 
         /// <summary>Returns an enumerator that iterates through the collection.</summary>
         /// <returns>An enumerator that can be used to iterate through the collection.</returns>
@@ -71,9 +82,9 @@ namespace Gremlin.Net.Driver
         /// <summary>
         /// Casts a IReadOnlyCollection to ResultSet
         /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="data"></param>
-        /// <returns></returns>
+        /// <typeparam name="T">Type of the result elements</typeparam>
+        /// <param name="data"> result data</param>
+        /// <returns>IReadOnlyCollection as ResultSet</returns>
         public static ResultSet<T> AsResultSet<T>(this IReadOnlyCollection<T> data)
         {
             if (!(data is ResultSet<T> resultSet))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
index a7e191f..bcb76e7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
@@ -30,6 +30,8 @@ using Gremlin.Net.Driver.Messages;
 using Gremlin.Net.IntegrationTest.Util;
 using Xunit;
 using Gremlin.Net.Structure.IO.GraphSON;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
 
 namespace Gremlin.Net.IntegrationTest.Driver
 {
@@ -174,16 +176,14 @@ namespace Gremlin.Net.IntegrationTest.Driver
             var gremlinServer = new GremlinServer(TestHost, TestPort);
             using (var gremlinClient = new GremlinClient(gremlinServer))
             {
-                var expectedResult = new List<int> { 1, 2, 3, 4, 5 };
-                var requestMsg = $"{nameof(expectedResult)}";
-                var bindings = new Dictionary<string, object> { { nameof(expectedResult), expectedResult } };
-
-                var response = await gremlinClient.SubmitAsync<int>(requestMsg, bindings);
+                var requestMsg = _requestMessageProvider.GetDummyMessage();
+                var response = await gremlinClient.SubmitAsync<int>(requestMsg);
 
                 var resultSet = response.AsResultSet();
-
                 Assert.NotNull(resultSet.StatusAttributes);
 
+                var values= resultSet.StatusAttributes["@value"] as JArray;
+                Assert.True(values.First.ToString().Equals("host"));
             }
         }
 


[06/22] tinkerpop git commit: Exposes ResultSet on GremlinClient. Adds StatusAttributes property on ResponseException. Removed explicit this from ResultSet to align with existing style.

Posted by sp...@apache.org.
Exposes ResultSet<T> on GremlinClient.
Adds StatusAttributes property on ResponseException.
Removed explicit this from ResultSet<T> to align with existing style.


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

Branch: refs/heads/master
Commit: 137f36510a134f4599dc30210341004b6912fbfd
Parents: 6310dab
Author: Patrik Husfloen <re...@redoz.com>
Authored: Wed Sep 5 23:40:57 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400

----------------------------------------------------------------------
 .../src/Gremlin.Net/Driver/Connection.cs        |  2 +-
 .../Driver/Exceptions/ResponseException.cs      | 10 ++++-
 .../src/Gremlin.Net/Driver/GremlinClient.cs     |  2 +-
 .../src/Gremlin.Net/Driver/IConnection.cs       |  2 +-
 .../src/Gremlin.Net/Driver/IGremlinClient.cs    |  4 +-
 .../Driver/Messages/ResponseStatus.cs           |  2 +-
 .../src/Gremlin.Net/Driver/ProxyConnection.cs   |  2 +-
 .../src/Gremlin.Net/Driver/ResultSet.cs         | 41 ++++----------------
 .../Driver/GremlinClientTests.cs                |  3 +-
 9 files changed, 24 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 5b4be20..822fc65 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -53,7 +53,7 @@ namespace Gremlin.Net.Driver
             _messageSerializer = new JsonMessageSerializer(mimeType);
         }
 
-        public async Task<IReadOnlyCollection<T>> SubmitAsync<T>(RequestMessage requestMessage)
+        public async Task<ResultSet<T>> SubmitAsync<T>(RequestMessage requestMessage)
         {
             await SendAsync(requestMessage).ConfigureAwait(false);
             return await ReceiveAsync<T>().ConfigureAwait(false);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
index 8d26106..3c0d927 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs
@@ -22,6 +22,7 @@
 #endregion
 
 using System;
+using System.Collections.Generic;
 
 namespace Gremlin.Net.Driver.Exceptions
 {
@@ -33,9 +34,16 @@ namespace Gremlin.Net.Driver.Exceptions
         /// <summary>
         ///     Initializes a new instance of the <see cref="ResponseException" /> class.
         /// </summary>
+        /// <param name="statusAttributes">The status attributes as returned by the server.</param>
         /// <param name="message">The error message string.</param>
-        public ResponseException(string message) : base(message)
+        public ResponseException(IReadOnlyDictionary<string, object> statusAttributes, string message) : base(message)
         {
+            StatusAttributes = statusAttributes;
         }
+
+        /// <summary>
+        /// Gets or sets the status attributes from the gremlin response
+        /// </summary>
+        public IReadOnlyDictionary<string, object> StatusAttributes { get; }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
index 2b47cbc..b933b37 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/GremlinClient.cs
@@ -68,7 +68,7 @@ namespace Gremlin.Net.Driver
         public int NrConnections => _connectionPool.NrConnections;
 
         /// <inheritdoc />
-        public async Task<IReadOnlyCollection<T>> SubmitAsync<T>(RequestMessage requestMessage)
+        public async Task<ResultSet<T>> SubmitAsync<T>(RequestMessage requestMessage)
         {
             using (var connection = await _connectionPool.GetAvailableConnectionAsync().ConfigureAwait(false))
             {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs
index e1651a6..b5ef52c 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/IConnection.cs
@@ -30,6 +30,6 @@ namespace Gremlin.Net.Driver
 {
     internal interface IConnection : IDisposable
     {
-        Task<IReadOnlyCollection<T>> SubmitAsync<T>(RequestMessage requestMessage);
+        Task<ResultSet<T>> SubmitAsync<T>(RequestMessage requestMessage);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs
index 7a7048a..9bef4be 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/IGremlinClient.cs
@@ -38,11 +38,11 @@ namespace Gremlin.Net.Driver
         /// </summary>
         /// <typeparam name="T">The type of the expected results.</typeparam>
         /// <param name="requestMessage">The <see cref="RequestMessage" /> to send.</param>
-        /// <returns>A collection of the data returned from the server.</returns>
+        /// <returns>A <see cref="ResultSet{T}"/> containing the data and status attributes returned from the server.</returns>
         /// <exception cref="Exceptions.ResponseException">
         ///     Thrown when a response is received from Gremlin Server that indicates
         ///     that an error occurred.
         /// </exception>
-        Task<IReadOnlyCollection<T>> SubmitAsync<T>(RequestMessage requestMessage);
+        Task<ResultSet<T>> SubmitAsync<T>(RequestMessage requestMessage);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
index e3c1797..c436662 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Messages/ResponseStatus.cs
@@ -44,7 +44,7 @@ namespace Gremlin.Net.Driver.Messages
         public static void ThrowIfStatusIndicatesError(this ResponseStatus status)
         {
             if (status.Code.IndicatesError())
-                throw new ResponseException($"{status.Code}: {status.Message}");
+                throw new ResponseException(status.Attributes, $"{status.Code}: {status.Message}");
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs
index cbe15ec..fef6ede 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ProxyConnection.cs
@@ -39,7 +39,7 @@ namespace Gremlin.Net.Driver
             _releaseAction = releaseAction;
         }
 
-        public async Task<IReadOnlyCollection<T>> SubmitAsync<T>(RequestMessage requestMessage)
+        public async Task<ResultSet<T>> SubmitAsync<T>(RequestMessage requestMessage)
         {
             return await _realConnection.SubmitAsync<T>(requestMessage).ConfigureAwait(false);
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 5d4a145..00a24d3 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -21,7 +21,6 @@
 
 #endregion
 
-using Gremlin.Net.Driver.Exceptions;
 using System.Collections;
 using System.Collections.Generic;
 
@@ -34,24 +33,21 @@ namespace Gremlin.Net.Driver
     /// <typeparam name="T">Type of the result elements</typeparam>
     public sealed class ResultSet<T> : IReadOnlyCollection<T>
     {
-        /// <summary>
-        ///  Gets or sets the data from the response
-        /// </summary>
-        public IReadOnlyCollection<T> Data { get; }
+        private readonly IReadOnlyCollection<T> _data;
 
         /// <summary>
         /// Gets or sets the status attributes from the gremlin response
         /// </summary>
-        public Dictionary<string, object> StatusAttributes { get; }
+        public IReadOnlyDictionary<string, object> StatusAttributes { get; }
 
         /// <summary>
         /// Initializes a new instance of the ResultSet class for the specified data and status attributes.
         /// </summary>
         /// <param name="data"></param>
         /// <param name="attributes"></param>
-        public ResultSet(IReadOnlyCollection<T> data, Dictionary<string, object> attributes)
+        public ResultSet(IReadOnlyCollection<T> data, IReadOnlyDictionary<string, object> attributes)
         {
-            this.Data = data;
+            _data = data;
             this.StatusAttributes = attributes;
         }
 
@@ -59,41 +55,18 @@ namespace Gremlin.Net.Driver
         /// <returns>An enumerator that can be used to iterate through the collection.</returns>
         public IEnumerator<T> GetEnumerator()
         {
-            return this.Data.GetEnumerator();
+            return _data.GetEnumerator();
         }
 
         /// <summary>Returns an enumerator that iterates through a collection.</summary>
         /// <returns>An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.</returns>
         IEnumerator IEnumerable.GetEnumerator()
         {
-            return this.GetEnumerator();
+            return _data.GetEnumerator();
         }
 
         /// <summary>Gets the number of elements in the collection.</summary>
         /// <returns>The number of elements in the collection. </returns>
-        public int Count => this.Data.Count;
+        public int Count => _data.Count;
     }
-
-    /// <summary>
-    /// Extension for IReadOnlyCollection 
-    /// </summary>
-    public static class ResultSetExtensions
-    {
-        /// <summary>
-        /// Casts a IReadOnlyCollection to ResultSet
-        /// </summary>
-        /// <typeparam name="T">Type of the result elements</typeparam>
-        /// <param name="data"> result data</param>
-        /// <returns>IReadOnlyCollection as ResultSet</returns>
-        public static ResultSet<T> AsResultSet<T>(this IReadOnlyCollection<T> data)
-        {
-            if (!(data is ResultSet<T> resultSet))
-            {
-                throw new ResponseException($"IReadOnlyCollection is not of type ResultSet");
-            }
-
-            return resultSet;
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/137f3651/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
index bcb76e7..6470924 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
@@ -177,9 +177,8 @@ namespace Gremlin.Net.IntegrationTest.Driver
             using (var gremlinClient = new GremlinClient(gremlinServer))
             {
                 var requestMsg = _requestMessageProvider.GetDummyMessage();
-                var response = await gremlinClient.SubmitAsync<int>(requestMsg);
+                var resultSet = await gremlinClient.SubmitAsync<int>(requestMsg);
 
-                var resultSet = response.AsResultSet();
                 Assert.NotNull(resultSet.StatusAttributes);
 
                 var values= resultSet.StatusAttributes["@value"] as JArray;


[21/22] tinkerpop git commit: TINKERPOP-1913 Updated changelog

Posted by sp...@apache.org.
TINKERPOP-1913 Updated changelog


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

Branch: refs/heads/master
Commit: 4e1b7e3f6dee956f5760837621972026e84dcd5c
Parents: 3aacd06
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 16:12:56 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 16:12:56 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e1b7e3f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 32094ea..99093ce 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -38,12 +38,11 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
 * Modified Gremlin Server to return a "host" status attribute on responses.
-* Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retrieve status attributes from traversal side-effects in Python and Java drivers.
-* Deprecated two `submit()`-related methods on the Java driver `Client` class.
+* Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server.
 * Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
 * Modified Python `GremlinServerError` to include status attributes.
 * Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
+* Deprecated two `submit()`-related methods on the Java driver `Client` class.
 * Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.
 * Fixed a bug in dynamic Gryo registration where registrations that did not have serializers would fail.


[18/22] tinkerpop git commit: TINKERPOP-1913 Added status attributes to ResultSet for python

Posted by sp...@apache.org.
TINKERPOP-1913 Added status attributes to ResultSet for python


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

Branch: refs/heads/master
Commit: 49b1507fdcf15bed2667beb205357cb44a4d57e8
Parents: bb01d96
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 15:06:46 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 15:06:46 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                          | 7 +++----
 .../src/main/jython/gremlin_python/driver/protocol.py       | 1 +
 .../src/main/jython/gremlin_python/driver/resultset.py      | 9 +++++++++
 gremlin-python/src/main/jython/tests/driver/test_client.py  | 3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e1b75dd..386f0d9 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -38,11 +38,10 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
 * Modified Gremlin Server to return a "host" status attribute on responses.
-* Added ability to the Java driver to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retreive status attributes from traversal side-effects.
+* Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
+* Modified remote traversals to retrieve status attributes from traversal side-effects.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
-* Modified Gremlin.Net `ResponseException` to include status code and status attributes.
-* Modified Java driver's `ResponseException` to include status code and status attributes.
+* Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
 * Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
 * Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index e0a2f7e..96174e0 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -90,6 +90,7 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
         elif status_code in [200, 206]:
             result_set.stream.put_nowait(data)
             if status_code == 200:
+                result_set.status_attributes = message['status']['attributes']
                 del results_dict[request_id]
             return status_code
         else:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
index cfdca5b..76e5029 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
@@ -28,6 +28,7 @@ class ResultSet:
         self._request_id = request_id
         self._done = None
         self._aggregate_to = None
+        self._status_attributes = {}
 
     @property
     def aggregate_to(self):
@@ -38,6 +39,14 @@ class ResultSet:
         self._aggregate_to = val
 
     @property
+    def status_attributes(self):
+        return self._status_attributes
+
+    @status_attributes.setter
+    def status_attributes(self, val):
+        self._status_attributes = val
+
+    @property
     def request_id(self):
         return self._request_id
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index fbfe2d7..44dc3a7 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -19,6 +19,7 @@ under the License.
 import pytest
 
 from gremlin_python.driver.client import Client
+from gremlin_python.driver.protocol import GremlinServerError
 from gremlin_python.driver.request import RequestMessage
 from gremlin_python.process.graph_traversal import __
 from gremlin_python.structure.graph import Graph
@@ -35,6 +36,8 @@ def test_connection(connection):
     results = future.result()
     assert len(results) == 6
     assert isinstance(results, list)
+    assert results_set.done.done()
+    assert 'host' in results_set.status_attributes
 
 
 def test_client_simple_eval(client):


[16/22] tinkerpop git commit: TINKERPOP-1913 Modified changelog

Posted by sp...@apache.org.
TINKERPOP-1913 Modified changelog


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

Branch: refs/heads/master
Commit: 55549cfd49817da35c4dd460b596c734daaaf011
Parents: 5eac32e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 12:45:15 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:43 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55549cfd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 2adc0dc..e1b75dd 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -37,7 +37,13 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Maintained order of annotations in metrics returned from `profile()`-step.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
+* Modified Gremlin Server to return a "host" status attribute on responses.
+* Added ability to the Java driver to retrieve status attributes returned from the server on the `ResultSet` object.
+* Modified remote traversals to retreive status attributes from traversal side-effects.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
+* Modified Gremlin.Net `ResponseException` to include status code and status attributes.
+* Modified Java driver's `ResponseException` to include status code and status attributes.
+* Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
 * Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.
 * Fixed a bug in dynamic Gryo registration where registrations that did not have serializers would fail.