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

[1/3] incubator-tinkerpop git commit: Complete the eval() future after the whole lifecycle.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master c4690b2dc -> 93cc98e78


Complete the eval() future after the whole lifecycle.

This prevents problems with where the eval future would complete but then an exeption would toss later in the lifecycle and the future wouldn't get notified again.  Fixed a test where this problem was previously hiding that the test was erroring out. CTR


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

Branch: refs/heads/master
Commit: da5abb0534123dbf2707fdece6b98d6846a12a27
Parents: 675d981
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Mar 14 15:25:33 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Mar 14 15:28:26 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../engine/GremlinExecutorOverGraphTest.java    |  7 ++---
 .../gremlin/groovy/engine/GremlinExecutor.java  | 12 ++++++---
 .../groovy/engine/GremlinExecutorTest.java      | 27 ++++++++++++++++----
 4 files changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/da5abb05/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e03e3bf..fd6a766 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* The future from `GremlinExecutor.eval()` is completed after the entire evaluation lifecyle is completed.
 * Spark `Memory` uses `collect().iterator()` instead of `toLocalIterator()` to reduce noise in Spark UI.
 * Added the `:remote console` option which flips the Gremlin Console into a remote-only mode where all script evaluation is routed to the currently configured remote, which removes the need to use the `:>` command.
 * Added `allowRemoteConsole()` to the `RemoteAcceptor` interface.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/da5abb05/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java
index cc6b34f..4ee3bf2 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.groovy.engine;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.junit.Test;
 
@@ -50,9 +51,9 @@ public class GremlinExecutorOverGraphTest extends AbstractGremlinTest {
         final ExecutorService evalExecutor = Executors.newSingleThreadExecutor(testingThreadFactory);
         final GremlinExecutor gremlinExecutor = GremlinExecutor.build()
                 .afterSuccess(b -> {
-                    final Graph graph = (Graph) b.get("g");
-                    if (graph.features().graph().supportsTransactions())
-                        graph.tx().commit();
+                    final GraphTraversalSource g = (GraphTraversalSource) b.get("g");
+                    if (g.getGraph().get().features().graph().supportsTransactions())
+                        g.tx().commit();
                 })
                 .executorService(evalExecutor).create();
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/da5abb05/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java
index df8b583..edd421d 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java
@@ -262,7 +262,6 @@ public class GremlinExecutor implements AutoCloseable {
                 // transactional constraints
                 final Object result = lifeCycle.getTransformResult().isPresent() ?
                         lifeCycle.getTransformResult().get().apply(o) : o;
-                evaluationFuture.complete(result);
 
                 // a mechanism for taking the final result and doing something with it in the same thread, but
                 // AFTER the eval and transform are done and that future completed.  this provides a final means
@@ -270,6 +269,12 @@ public class GremlinExecutor implements AutoCloseable {
                 if (lifeCycle.getWithResult().isPresent()) lifeCycle.getWithResult().get().accept(result);
 
                 lifeCycle.getAfterSuccess().orElse(afterSuccess).accept(bindings);
+
+                // the evaluationFuture must be completed after all processing as an exception in lifecycle events
+                // that must raise as an exception to the caller who has the returned evaluationFuture. in other words,
+                // if it occurs before this point, then the handle() method won't be called again if there is an
+                // exception that ends up below trying to completeExceptionally()
+                evaluationFuture.complete(result);
             } catch (Throwable ex) {
                 final Throwable root = null == ex.getCause() ? ex : ExceptionUtils.getRootCause(ex);
 
@@ -746,7 +751,7 @@ public class GremlinExecutor implements AutoCloseable {
 
             /**
              * Specifies the function to execute on the result of the script evaluation just after script evaluation
-             * returns but after the script evaluation is marked as complete.
+             * returns but before the script evaluation is marked as complete.
              */
             public Builder withResult(final Consumer<Object> withResult) {
                 this.withResult = withResult;
@@ -755,7 +760,8 @@ public class GremlinExecutor implements AutoCloseable {
 
             /**
              * Specifies the function to execute after result transformations.  This function can also be
-             * specified globally on {@link GremlinExecutor.Builder#afterSuccess(Consumer)}.
+             * specified globally on {@link GremlinExecutor.Builder#afterSuccess(Consumer)}. The script evaluation
+             * will be marked as "complete" after this method.
              */
             public Builder afterSuccess(final Consumer<Bindings> afterSuccess) {
                 this.afterSuccess = afterSuccess;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/da5abb05/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java
index aad1f77..22c1699 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java
@@ -24,11 +24,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCust
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptTimeoutException;
 import org.javatuples.Pair;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.script.Bindings;
 import javax.script.CompiledScript;
@@ -41,7 +37,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.ExecutorService;
@@ -85,6 +81,27 @@ public class GremlinExecutorTest {
     }
 
     @Test
+    public void shouldRaiseExceptionInWithResultOfLifeCycle() throws Exception {
+        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create();
+        final GremlinExecutor.LifeCycle lc = GremlinExecutor.LifeCycle.build()
+                .withResult(r -> {
+                    throw new RuntimeException("no worky");
+                }).create();
+
+        final AtomicBoolean exceptionRaised = new AtomicBoolean(false);
+
+        final CompletableFuture<Object> future = gremlinExecutor.eval("1+1", "gremlin-groovy", new SimpleBindings(), lc);
+        future.handle((r, t) -> {
+            exceptionRaised.set(t != null && t instanceof RuntimeException && t.getMessage().equals("no worky"));
+            return null;
+        }).get();
+
+        assertThat(exceptionRaised.get(), is(true));
+
+        gremlinExecutor.close();
+    }
+
+    @Test
     public void shouldEvalScript() throws Exception {
         final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create();
         assertEquals(2, gremlinExecutor.eval("1+1").get());


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

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


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

Branch: refs/heads/master
Commit: 93cc98e78b9bc3bf058d81b5f711dd05b27be8b3
Parents: c4690b2 e8b6f8e
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Mar 15 20:54:31 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Mar 15 20:54:31 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 ++
 .../gremlin/structure/io/gryo/GryoMapper.java   |  4 +--
 .../engine/GremlinExecutorOverGraphTest.java    |  7 ++---
 .../gremlin/groovy/engine/GremlinExecutor.java  | 12 ++++++---
 .../groovy/engine/GremlinExecutorTest.java      | 27 ++++++++++++++++----
 5 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/93cc98e7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------


[2/3] incubator-tinkerpop git commit: Fixed a severe bug where LP_O_OB_P_S_SE_SL_Traverser was not registered by GryoMapper.

Posted by ok...@apache.org.
Fixed a severe bug where LP_O_OB_P_S_SE_SL_Traverser was not registered by GryoMapper.


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

Branch: refs/heads/master
Commit: e8b6f8e430d2f73468cd7ae969a8c3b6eba55da0
Parents: da5abb0
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Mar 15 20:52:17 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Mar 15 20:52:17 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                               | 1 +
 .../apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e8b6f8e4/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index fd6a766..53c817f 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.2 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed a severe bug where `LP_O_OB_P_S_SE_SL_Traverser` was not registered with `GryoMapper`.
 * The future from `GremlinExecutor.eval()` is completed after the entire evaluation lifecyle is completed.
 * Spark `Memory` uses `collect().iterator()` instead of `toLocalIterator()` to reduce noise in Spark UI.
 * Added the `:remote console` option which flips the Gremlin Console into a remote-only mode where all script evaluation is routed to the currently configured remote, which removes the need to use the `:>` command.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e8b6f8e4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
index c20655e..d652932 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
@@ -28,7 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_LP_O_P_S_SE_SL
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_LP_O_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.LP_O_OB_P_S_SE_SL_TraverserGenerator;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.LP_O_OB_P_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.LP_O_OB_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.O_OB_S_SE_SL_Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.O_Traverser;
@@ -284,7 +284,7 @@ public final class GryoMapper implements Mapper<Kryo> {
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(B_LP_O_S_SE_SL_Traverser.class, null, 87));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(O_OB_S_SE_SL_Traverser.class, null, 89));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(LP_O_OB_S_SE_SL_Traverser.class, null, 90));
-            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(LP_O_OB_P_S_SE_SL_TraverserGenerator.class, null, 91));
+            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(LP_O_OB_P_S_SE_SL_Traverser.class, null, 91));
 
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TraverserSet.class, null, 58));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Tree.class, null, 61));