Repository: tinkerpop Updated Branches: refs/heads/tp33 c466efad6 -> aab821826
Support construct a GremlinServer instance from gremlin executor service This constructor is useful when Gremlin Server is being used in an embedded style and there is a need to share thread pools with the hosting application. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d3dbd137 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d3dbd137 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d3dbd137 Branch: refs/heads/tp33 Commit: d3dbd13777f91ec1cd94fc83d309300c6181d29a Parents: 2fd0f25 Author: Jermy Li <javalov...@gmail.com> Authored: Thu Mar 8 19:10:48 2018 +0800 Committer: Jermy Li <javalov...@gmail.com> Committed: Mon Mar 19 20:16:58 2018 +0800 ---------------------------------------------------------------------- .../apache/tinkerpop/gremlin/server/GremlinServer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d3dbd137/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java index 5b04ebe..55a1d84 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java @@ -81,6 +81,15 @@ public class GremlinServer { * Construct a Gremlin Server instance from {@link Settings}. */ public GremlinServer(final Settings settings) { + this(settings, null); + } + + /** + * Construct a Gremlin Server instance from {@link Settings} and {@link ExecutorService}. + * This constructor is useful when Gremlin Server is being used in an embedded style + * and there is a need to share thread pools with the hosting application. + */ + public GremlinServer(final Settings settings, final ExecutorService gremlinExecutorService) { settings.optionalMetrics().ifPresent(GremlinServer::configureMetrics); this.settings = settings; provideDefaultForGremlinPoolSize(settings); @@ -108,8 +117,8 @@ public class GremlinServer { workerGroup = new NioEventLoopGroup(settings.threadPoolWorker, threadFactoryWorker); } - serverGremlinExecutor = new ServerGremlinExecutor(settings, null, workerGroup); - gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); + serverGremlinExecutor = new ServerGremlinExecutor(settings, gremlinExecutorService, workerGroup); + this.gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); // initialize the OpLoader with configurations being passed to each OpProcessor implementation loaded OpLoader.init(settings);