tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [2/7] incubator-tinkerpop git commit: Added maxWaitForSessionClose to driver configuration.
Date Wed, 02 Mar 2016 22:19:38 GMT
Added maxWaitForSessionClose to driver configuration.

This setting configures how long the driver will wait to kill a session before it just lets
the server handle it.  Added a bunch of javadoc to the driver settings.


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

Branch: refs/heads/TINKERPOP-1160
Commit: 29b052598ecc90296a810b3a8fdb525afbabeb6d
Parents: 4247aa6
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Wed Mar 2 15:48:52 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Wed Mar 2 15:48:52 2016 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/driver/Client.java |   1 -
 .../tinkerpop/gremlin/driver/Connection.java    |  14 ++-
 .../tinkerpop/gremlin/driver/Settings.java      | 116 +++++++++++++++++++
 3 files changed, 127 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index 031d595..50de9d8 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -22,7 +22,6 @@ import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
index cb26781..a3b8ff3 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
@@ -33,6 +33,8 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
@@ -55,6 +57,7 @@ final class Connection {
     public static final int MAX_IN_PROCESS = 4;
     public static final int MIN_IN_PROCESS = 1;
     public static final int MAX_WAIT_FOR_CONNECTION = 3000;
+    public static final int MAX_WAIT_FOR_SESSION_CLOSE = 3000;
     public static final int MAX_CONTENT_LENGTH = 65536;
     public static final int RECONNECT_INITIAL_DELAY = 1000;
     public static final int RECONNECT_INTERVAL = 1000;
@@ -215,7 +218,7 @@ final class Connection {
 
     private void shutdown(final CompletableFuture<Void> future) {
         // shutdown can be called directly from closeAsync() or after write() and therefore
this method should only
-        // be called once. once shutdown is initiated, it shoudln't be executed a second
time or else it sends more
+        // be called once. once shutdown is initiated, it shouldn't be executed a second
time or else it sends more
         // messages at the server and leads to ugly log messages over there.
         if (shutdownInitiated.compareAndSet(false, true)) {
             if (client instanceof Client.SessionedClient) {
@@ -228,10 +231,15 @@ final class Connection {
                     // make sure we get a response here to validate that things closed as
expected.  on error, we'll let
                     // the server try to clean up on its own.  the primary error here should
probably be related to
                     // protocol issues which should not be something a user has to fuss with.
-                    closed.get();
+                    closed.get(cluster.connectionPoolSettings().maxWaitForSessionClose, TimeUnit.MILLISECONDS);
+                } catch (TimeoutException ex) {
+                    final String msg = String.format(
+                            "Timeout while trying to close connection on %s - force closing
- server will close session on shutdown or expiration.",
+                            ((Client.SessionedClient) client).getSessionId());
+                    logger.warn(msg, ex);
                 } catch (Exception ex) {
                     final String msg = String.format(
-                            "Encountered an error trying to close connection on %s - force
closing - server will close session on shutdown or timeout.",
+                            "Encountered an error trying to close connection on %s - force
closing - server will close session on shutdown or expiration.",
                             ((Client.SessionedClient) client).getSessionId());
                     logger.warn(msg, ex);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29b05259/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
index 7a40d4f..fb85910 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
@@ -31,28 +31,62 @@ import java.util.Objects;
 import java.util.Optional;
 
 /**
+ * Settings for the {@link Cluster} and its related components.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 final class Settings {
 
+    /**
+     * The port of the Gremlin Server to connect to which defaults to {@code 8192}. The same
port will be applied for
+     * all {@link #hosts}.
+     */
     public int port = 8182;
 
+    /**
+     * The list of hosts that the driver will connect to.
+     */
     public List<String> hosts = new ArrayList<>();
 
+    /**
+     * The serializer that will be used when communicating with the server. Note that serializer
settings should match
+     * what is available on the server.
+     */
     public SerializerSettings serializer = new SerializerSettings();
 
+    /**
+     * Settings for connections and connection pool.
+     */
     public ConnectionPoolSettings connectionPool = new ConnectionPoolSettings();
 
+    /**
+     * The size of the thread pool defaulted to the number of available processors.
+     */
     public int nioPoolSize = Runtime.getRuntime().availableProcessors();
 
+    /**
+     * The number of worker threads defaulted to the number of available processors * 2.
+     */
     public int workerPoolSize = Runtime.getRuntime().availableProcessors() * 2;
 
+    /**
+     * The username to submit on requests that require authentication.
+     */
     public String username = null;
 
+    /**
+     * The password to submit on requests that require authentication.
+     */
     public String password = null;
 
+    /**
+     * The JAAS to submit on requests that require authentication.
+     */
     public String jaasEntry = null;
 
+    /**
+     * The JAAS protocol to submit on requests that require authentication.
+     */
     public String protocol = null;
 
     /**
@@ -74,19 +108,93 @@ final class Settings {
     }
 
     static class ConnectionPoolSettings {
+        /**
+         * Determines if SSL should be enabled or not. If enabled on the server then it must
be enabled on the client.
+         */
         public boolean enableSsl = false;
+
+        /**
+         * The trusted certificate in PEM format.
+         */
         public String trustCertChainFile = null;
+
+        /**
+         * The minimum size of a connection pool for a {@link Host}. By default this is set
to 2.
+         */
         public int minSize = ConnectionPool.MIN_POOL_SIZE;
+
+        /**
+         * The maximum size of a connection pool for a {@link Host}. By default this is set
to 8.
+         */
         public int maxSize = ConnectionPool.MAX_POOL_SIZE;
+
+        /**
+         * A connection under low use can be destroyed. This setting determines the threshold
for determining when
+         * that connection can be released and is defaulted to 8.
+         */
         public int minSimultaneousUsagePerConnection = ConnectionPool.MIN_SIMULTANEOUS_USAGE_PER_CONNECTION;
+
+        /**
+         * If a connection is over used, then it might mean that is necessary to expand the
pool by adding a new
+         * connection.  This setting determines the threshold for a connections over use
and is defaulted to 16
+         */
         public int maxSimultaneousUsagePerConnection = ConnectionPool.MAX_SIMULTANEOUS_USAGE_PER_CONNECTION;
+
+        /**
+         * The maximum number of requests in flight on a connection where the default is
4.
+         */
         public int maxInProcessPerConnection = Connection.MAX_IN_PROCESS;
+
+        /**
+         * A connection has available in-process requests which is calculated by subtracting
the number of current
+         * in-flight requests on a connection and subtracting that from the {@link #maxInProcessPerConnection}.
When
+         * that number drops below this configuration setting, the connection is recommended
for replacement. The
+         * default for this setting is 1.
+         */
         public int minInProcessPerConnection = Connection.MIN_IN_PROCESS;
+
+        /**
+         * The amount of time in milliseconds to wait for a new connection before timing
out where the default value
+         * is 3000.
+         */
         public int maxWaitForConnection = Connection.MAX_WAIT_FOR_CONNECTION;
+
+        /**
+         * If the connection is using a "session" this setting represents the amount of time
in milliseconds to wait
+         * for that session to close before timing out where the default value is 3000. Note
that the server will
+         * eventually clean up dead sessions itself on expiration of the session or during
shutdown.
+         */
+        public int maxWaitForSessionClose = Connection.MAX_WAIT_FOR_SESSION_CLOSE;
+
+        /**
+         * The maximum length in bytes that a message can be sent to the server. This number
can be no greater than
+         * the setting of the same name in the server configuration. The default value is
65536.
+         */
         public int maxContentLength = Connection.MAX_CONTENT_LENGTH;
+
+        /**
+         * The amount of time in milliseconds to wait before trying to reconnect to a dead
host. The default value is
+         * 1000. This interval occurs after the time specified by the {@link #reconnectInitialDelay}.
+         */
         public int reconnectInterval = Connection.RECONNECT_INTERVAL;
+
+        /**
+         * The amount of time in milliseconds to wait before trying to reconnect to a dead
host for the first time.
+         * The default value is 1000.
+         */
         public int reconnectInitialDelay = Connection.RECONNECT_INITIAL_DELAY;
+
+        /**
+         * The override value for the size of the result batches to be returned from the
server. This value is set to
+         * 64 by default.
+         */
         public int resultIterationBatchSize = Connection.RESULT_ITERATION_BATCH_SIZE;
+
+        /**
+         * The constructor for the channel that connects to the server. This value should
be the fully qualified
+         * class name of a Gremlin Driver {@link Channelizer} implementation.  By default
this value is set to
+         * {@link org.apache.tinkerpop.gremlin.driver.Channelizer.WebSocketChannelizer}.
+         */
         public String channelizer = Channelizer.WebSocketChannelizer.class.getName();
 
         /**
@@ -107,7 +215,15 @@ final class Settings {
     }
 
     public static class SerializerSettings {
+        /**
+         * The fully qualified class name of the {@link MessageSerializer} that will be used
to communicate with the
+         * server. Note that the serializer configured on the client should be supported
by the server configuration.
+         */
         public String className = GraphSONMessageSerializerV1d0.class.getCanonicalName();
+
+        /**
+         * The configuration for the specified serializer with the {@link #className}.
+         */
         public Map<String, Object> config = null;
 
         public MessageSerializer create() throws Exception {


Mime
View raw message