You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/05/07 23:30:14 UTC

[05/24] incubator-tinkerpop git commit: Update javadoc in the driver for some of its more obscure settings.

Update javadoc in the driver for some of its more obscure 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/4845c136
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4845c136
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4845c136

Branch: refs/heads/TINKERPOP3-666
Commit: 4845c136abc3e84fcd305ecbe4b2d5e85e6691d1
Parents: c6d220d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 7 13:19:49 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 7 13:19:49 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Cluster.java       | 34 ++++++++++++++++++++
 .../gremlin/driver/ConnectionPool.java          |  8 ++---
 2 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4845c136/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
index cdf8a09..906160d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java
@@ -251,31 +251,65 @@ public class Cluster {
             return this;
         }
 
+        /**
+         * The minimum number of in-flight requests that can occur on a {@link Connection} before it is considered
+         * for closing on return to the {@link ConnectionPool}.
+         */
         public Builder minInProcessPerConnection(final int minInProcessPerConnection) {
             this.minInProcessPerConnection = minInProcessPerConnection;
             return this;
         }
 
+        /**
+         * The maximum number of in-flight requests that can occur on a {@link Connection}. This represents an
+         * indication of how busy a {@link Connection} is allowed to be.  This number is linked to the
+         * {@link #maxSimultaneousUsagePerConnection} setting, but is slightly different in that it refers to
+         * the total number of requests on a {@link Connection}.  In other words, a {@link Connection} might
+         * be borrowed once to have multiple requests executed against it.  This number controls the maximum
+         * number of requests whereas {@link #maxInProcessPerConnection} controls the times borrowed.
+         */
         public Builder maxInProcessPerConnection(final int maxInProcessPerConnection) {
             this.maxInProcessPerConnection = maxInProcessPerConnection;
             return this;
         }
 
+        /**
+         * The maximum number of times that a {@link Connection} can be borrowed from the pool simultaneously.
+         * This represents an indication of how busy a {@link Connection} is allowed to be.  Set too large and the
+         * {@link Connection} may queue requests too quickly, rather than wait for an available {@link Connection}
+         * or create a fresh one.  If set too small, the {@link Connection} will show as busy very quickly thus
+         * forcing waits for available {@link Connection} instances in the pool when there is more capacity available.
+         */
         public Builder maxSimultaneousUsagePerConnection(final int maxSimultaneousUsagePerConnection) {
             this.maxSimultaneousUsagePerConnection = maxSimultaneousUsagePerConnection;
             return this;
         }
 
+        /**
+         * The minimum number of times that a {@link Connection} should be borrowed from the pool before it falls
+         * under consideration for closing.  If a {@link Connection} is not busy and the
+         * {@link #minConnectionPoolSize} is exceeded, then there is no reason to keep that connection open.  Set
+         * too large and {@link Connection} that isn't busy will continue to consume resources when it is not being
+         * used.  Set too small and {@link Connection} instances will be destroyed when the driver might still be
+         * busy.
+         */
         public Builder minSimultaneousUsagePerConnection(final int minSimultaneousUsagePerConnection) {
             this.minSimultaneousUsagePerConnection = minSimultaneousUsagePerConnection;
             return this;
         }
 
+        /**
+         * The maximum size that the {@link ConnectionPool} can grow.
+         */
         public Builder maxConnectionPoolSize(final int maxSize) {
             this.maxConnectionPoolSize = maxSize;
             return this;
         }
 
+        /**
+         * The minimum size of the {@link ConnectionPool}.  When the {@link Client} is started, {@link Connection}
+         * objects will be initially constructed to this size.
+         */
         public Builder minConnectionPoolSize(final int minSize) {
             this.minConnectionPoolSize = minSize;
             return this;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4845c136/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index b2cc050..7aa401d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -160,12 +160,12 @@ class ConnectionPool {
         logger.debug("Attempting to return {} on {}", connection, host);
         if (isClosed()) throw new ConnectionException(host.getHostUri(), host.getAddress(), "Pool is shutdown");
 
-        int inFlight = connection.borrowed.decrementAndGet();
+        int borrowed = connection.borrowed.decrementAndGet();
         if (connection.isDead()) {
             logger.debug("Marking {} as dead", this.host);
             considerUnavailable();
         } else {
-            if (bin.contains(connection) && inFlight == 0) {
+            if (bin.contains(connection) && borrowed == 0) {
                 logger.debug("{} is already in the bin and it has no inflight requests so it is safe to close", connection);
                 if (bin.remove(connection))
                     connection.closeAsync();
@@ -178,10 +178,10 @@ class ConnectionPool {
             // then let the world know the connection is available.
             final int poolSize = connections.size();
             final int availableInProcess = connection.availableInProcess();
-            if (poolSize > minPoolSize && inFlight <= minSimultaneousUsagePerConnection) {
+            if (poolSize > minPoolSize && borrowed <= minSimultaneousUsagePerConnection) {
                 if (logger.isDebugEnabled())
                     logger.debug("On {} pool size of {} > minPoolSize {} and borrowed of {} <= minSimultaneousUsagePerConnection {} so destroy {}",
-                            host, poolSize, minPoolSize, inFlight, minSimultaneousUsagePerConnection, connection.getConnectionInfo());
+                            host, poolSize, minPoolSize, borrowed, minSimultaneousUsagePerConnection, connection.getConnectionInfo());
                 destroyConnection(connection);
             } else if (connection.availableInProcess() < minInProcess) {
                 if (logger.isDebugEnabled())