You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/07 20:22:06 UTC
[06/10] incubator-tinkerpop git commit: Some inline comments in
gremlin-driver.
Some inline comments in gremlin-driver.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/325b0803
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/325b0803
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/325b0803
Branch: refs/heads/master
Commit: 325b0803afc9c2b845d8dfc862f6db079f3f202e
Parents: 4a1e512
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 7 13:29:24 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 7 13:29:24 2015 -0400
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/driver/Cluster.java | 2 +-
.../tinkerpop/gremlin/driver/ConnectionPool.java | 18 ++++++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/325b0803/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 906160d..c42014a 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
@@ -42,7 +42,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
/**
- * A bunch of Gremlin Server instances.
+ * A connection to a set of one or more Gremlin Server instances.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/325b0803/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 7aa401d..3445114 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
@@ -137,18 +137,24 @@ class ConnectionPool {
}
while (true) {
- final int inFlight = leastUsedConn.borrowed.get();
+ final int borrowed = leastUsedConn.borrowed.get();
final int availableInProcess = leastUsedConn.availableInProcess();
- // if the number in flight starts to exceed what's available for this connection, then we need
- // to wait for a connection to become available.
- if (inFlight >= leastUsedConn.availableInProcess()) {
+ // if the number borrowed starts to exceed what's available for this connection, then we need
+ // to wait for a connection to become available. this is an interesting comparison for "busy-ness"
+ // because it compares the number of times the connection was borrowed to what's in-process. the
+ // in-process number refers to the number of outstanding requests less the maxInProcessForConnection
+ // setting. this scenario can only really happen if
+ // maxInProcessForConnection=maxSimultaneousUsagePerConnection or if there is some sort of batch type
+ // operation where more than one message is sent on a single borrowed connection before it is returned
+ // to the pool.
+ if (borrowed >= leastUsedConn.availableInProcess()) {
logger.debug("Least used connection selected from pool for {} but borrowed [{}] >= availableInProcess [{}] - wait",
- host, inFlight, availableInProcess);
+ host, borrowed, availableInProcess);
return waitForConnection(timeout, unit);
}
- if (leastUsedConn.borrowed.compareAndSet(inFlight, inFlight + 1)) {
+ if (leastUsedConn.borrowed.compareAndSet(borrowed, borrowed + 1)) {
if (logger.isDebugEnabled())
logger.debug("Return least used {} on {}", leastUsedConn.getConnectionInfo(), host);
return leastUsedConn;