Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-999 [created] 4c89e1594


TINKERPOP-999 Removed generics from ServerGremlinExecutor


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

Branch: refs/heads/TINKERPOP-999
Commit: 4c89e1594537f02c4bb3f0efa60f3e5042621442
Parents: 268333b
Author: Stephen Mallette <[email protected]>
Authored: Tue Jun 20 15:14:44 2017 -0400
Committer: Stephen Mallette <[email protected]>
Committed: Tue Jun 20 15:14:44 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../gremlin/server/AbstractChannelizer.java     |  4 +-
 .../tinkerpop/gremlin/server/Channelizer.java   |  3 +-
 .../tinkerpop/gremlin/server/GremlinServer.java | 42 +++-----------------
 .../gremlin/server/channel/HttpChannelizer.java |  4 +-
 .../gremlin/server/channel/NioChannelizer.java  |  3 +-
 .../server/channel/WebSocketChannelizer.java    |  3 +-
 .../server/util/ServerGremlinExecutor.java      | 36 +++--------------
 8 files changed, 17 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 58a3a62..ba591c2 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,7 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Added "attachment requisite" `VertexProperty.element()` and 
`Property.element()` data in GraphSON serialization.
 * GraphSON 3.0 is now the default serialization format in TinkerGraph and 
Gremlin Server.
 * Established the GraphSON 3.0 format.
+* Changed `ServerGremlinExecutor` to not use generics since there really is no 
flexibility in the kind of `ScheduledExecutorService` that will be used.
 * Removed previously deprecated `OpSelectorHandler.errorMeter` and 
`AbstractEvalOpProcessor.errorMeter` fields.
 * Removed previously deprecated `AbstractEvalOpProcessor.validBindingName` 
field.
 * Removed previously deprecated 
`SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION` field.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
index bcaa2e4..086074a 100644
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.server;
 
-import io.netty.channel.EventLoopGroup;
 import io.netty.handler.ssl.SslContext;
 import io.netty.handler.ssl.SslContextBuilder;
 import io.netty.handler.ssl.SslProvider;
@@ -53,7 +52,6 @@ import java.util.Optional;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.stream.Stream;
-import java.util.Iterator;
 
 /**
  * A base implementation for the {@code Channelizer} which does a basic 
configuration of the pipeline, one that
@@ -110,7 +108,7 @@ public abstract class AbstractChannelizer extends 
ChannelInitializer<SocketChann
     }
 
     @Override
-    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor) {
+    public void init(final ServerGremlinExecutor serverGremlinExecutor) {
         settings = serverGremlinExecutor.getSettings();
         gremlinExecutor = serverGremlinExecutor.getGremlinExecutor();
         graphManager = serverGremlinExecutor.getGraphManager();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
index fd7821e..31c65c1 100644
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
@@ -19,7 +19,6 @@
 package org.apache.tinkerpop.gremlin.server;
 
 import io.netty.channel.ChannelHandler;
-import io.netty.channel.EventLoopGroup;
 import org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor;
 
 /**
@@ -35,5 +34,5 @@ public interface Channelizer extends ChannelHandler {
     /**
      * This method is called just after the {@code Channelizer} is initialized.
      */
-    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor);
+    public void init(final ServerGremlinExecutor serverGremlinExecutor);
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/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 50427fd..068e1a4 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
@@ -69,12 +69,12 @@ public class GremlinServer {
     private Channel ch;
 
     private CompletableFuture<Void> serverStopped = null;
-    private CompletableFuture<ServerGremlinExecutor<EventLoopGroup>> 
serverStarted = null;
+    private CompletableFuture<ServerGremlinExecutor> serverStarted = null;
 
     private final EventLoopGroup bossGroup;
     private final EventLoopGroup workerGroup;
     private final ExecutorService gremlinExecutorService;
-    private final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor;
+    private final ServerGremlinExecutor serverGremlinExecutor;
     private final boolean isEpollEnabled;
 
     /**
@@ -108,7 +108,7 @@ public class GremlinServer {
             workerGroup = new NioEventLoopGroup(settings.threadPoolWorker, 
threadFactoryWorker);
         }
 
-        serverGremlinExecutor = new ServerGremlinExecutor<>(settings, null, 
workerGroup, EventLoopGroup.class);
+        serverGremlinExecutor = new ServerGremlinExecutor(settings, null, 
workerGroup, null);
         gremlinExecutorService = 
serverGremlinExecutor.getGremlinExecutorService();
 
         // initialize the OpLoader with configurations being passed to each 
OpProcessor implementation loaded
@@ -116,46 +116,16 @@ public class GremlinServer {
     }
 
     /**
-     * Construct a Gremlin Server instance from the {@link 
ServerGremlinExecutor} which internally carries some
-     * 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 <a 
href="https://issues.apache.org/jira/browse/TINKERPOP-912";>TINKERPOP-912</a>
-     */
-    @Deprecated
-    public GremlinServer(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor) {
-        this.serverGremlinExecutor = serverGremlinExecutor;
-        this.settings = serverGremlinExecutor.getSettings();
-        this.isEpollEnabled = settings.useEpollEventLoop && 
SystemUtils.IS_OS_LINUX;
-        if(settings.useEpollEventLoop && !SystemUtils.IS_OS_LINUX){
-            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");
-        if(isEpollEnabled) {
-            bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, 
threadFactoryBoss);
-        } else{
-            bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, 
threadFactoryBoss);
-        }
-        workerGroup = serverGremlinExecutor.getScheduledExecutorService();
-        gremlinExecutorService = 
serverGremlinExecutor.getGremlinExecutorService();
-    }
-
-    /**
      * Start Gremlin Server with {@link Settings} provided to the constructor.
      */
-    public synchronized 
CompletableFuture<ServerGremlinExecutor<EventLoopGroup>> start() throws 
Exception {
+    public synchronized CompletableFuture<ServerGremlinExecutor> start() 
throws Exception {
         if (serverStarted != null) {
             // server already started - don't get it rolling again
             return serverStarted;
         }
 
         serverStarted = new CompletableFuture<>();
-        final CompletableFuture<ServerGremlinExecutor<EventLoopGroup>> 
serverReadyFuture = serverStarted;
+        final CompletableFuture<ServerGremlinExecutor> serverReadyFuture = 
serverStarted;
         try {
             final ServerBootstrap b = new ServerBootstrap();
 
@@ -330,7 +300,7 @@ public class GremlinServer {
         return serverStopped;
     }
 
-    public ServerGremlinExecutor<EventLoopGroup> getServerGremlinExecutor() {
+    public ServerGremlinExecutor getServerGremlinExecutor() {
         return serverGremlinExecutor;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
index a34da25..ef96c28 100644
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
@@ -18,12 +18,10 @@
  */
 package org.apache.tinkerpop.gremlin.server.channel;
 
-import io.netty.channel.EventLoopGroup;
 import org.apache.tinkerpop.gremlin.server.AbstractChannelizer;
 import org.apache.tinkerpop.gremlin.server.Channelizer;
 import org.apache.tinkerpop.gremlin.server.Settings;
 import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
-import org.apache.tinkerpop.gremlin.server.auth.Authenticator;
 import 
org.apache.tinkerpop.gremlin.server.handler.AbstractAuthenticationHandler;
 import 
org.apache.tinkerpop.gremlin.server.handler.HttpBasicAuthenticationHandler;
 import org.apache.tinkerpop.gremlin.server.handler.HttpGremlinEndpointHandler;
@@ -48,7 +46,7 @@ public class HttpChannelizer extends AbstractChannelizer {
     private AbstractAuthenticationHandler authenticationHandler;
 
     @Override
-    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor) {
+    public void init(final ServerGremlinExecutor serverGremlinExecutor) {
         super.init(serverGremlinExecutor);
         httpGremlinEndpointHandler = new 
HttpGremlinEndpointHandler(serializers, gremlinExecutor, graphManager, 
settings);
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/NioChannelizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/NioChannelizer.java
 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/NioChannelizer.java
index 4baad23..53d8332 100644
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/NioChannelizer.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/NioChannelizer.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.server.channel;
 
-import io.netty.channel.EventLoopGroup;
 import org.apache.tinkerpop.gremlin.server.AbstractChannelizer;
 import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
 import org.apache.tinkerpop.gremlin.server.handler.GremlinResponseFrameEncoder;
@@ -46,7 +45,7 @@ public class NioChannelizer extends AbstractChannelizer {
     private NioGremlinResponseFrameEncoder nioGremlinResponseFrameEncoder;
 
     @Override
-    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor) {
+    public void init(final ServerGremlinExecutor serverGremlinExecutor) {
         super.init(serverGremlinExecutor);
 
         // configure authentication - null means don't bother to add 
authentication to the pipeline

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
index 2fb52fe..8c4089d 100644
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.server.channel;
 
-import io.netty.channel.EventLoopGroup;
 import org.apache.tinkerpop.gremlin.server.AbstractChannelizer;
 import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
 import 
org.apache.tinkerpop.gremlin.server.handler.AbstractAuthenticationHandler;
@@ -57,7 +56,7 @@ public class WebSocketChannelizer extends AbstractChannelizer 
{
     private AbstractAuthenticationHandler authenticationHandler;
 
     @Override
-    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor) {
+    public void init(final ServerGremlinExecutor serverGremlinExecutor) {
         super.init(serverGremlinExecutor);
 
         gremlinResponseFrameEncoder = new GremlinResponseFrameEncoder();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4c89e159/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 fab0716..1ac0dac 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
@@ -50,52 +50,27 @@ import java.util.stream.Collectors;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
+public class ServerGremlinExecutor {
     private static final Logger logger = 
LoggerFactory.getLogger(ServerGremlinExecutor.class);
 
     private final GraphManager graphManager;
     private final Settings settings;
     private final List<LifeCycleHook> hooks;
 
-    private final T scheduledExecutorService;
+    private final ScheduledExecutorService scheduledExecutorService;
     private final ExecutorService gremlinExecutorService;
     private final GremlinExecutor gremlinExecutor;
 
     private final Map<String,Object> 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
-     * {@link Executors#newScheduledThreadPool(int, ThreadFactory)}.
-     */
-    public ServerGremlinExecutor(final Settings settings, final Class<T> 
scheduleExecutorServiceClass) {
-        this(settings, null, null, scheduleExecutorServiceClass);
-    }
-
-    /**
-     * Create a new object from {@link Settings} where thread pools are 
externally assigned. Note that if the
-     * {@code scheduleExecutorServiceClass} is set to {@code null} it will be 
created via
-     * {@link Executors#newScheduledThreadPool(int, ThreadFactory)}.  If 
either of the {@link ExecutorService}
-     * instances are supplied, the {@link Settings#gremlinPool} value will be 
ignored for the pool size. The
-     * {@link GraphManager} will be constructed from the {@link Settings}.
-     */
-    public ServerGremlinExecutor(final Settings settings, final 
ExecutorService gremlinExecutorService,
-                                 final T scheduledExecutorService, final 
Class<T> scheduleExecutorServiceClass) {
-        this(settings,
-             gremlinExecutorService,
-             scheduledExecutorService,
-             scheduleExecutorServiceClass,
-             null);
-    }
-    /**
      * Create a new object from {@link Settings} where thread pools are 
externally assigned. Note that if the
      * {@code scheduleExecutorServiceClass} is set to {@code null} it will be 
created via
      * {@link Executors#newScheduledThreadPool(int, ThreadFactory)}.  If 
either of the {@link ExecutorService}
      * instances are supplied, the {@link Settings#gremlinPool} value will be 
ignored for the pool size.
      */
     public ServerGremlinExecutor(final Settings settings, final 
ExecutorService gremlinExecutorService,
-                                 final T scheduledExecutorService, final 
Class<T> scheduleExecutorServiceClass,
-                                 GraphManager graphManager) {
+                                 final ScheduledExecutorService 
scheduledExecutorService, GraphManager graphManager) {
         this.settings = settings;
 
         if (null == graphManager) {
@@ -126,8 +101,7 @@ public class ServerGremlinExecutor<T extends 
ScheduledExecutorService> {
 
         if (null == scheduledExecutorService) {
             final ThreadFactory threadFactoryGremlin = 
ThreadFactoryUtil.create("worker-%d");
-            this.scheduledExecutorService = scheduleExecutorServiceClass.cast(
-                    
Executors.newScheduledThreadPool(settings.threadPoolWorker, 
threadFactoryGremlin));
+            this.scheduledExecutorService = 
Executors.newScheduledThreadPool(settings.threadPoolWorker, 
threadFactoryGremlin);
         } else {
             this.scheduledExecutorService = scheduledExecutorService;
         }
@@ -215,7 +189,7 @@ public class ServerGremlinExecutor<T extends 
ScheduledExecutorService> {
         hostOptions.clear();
     }
 
-    public T getScheduledExecutorService() {
+    public ScheduledExecutorService getScheduledExecutorService() {
         return scheduledExecutorService;
     }
 

Reply via email to