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 2015/03/04 13:55:19 UTC
incubator-tinkerpop git commit: Moved stopwatch functionality into
handleIterator.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 30e0604d2 -> 14c54a552
Moved stopwatch functionality into handleIterator.
It is now completely the responsibility of the implementer to break result iteration if it exceeds serialization time. A good implementation will do that.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/14c54a55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/14c54a55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/14c54a55
Branch: refs/heads/master
Commit: 14c54a5528ac05f2527707135f57528935f9c34f
Parents: 30e0604
Author: Stephen Mallette <sp...@apache.org>
Authored: Wed Mar 4 07:54:05 2015 -0500
Committer: Stephen Mallette <sp...@apache.org>
Committed: Wed Mar 4 07:54:05 2015 -0500
----------------------------------------------------------------------
.../server/op/AbstractEvalOpProcessor.java | 24 ++++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/14c54a55/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
index e6dd7de..a353e6d 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java
@@ -148,20 +148,13 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
final CompletableFuture<Void> iterationFuture = evalFuture.thenAcceptAsync(o -> {
final Iterator itty = IteratorUtils.convertToIterator(o);
- // timer for the total serialization time
- final StopWatch stopWatch = new StopWatch();
-
logger.debug("Preparing to iterate results from - {} - in thread [{}]", msg, Thread.currentThread().getName());
- stopWatch.start();
-
try {
- handleIterator(context, itty, stopWatch);
+ handleIterator(context, itty);
} catch (TimeoutException te) {
throw new RuntimeException(te);
}
-
- stopWatch.stop();
}, executor);
iterationFuture.handleAsync((r, ex) -> {
@@ -179,15 +172,24 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
}
/**
- * Called by {@link #evalOpInternal} when iterating a result set.
+ * Called by {@link #evalOpInternal} when iterating a result set. Implementers should respect the
+ * {@link Settings#serializedResponseTimeout} configuration and break the serialization process if
+ * it begins to take too long to do so, throwing a {@link java.util.concurrent.TimeoutException} in such
+ * cases.
*
+ * @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.
*/
- protected void handleIterator(final Context context, final Iterator itty, final StopWatch stopWatch) throws TimeoutException {
+ protected void handleIterator(final Context context, final Iterator itty) throws TimeoutException {
final ChannelHandlerContext ctx = context.getChannelHandlerContext();
final RequestMessage msg = context.getRequestMessage();
final Settings settings = context.getSettings();
+ // timer for the total serialization time
+ final StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+
// the batch size can be overridden by the request
final int resultIterationBatchSize = (Integer) msg.optionalArgs(Tokens.ARGS_BATCH_SIZE).orElse(settings.resultIterationBatchSize);
List<Object> aggregate = new ArrayList<>(resultIterationBatchSize);
@@ -209,5 +211,7 @@ public abstract class AbstractEvalOpProcessor implements OpProcessor {
stopWatch.unsplit();
}
+
+ stopWatch.stop();
}
}