Return-Path: X-Original-To: apmail-tinkerpop-commits-archive@minotaur.apache.org Delivered-To: apmail-tinkerpop-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ECF9718DD7 for ; Thu, 3 Dec 2015 16:43:24 +0000 (UTC) Received: (qmail 75548 invoked by uid 500); 3 Dec 2015 16:43:24 -0000 Delivered-To: apmail-tinkerpop-commits-archive@tinkerpop.apache.org Received: (qmail 75524 invoked by uid 500); 3 Dec 2015 16:43:24 -0000 Mailing-List: contact commits-help@tinkerpop.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.incubator.apache.org Delivered-To: mailing list commits@tinkerpop.incubator.apache.org Received: (qmail 75515 invoked by uid 99); 3 Dec 2015 16:43:24 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 16:43:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 67FF8CC69D for ; Thu, 3 Dec 2015 16:43:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id wP13STXpRb19 for ; Thu, 3 Dec 2015 16:43:09 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id CC3A525EBF for ; Thu, 3 Dec 2015 16:42:58 +0000 (UTC) Received: (qmail 70852 invoked by uid 99); 3 Dec 2015 16:42:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 16:42:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 78C12E6820; Thu, 3 Dec 2015 16:42:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: okram@apache.org To: commits@tinkerpop.incubator.apache.org Date: Thu, 03 Dec 2015 16:43:09 -0000 Message-Id: <13a9f4623f684fa1b63bf5ed156b8708@git.apache.org> In-Reply-To: <7ddfc1cac2064448b504bfb82908f6f4@git.apache.org> References: <7ddfc1cac2064448b504bfb82908f6f4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/50] incubator-tinkerpop git commit: GremlinServerExecutor includes "hostOptions" GremlinServerExecutor includes "hostOptions" Added some deprecation to a GremlinServer constructor - opens a bad usage of GremlinServerExecutor. Added a way to get the internally constructed GremlinServerExecutor from GremlinServer. Included a hostOptions Map in GremlinServerExecutor that will make it possible for embedding applications to include objects that can be used by the Channelizer. Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d4cd1dd2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d4cd1dd2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d4cd1dd2 Branch: refs/heads/TINKERPOP3-982 Commit: d4cd1dd2868190b539a74741d17c59e6a0a0ada3 Parents: b007e83 Author: Stephen Mallette Authored: Fri Nov 27 09:58:24 2015 -0500 Committer: Stephen Mallette Committed: Fri Nov 27 09:58:24 2015 -0500 ---------------------------------------------------------------------- .../tinkerpop/gremlin/server/GremlinServer.java | 9 +++++- .../server/util/ServerGremlinExecutor.java | 32 +++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d4cd1dd2/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 2104e2f..c2c18b7 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 @@ -86,7 +86,6 @@ public class GremlinServer { logger.warn("cannot use epoll in non-linux env, falling back to NIO"); } - Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown")); final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d"); @@ -114,7 +113,11 @@ public class GremlinServer { * pre-constructed objects used by the server as well as the {@link Settings} object itself. 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. + * + * @deprecated As of release 3.1.1-incubating, not replaced. + * @see TINKERPOP3-912 */ + @Deprecated public GremlinServer(final ServerGremlinExecutor serverGremlinExecutor) { this.serverGremlinExecutor = serverGremlinExecutor; this.settings = serverGremlinExecutor.getSettings(); @@ -310,6 +313,10 @@ public class GremlinServer { return serverStopped; } + public ServerGremlinExecutor getServerGremlinExecutor() { + return serverGremlinExecutor; + } + public static void main(final String[] args) throws Exception { // add to vm options: -Dlog4j.configuration=file:conf/log4j.properties printHeader(); http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d4cd1dd2/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java index fe3c9a5..3fa568c 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java @@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.server.util; import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor; import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; +import org.apache.tinkerpop.gremlin.server.Channelizer; import org.apache.tinkerpop.gremlin.server.GraphManager; import org.apache.tinkerpop.gremlin.server.GremlinServer; import org.apache.tinkerpop.gremlin.server.Settings; @@ -27,8 +28,11 @@ import org.apache.tinkerpop.gremlin.structure.Graph; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -37,11 +41,11 @@ import java.util.stream.Collectors; /** * The core of script execution in Gremlin Server. Given {@link Settings} and optionally other arguments, this - * class will construct a {@link GremlinExecutor} to be used by Gremlin Server. Those expecting to build their - * own version of Gremlin Server might consider coring their implementation with this class as it provides some - * basic infrastructure required for most of Gremlin Server script processing features. Those embedding Gremlin - * Server in another application might consider using this class to initialize the {@link GremlinServer} class - * as it will allow sharing of thread pool resources. + * class will construct a {@link GremlinExecutor} to be used by Gremlin Server. A typical usage would be to + * instantiate the {@link GremlinServer} and then immediately call {@link GremlinServer#getServerGremlinExecutor()} + * which would allow the opportunity to assign "host options" which could be used by a custom {@link Channelizer}. + * Add these options before calling {@link GremlinServer#start()} to be sure the {@link Channelizer} gets access to + * those. * * @author Stephen Mallette (http://stephen.genoprime.com) */ @@ -56,6 +60,8 @@ public class ServerGremlinExecutor { private final ExecutorService gremlinExecutorService; private final GremlinExecutor gremlinExecutor; + private final Map hostOptions = new ConcurrentHashMap<>(); + /** * Create a new object from {@link Settings} where thread pools are internally created. Note that the * {@code scheduleExecutorServiceClass} will be created via @@ -138,6 +144,22 @@ public class ServerGremlinExecutor { .collect(Collectors.toList()); } + public void addHostOption(final String key, final Object value) { + hostOptions.put(key, value); + } + + public Map getHostOptions() { + return Collections.unmodifiableMap(hostOptions); + } + + public Object removeHostOption(final String key) { + return hostOptions.remove(key); + } + + public void clearHostOptions() { + hostOptions.clear(); + } + public T getScheduledExecutorService() { return scheduledExecutorService; }