tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [11/50] [abbrv] tinkerpop git commit: Cleaned up error processing on remote side-effects.
Date Wed, 23 Nov 2016 01:36:28 GMT
Cleaned up error processing on remote side-effects.

The old method for parsing error message text from the server was kinda ugly and after recent
refactoring it is ultimately unecessary as the keys are all known prior to a call to get()
going through. Calls to get() will trap bad keys and make the "remote" side-effects behave
like local ones and simply throw the appropriate exception. CTR


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

Branch: refs/heads/TINKERPOP-1529-variant2
Commit: d0f02027208f45c186a58c0e5c26b606acf8e165
Parents: 9737506
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Mon Nov 14 15:49:01 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Mon Nov 14 15:49:01 2016 -0500

----------------------------------------------------------------------
 .../DriverRemoteTraversalSideEffects.java       | 21 +++++++++-----------
 .../DriverRemoteTraversalSideEffectsTest.java   |  2 --
 2 files changed, 9 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0f02027/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 e13c33e..8d6fa98 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
@@ -33,7 +33,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Java driver implementation of {@link TraversalSideEffects}. This class is not thread safe.
@@ -51,7 +50,6 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
 
     private boolean closed = false;
     private boolean retrievedAllKeys = false;
-    private final AtomicInteger counter = new AtomicInteger(0);
 
     public DriverRemoteTraversalSideEffects(final Client client, final UUID serverSideEffect,
final Host host) {
         this.client = client;
@@ -78,12 +76,13 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
                 final Result result = client.submitAsync(msg).get().all().get().get(0);
                 sideEffects.put(key, null == result ? null : result.getObject());
             } catch (Exception ex) {
-                final Throwable root = ExceptionUtils.getRootCause(ex);
-                final String exMsg = null == root ? "" : root.getMessage();
-                if (exMsg.equals("Could not find side-effects for " + serverSideEffect +
"."))
-                    sideEffects.put(key, null);
-                else
-                    throw new RuntimeException("Could not get side-effect for " + serverSideEffect
+ " with key of " + key, root == null ? ex : root);
+                // we use to try to catch  "no found" situations returned from the server
here and then null the
+                // side-effect for the requested key. doesn't seem like there is a need for
that now because calls
+                // to get() now initially trigger a call the keys() so you would know all
of the keys available on
+                // the server and would validate them up front throwing sideEffectKeyDoesNotExist(key)
which thus
+                // produces behavior similar to the non-remote side-effect implementations.
if we get an exception
+                // here at this point then we likely have a legit error in communicating
to the remote server.
+                throw new RuntimeException("Could not get side-effect for " + serverSideEffect
+ " with key of " + key, ex);
             }
         }
 
@@ -111,9 +110,7 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
                 retrievedAllKeys = true;
             } catch (Exception ex) {
                 final Throwable root = ExceptionUtils.getRootCause(ex);
-                final String exMsg = null == root ? "" : root.getMessage();
-                if (!exMsg.equals("Could not find side-effects for " + serverSideEffect +
"."))
-                    throw new RuntimeException("Could not get keys", root);
+                throw new RuntimeException("Could not get keys", null == root ? ex : root);
             }
         }
 
@@ -132,7 +129,7 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
                 closed = true;
             } catch (Exception ex) {
                 final Throwable root = ExceptionUtils.getRootCause(ex);
-                throw new RuntimeException("Error on closing side effects", root);
+                throw new RuntimeException("Error on closing side effects", null == root
? ex : root);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d0f02027/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
index c589733..27d0079 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffectsTest.java
@@ -24,7 +24,6 @@ import org.apache.tinkerpop.gremlin.driver.ResultSet;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 import java.util.UUID;
@@ -123,7 +122,6 @@ public class DriverRemoteTraversalSideEffectsTest extends AbstractResultQueueTes
     }
 
     private void mockClientForCall(final Client client) throws Exception {
-
         // the return is just generic garbage from addToQueue for any call to submitAsync().
         when(client.submitAsync(any(RequestMessage.class))).thenAnswer((Answer<Object>)
invocationOnMock -> {
             final ResultSet returnedResultSet = new ResultSet(resultQueue, pool, readCompleted,
RequestMessage.build("traversal").create(), null);


Mime
View raw message