Merge branch 'tp32'

Conflicts:
        docs/src/reference/gremlin-applications.asciidoc
        
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
        
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
        
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
        
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
        
gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml


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

Branch: refs/heads/master
Commit: 8fc726037a967eee9c04645e3376b3c44d2b8dfe
Parents: d683206 d970564
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 23 07:41:44 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 23 07:41:44 2018 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../src/reference/gremlin-applications.asciidoc | 13 +++--
 .../upgrade/release-3.2.x-incubating.asciidoc   | 15 ++++++
 .../driver/handler/WebSocketClientHandler.java  |  5 +-
 gremlin-server/conf/gremlin-server-classic.yaml |  2 +
 .../conf/gremlin-server-modern-py.yaml          |  2 +
 .../conf/gremlin-server-modern-readonly.yaml    |  2 +
 gremlin-server/conf/gremlin-server-modern.yaml  |  2 +
 gremlin-server/conf/gremlin-server-neo4j.yaml   |  2 +
 gremlin-server/conf/gremlin-server-secure.yaml  |  2 +
 gremlin-server/conf/gremlin-server-spark.yaml   |  2 +
 gremlin-server/conf/gremlin-server.yaml         |  2 +
 .../gremlin/server/AbstractChannelizer.java     | 14 ++++-
 .../tinkerpop/gremlin/server/Channelizer.java   | 17 ++++++
 .../tinkerpop/gremlin/server/GremlinServer.java | 11 +++-
 .../tinkerpop/gremlin/server/Settings.java      | 18 +++++++
 .../server/channel/WebSocketChannelizer.java    | 11 ++++
 .../server/channel/WsAndHttpChannelizer.java    | 28 +++++-----
 .../server/handler/OpSelectorHandler.java       | 35 +++++++++++++
 .../handler/WsAndHttpChannelizerHandler.java    | 11 +++-
 .../server/GremlinServerIntegrateTest.java      | 55 +++++++++++++++++++-
 .../gremlin/util/Log4jRecordingAppender.java    |  5 +-
 .../util/Log4jRecordingAppenderTest.java        |  2 +-
 .../remote/gremlin-server-integration.yaml      |  2 +
 .../server/gremlin-server-integration.yaml      |  2 +
 25 files changed, 231 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 7fa52a5,60e0ef4..d54b880
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -274,9 -25,9 +274,10 @@@ image::https://raw.githubusercontent.co
  
  * Modified `GremlinDslProcessor` so that it generated the 
`getAnonymousTraversalClass()` method to return the DSL version of `__`.
  * Added the "Kitchen Sink" test data set.
+ * Added `idleConnectionTimeout` and `keepAliveInterval` to Gremlin Server 
that enables a "ping" and auto-close for seemingly dead clients.
  * Fixed a bug in `NumberHelper` that led to wrong min/max results if numbers 
exceeded the Integer limits.
  * Delayed setting of the request identifier until `RequestMessage` 
construction by the builder.
 +* `ReferenceElement` avoids `UnsupportedOperationException` handling in 
construction thus improving performance.
  * Improved error messaging for failed serialization and deserialization of 
request/response messages.
  * Removed hardcoded expectation in metrics serialization test suite as 
different providers may have different outputs.
  * Added `IndexedTraverserSet` which indexes on the value of a `Traverser` 
thus improving performance when used.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --cc docs/src/reference/gremlin-applications.asciidoc
index efc2c80,380ff4e..53a1642
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@@ -1768,8 -1594,10 +1769,10 @@@ The following sections define best prac
  
  image:gremlin-handdrawn.png[width=120,float=right] Tuning Gremlin Server for 
a particular environment may require some simple trial-and-error, but the 
following represent some basic guidelines that might be useful:
  
- * Gremlin Server defaults to a very modest maximum heap size.  Consider 
increasing this value for non-trivial uses.  Maximum heap size (`-Xmx`) is 
defined with the `JAVA_OPTIONS` setting in `gremlin-server.conf`.
- * When configuring the size of `threadPoolWorker` start with the default of 
`1` and increment by one as needed to a maximum of `2*number of cores`.
+ * Gremlin Server defaults to a very modest maximum heap size.  Consider 
increasing this value for non-trivial uses.
 -Maximum heap size (`-Xmx`) is defined with the `JAVA_OPTIONS` setting in 
`gremlin-server.sh`.
++Maximum heap size (`-Xmx`) is defined with the `JAVA_OPTIONS` setting in 
`gremlin-server.conf`.
+ * When configuring the size of `threadPoolWorker` start with the default of 
`1` and increment by one as needed to a
+ maximum of `2*number of cores`.
  * The "right" size of the `gremlinPool` setting is somewhat dependent on the 
type of scripts that will be processed
  by Gremlin Server.  As requests arrive to Gremlin Server they are decoded and 
queued to be processed by threads in
  this pool.  When this pool is exhausted of threads, Gremlin Server will 
continue to accept incoming requests, but

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-classic.yaml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-modern-py.yaml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-modern-readonly.yaml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-modern.yaml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-neo4j.yaml
----------------------------------------------------------------------
diff --cc gremlin-server/conf/gremlin-server-neo4j.yaml
index 43b1e80,f88001c..3b74c31
--- a/gremlin-server/conf/gremlin-server-neo4j.yaml
+++ b/gremlin-server/conf/gremlin-server-neo4j.yaml
@@@ -48,8 -51,12 +48,10 @@@ metrics: 
    consoleReporter: {enabled: true, interval: 180000},
    csvReporter: {enabled: true, interval: 180000, fileName: 
/tmp/gremlin-server-metrics.csv},
    jmxReporter: {enabled: true},
 -  slf4jReporter: {enabled: true, interval: 180000},
 -  gangliaReporter: {enabled: false, interval: 180000, addressingMode: 
MULTICAST},
 -  graphiteReporter: {enabled: false, interval: 180000}}
 +  slf4jReporter: {enabled: true, interval: 180000}}
  strictTransactionManagement: false
+ idleConnectionTimeout: 0
+ keepAliveInterval: 0
  maxInitialLineLength: 4096
  maxHeaderSize: 8192
  maxChunkSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-secure.yaml
----------------------------------------------------------------------
diff --cc gremlin-server/conf/gremlin-server-secure.yaml
index aa847d8,42a7785..6c77ad1
--- a/gremlin-server/conf/gremlin-server-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-secure.yaml
@@@ -47,8 -54,12 +47,10 @@@ metrics: 
    consoleReporter: {enabled: true, interval: 180000},
    csvReporter: {enabled: true, interval: 180000, fileName: 
/tmp/gremlin-server-metrics.csv},
    jmxReporter: {enabled: true},
 -  slf4jReporter: {enabled: true, interval: 180000},
 -  gangliaReporter: {enabled: false, interval: 180000, addressingMode: 
MULTICAST},
 -  graphiteReporter: {enabled: false, interval: 180000}}
 +  slf4jReporter: {enabled: true, interval: 180000}}
  strictTransactionManagement: false
+ idleConnectionTimeout: 0
+ keepAliveInterval: 0
  maxInitialLineLength: 4096
  maxHeaderSize: 8192
  maxChunkSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server-spark.yaml
----------------------------------------------------------------------
diff --cc gremlin-server/conf/gremlin-server-spark.yaml
index 0d8a63c,bf7d32b..8d7d322
--- a/gremlin-server/conf/gremlin-server-spark.yaml
+++ b/gremlin-server/conf/gremlin-server-spark.yaml
@@@ -61,8 -64,12 +61,10 @@@ metrics: 
    consoleReporter: {enabled: true, interval: 180000},
    csvReporter: {enabled: true, interval: 180000, fileName: 
/tmp/gremlin-server-metrics.csv},
    jmxReporter: {enabled: true},
 -  slf4jReporter: {enabled: true, interval: 180000},
 -  gangliaReporter: {enabled: false, interval: 180000, addressingMode: 
MULTICAST},
 -  graphiteReporter: {enabled: false, interval: 180000}}
 +  slf4jReporter: {enabled: true, interval: 180000}}
  strictTransactionManagement: false
+ idleConnectionTimeout: 0
+ keepAliveInterval: 0
  maxInitialLineLength: 4096
  maxHeaderSize: 8192
  maxChunkSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/conf/gremlin-server.yaml
----------------------------------------------------------------------
diff --cc gremlin-server/conf/gremlin-server.yaml
index f81e25f,050d9d8..db7386c
--- a/gremlin-server/conf/gremlin-server.yaml
+++ b/gremlin-server/conf/gremlin-server.yaml
@@@ -38,8 -41,12 +38,10 @@@ metrics: 
    consoleReporter: {enabled: true, interval: 180000},
    csvReporter: {enabled: true, interval: 180000, fileName: 
/tmp/gremlin-server-metrics.csv},
    jmxReporter: {enabled: true},
 -  slf4jReporter: {enabled: true, interval: 180000},
 -  gangliaReporter: {enabled: false, interval: 180000, addressingMode: 
MULTICAST},
 -  graphiteReporter: {enabled: false, interval: 180000}}
 +  slf4jReporter: {enabled: true, interval: 180000}}
  strictTransactionManagement: false
+ idleConnectionTimeout: 0
+ keepAliveInterval: 0
  maxInitialLineLength: 4096
  maxHeaderSize: 8192
  maxChunkSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
----------------------------------------------------------------------
diff --cc 
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
index b2931f6,edea752..e7f299b
--- 
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
@@@ -22,10 -23,11 +22,11 @@@ import io.netty.handler.ssl.SslContext
  import io.netty.handler.ssl.SslContextBuilder;
  import io.netty.handler.ssl.SslProvider;
  import io.netty.handler.ssl.util.SelfSignedCertificate;
+ import io.netty.handler.timeout.IdleStateHandler;
  import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
  import 
org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV1d0;
 -import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0;
 -import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
 +import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0;
 +import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0;
  import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
  import org.apache.tinkerpop.gremlin.server.auth.Authenticator;
  import 
org.apache.tinkerpop.gremlin.server.handler.AbstractAuthenticationHandler;
@@@ -95,8 -99,10 +96,9 @@@ public abstract class AbstractChanneliz
  
      protected final Map<String, MessageSerializer> serializers = new 
HashMap<>();
  
+     private IdleStateHandler idleStateHandler;
      private OpSelectorHandler opSelectorHandler;
      private OpExecutorHandler opExecutorHandler;
 -    private IteratorHandler iteratorHandler;
  
      protected Authenticator authenticator;
  
@@@ -134,8 -140,9 +136,8 @@@
          authenticator = createAuthenticator(settings.authentication);
  
          // these handlers don't share any state and can thus be initialized 
once per pipeline
-         opSelectorHandler = new OpSelectorHandler(settings, graphManager, 
gremlinExecutor, scheduledExecutorService);
+         opSelectorHandler = new OpSelectorHandler(settings, graphManager, 
gremlinExecutor, scheduledExecutorService, this);
          opExecutorHandler = new OpExecutorHandler(settings, graphManager, 
gremlinExecutor, scheduledExecutorService);
 -        iteratorHandler = new IteratorHandler(settings);
      }
  
      @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
----------------------------------------------------------------------
diff --cc 
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Channelizer.java
index 31c65c1,15fb7d3..01987fc
--- 
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
@@@ -34,5 -35,22 +34,22 @@@ public interface Channelizer extends Ch
      /**
       * This method is called just after the {@code Channelizer} is 
initialized.
       */
 -    public void init(final ServerGremlinExecutor<EventLoopGroup> 
serverGremlinExecutor);
 +    public void init(final ServerGremlinExecutor serverGremlinExecutor);
+ 
+     /**
+      * Create a message to send to seemingly dead clients to see if they 
respond back. The message sent will be
+      * dependent on the implementation. For example, a websocket 
implementation would create a "ping" message.
+      * This method will only be used if {@link #supportsIdleMonitor()} is 
{@code true}.
+      */
+     public default Object createIdleDetectionMessage() {
+         return null;
+     }
+ 
+     /**
+      * Determines if the channelizer supports a method for keeping the 
connection alive and auto-closing zombie
+      * channels.
+      */
+     public default boolean supportsIdleMonitor() {
+         return false;
+     }
  }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
----------------------------------------------------------------------
diff --cc 
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WebSocketChannelizer.java
index 081e336,a6ec20b..157263b
--- 
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,6 -18,8 +18,7 @@@
   */
  package org.apache.tinkerpop.gremlin.server.channel;
  
 -import io.netty.channel.EventLoopGroup;
+ import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
  import org.apache.tinkerpop.gremlin.server.AbstractChannelizer;
  import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
  import 
org.apache.tinkerpop.gremlin.server.handler.AbstractAuthenticationHandler;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/WsAndHttpChannelizer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
----------------------------------------------------------------------
diff --cc 
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
index 45e601e,de65bb9..0f14293
--- 
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
+++ 
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
@@@ -18,12 -18,17 +18,15 @@@
   */
  package org.apache.tinkerpop.gremlin.server.handler;
  
 -import com.codahale.metrics.Meter;
+ import io.netty.handler.timeout.IdleState;
+ import io.netty.handler.timeout.IdleStateEvent;
  import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
  import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
  import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
  import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
+ import org.apache.tinkerpop.gremlin.server.Channelizer;
  import org.apache.tinkerpop.gremlin.server.Context;
  import org.apache.tinkerpop.gremlin.server.GraphManager;
 -import org.apache.tinkerpop.gremlin.server.GremlinServer;
  import org.apache.tinkerpop.gremlin.server.OpProcessor;
  import org.apache.tinkerpop.gremlin.server.Settings;
  import org.apache.tinkerpop.gremlin.server.op.OpLoader;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsAndHttpChannelizerHandler.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/util/Log4jRecordingAppender.java
----------------------------------------------------------------------
diff --cc 
gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/util/Log4jRecordingAppender.java
index 4a9ebd4,82c14ac..abb6864
--- 
a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/util/Log4jRecordingAppender.java
+++ 
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/util/Log4jRecordingAppender.java
@@@ -63,16 -60,8 +63,17 @@@ public class Log4jRecordingAppender ext
          messages.clear();
      }
  
-     public boolean logContainsAny(final String fragment) {
-         return messages.stream().anyMatch(m -> m.contains(fragment));
+     public boolean logContainsAny(final String regex) {
+         // chop off the line feed so that the regex doesn't have to account 
for that
+         return messages.stream().anyMatch(m -> m.substring(0,m.length() - 
1).matches(regex));
      }
 -}
 +
 +    public boolean logContainsAny(final String loggerName, final Level level, 
final String fragment) {
 +        return events.stream().anyMatch(m -> 
m.getLoggerName().equals(loggerName) &&
 +                m.getLevel().equals(level) && 
m.getMessage().toString().contains(fragment));
 +    }
 +    public boolean logMatchesAny(final String loggerName, final Level level, 
final String regex) {
 +        return events.stream().anyMatch(m -> 
m.getLoggerName().equals(loggerName) &&
 +                m.getLevel().equals(level) && 
m.getMessage().toString().matches(regex));
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fc72603/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------

Reply via email to