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 2017/10/12 16:47:25 UTC
[1/2] tinkerpop git commit: TINKERPOP-1761: Cancel script evaluation
timeout in when script evaluation finished.
Repository: tinkerpop
Updated Branches:
refs/heads/tp32 1fa01ef70 -> 021db5654
TINKERPOP-1761: Cancel script evaluation timeout in when script evaluation finished.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2a8c92f2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2a8c92f2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2a8c92f2
Branch: refs/heads/tp32
Commit: 2a8c92f245aa28b66c616e62230bfd3972e7e5b9
Parents: 60a34d1
Author: Konstantin Mueller <ko...@mnemonic.no>
Authored: Mon Sep 11 11:25:12 2017 +0200
Committer: Konstantin Mueller <ko...@mnemonic.no>
Committed: Mon Sep 11 11:25:12 2017 +0200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../gremlin/groovy/engine/GremlinExecutor.java | 14 +++++++++++++-
.../gremlin/groovy/engine/GremlinExecutorTest.java | 13 +++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8c92f2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ff0948a..fe1da7a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -34,6 +34,7 @@ TinkerPop 3.2.7 (Release Date: NOT OFFICIALLY RELEASED YET)
* Fixed a bug in `Neo4jGremlinPlugin` that prevented it from loading properly in the `GremlinPythonScriptEngine`.
* Fixed a bug in `ComputerVerificationStrategy` where child traversals were being analyzed prior to compilation.
* Fixed a bug that prevented Gremlin from ordering lists and streams made of mixed number types.
+* Cancel script evaluation timeout in `GremlinExecutor` when script evaluation finished.
[[release-3-2-6]]
TinkerPop 3.2.6 (Release Date: August 21, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8c92f2/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 fabc8cb..dd01f74 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
@@ -56,6 +56,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -329,7 +330,7 @@ public class GremlinExecutor implements AutoCloseable {
final Future<?> executionFuture = executorService.submit(evalFuture);
if (scriptEvalTimeOut > 0) {
// Schedule a timeout in the thread pool for future execution
- scheduledExecutorService.schedule(() -> {
+ final ScheduledFuture<?> sf = scheduledExecutorService.schedule(() -> {
if (executionFuture.cancel(true)) {
final CompletableFuture<Object> ef = evaluationFutureRef.get();
if (ef != null) {
@@ -338,6 +339,17 @@ public class GremlinExecutor implements AutoCloseable {
}
}
}, scriptEvalTimeOut, TimeUnit.MILLISECONDS);
+
+ // Cancel the scheduled timeout if the eval future is complete or the script evaluation failed with exception
+ evaluationFuture.handleAsync((v, t) -> {
+ if (!sf.isDone()) {
+ logger.debug("Killing scheduled timeout on script evaluation - {} - as the eval completed (possibly with exception).", script);
+ sf.cancel(true);
+ }
+
+ // no return is necessary - nothing downstream is concerned with what happens in here
+ return null;
+ }, scheduledExecutorService);
}
return evaluationFuture;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8c92f2/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 8aed8a6..ca361a0 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
@@ -418,6 +418,19 @@ public class GremlinExecutorTest {
}
@Test
+ public void shouldCancelTimeoutOnSuccessfulEval() throws Exception {
+ final long scriptEvaluationTimeout = 5_000;
+ final GremlinExecutor gremlinExecutor = GremlinExecutor.build()
+ .scriptEvaluationTimeout(scriptEvaluationTimeout)
+ .create();
+
+ final long now = System.currentTimeMillis();
+ assertEquals(2, gremlinExecutor.eval("1+1").get());
+ gremlinExecutor.close();
+ assertTrue(System.currentTimeMillis() - now < scriptEvaluationTimeout);
+ }
+
+ @Test
public void shouldEvalInMultipleThreads() throws Exception {
final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create();
[2/2] tinkerpop git commit: Merge branch 'pr-709' into tp32
Posted by sp...@apache.org.
Merge branch 'pr-709' into tp32
Conflicts:
CHANGELOG.asciidoc
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/021db565
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/021db565
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/021db565
Branch: refs/heads/tp32
Commit: 021db56542f68dbd104ea7c8ed56c86aa50c3237
Parents: 1fa01ef 2a8c92f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Oct 12 12:46:51 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Oct 12 12:46:51 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 3 ++-
.../gremlin/groovy/engine/GremlinExecutor.java | 14 +++++++++++++-
.../gremlin/groovy/engine/GremlinExecutorTest.java | 13 +++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/021db565/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 2f6069d,fe1da7a..d8fe716
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -43,10 -34,11 +43,11 @@@ image::https://raw.githubusercontent.co
* Fixed a bug in `Neo4jGremlinPlugin` that prevented it from loading properly in the `GremlinPythonScriptEngine`.
* Fixed a bug in `ComputerVerificationStrategy` where child traversals were being analyzed prior to compilation.
* Fixed a bug that prevented Gremlin from ordering lists and streams made of mixed number types.
- * Fixed a bug where `keepLabels` were being corrupted because a defensive copy was not being made when they were being set by `PathRetractionStrategy`.
++* Fixed a bug where `keepLabels` were being corrupted because a defensive copy was not being made when they were being set by `PathRetractionStrategy`.
+ * Cancel script evaluation timeout in `GremlinExecutor` when script evaluation finished.
[[release-3-2-6]]
-TinkerPop 3.2.6 (Release Date: August 21, 2017)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+=== TinkerPop 3.2.6 (Release Date: August 21, 2017)
This release also includes changes from <<release-3-1-8, 3.1.8>>.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/021db565/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java
----------------------------------------------------------------------