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 13:26:07 UTC

incubator-tinkerpop git commit: By adding some log level checks, prevent expensive calls on String construction.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 38b2afcad -> 9f656b9ed


By adding some log level checks, prevent expensive calls on String construction.


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

Branch: refs/heads/master
Commit: 9f656b9ed09c227d6731c979185216d814f7d5fa
Parents: 38b2afc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 7 07:24:54 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 7 07:24:54 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/Connection.java    |  6 ++++--
 .../gremlin/driver/ConnectionPool.java          | 22 +++++++++++++-------
 2 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9f656b9e/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 959b531..48c561b 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
@@ -158,7 +158,8 @@ class Connection {
         final ChannelPromise promise = channel.newPromise()
                 .addListener(f -> {
                     if (!f.isSuccess()) {
-                        logger.debug(String.format("Write on connection %s failed", thisConnection.getConnectionInfo()), f.cause());
+                        if (logger.isDebugEnabled())
+                            logger.debug(String.format("Write on connection %s failed", thisConnection.getConnectionInfo()), f.cause());
                         thisConnection.isDead = true;
                         thisConnection.returnToPool();
                         future.completeExceptionally(f.cause());
@@ -189,7 +190,8 @@ class Connection {
         try {
             if (pool != null) pool.returnConnection(this);
         } catch (ConnectionException ce) {
-            logger.debug("Returned {} connection to {} but an error occurred - {}", this.getConnectionInfo(), pool, ce.getMessage());
+            if (logger.isDebugEnabled())
+                logger.debug("Returned {} connection to {} but an error occurred - {}", this.getConnectionInfo(), pool, ce.getMessage());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9f656b9e/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 1e4d0c7..81ae801 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
@@ -130,8 +130,9 @@ class ConnectionPool {
         // not at maximum then consider opening a connection
         final int currentPoolSize = connections.size();
         if (leastUsedConn.inFlight.get() >= maxSimultaneousRequestsPerConnection && currentPoolSize < maxPoolSize) {
-            logger.debug("Least used {} on {} exceeds maxSimultaneousRequestsPerConnection but pool size {} < maxPoolSize - consider new connection",
-                    leastUsedConn.getConnectionInfo(), host, currentPoolSize);
+            if (logger.isDebugEnabled())
+                logger.debug("Least used {} on {} exceeds maxSimultaneousRequestsPerConnection but pool size {} < maxPoolSize - consider new connection",
+                        leastUsedConn.getConnectionInfo(), host, currentPoolSize);
             considerNewConnection();
         }
 
@@ -148,7 +149,8 @@ class ConnectionPool {
             }
 
             if (leastUsedConn.inFlight.compareAndSet(inFlight, inFlight + 1)) {
-                logger.debug("Return least used {} on {}", leastUsedConn.getConnectionInfo(), host);
+                if (logger.isDebugEnabled())
+                    logger.debug("Return least used {} on {}", leastUsedConn.getConnectionInfo(), host);
                 return leastUsedConn;
             }
         }
@@ -177,11 +179,13 @@ class ConnectionPool {
             final int poolSize = connections.size();
             final int availableInProcess = connection.availableInProcess();
             if (poolSize > minPoolSize && inFlight <= minSimultaneousRequestsPerConnection) {
-                logger.debug("On {} pool size of {} > minPoolSize {} and inFlight of {} <= minSimultaneousRequestsPerConnection {} so destroy {}",
-                        host, poolSize, minPoolSize, inFlight, minSimultaneousRequestsPerConnection, connection.getConnectionInfo());
+                if (logger.isDebugEnabled())
+                    logger.debug("On {} pool size of {} > minPoolSize {} and inFlight of {} <= minSimultaneousRequestsPerConnection {} so destroy {}",
+                            host, poolSize, minPoolSize, inFlight, minSimultaneousRequestsPerConnection, connection.getConnectionInfo());
                 destroyConnection(connection);
             } else if (connection.availableInProcess() < minInProcess) {
-                logger.debug("On {} availableInProcess {} < minInProcess {} so replace {}", host, availableInProcess, minInProcess, connection.getConnectionInfo());
+                if (logger.isDebugEnabled())
+                    logger.debug("On {} availableInProcess {} < minInProcess {} so replace {}", host, availableInProcess, minInProcess, connection.getConnectionInfo());
                 replaceConnection(connection);
             } else
                 announceAvailableConnection();
@@ -303,7 +307,8 @@ class ConnectionPool {
         if (connection.inFlight.get() == 0 && bin.remove(connection))
             connection.closeAsync();
 
-        logger.debug("{} destroyed", connection.getConnectionInfo());
+        if (logger.isDebugEnabled())
+            logger.debug("{} destroyed", connection.getConnectionInfo());
     }
 
     private Connection waitForConnection(final long timeout, final TimeUnit unit) throws TimeoutException, ConnectionException {
@@ -333,7 +338,8 @@ class ConnectionPool {
                     }
 
                     if (leastUsed.inFlight.compareAndSet(inFlight, inFlight + 1)) {
-                        logger.debug("Return least used {} on {} after waiting", leastUsed.getConnectionInfo(), host);
+                        if (logger.isDebugEnabled())
+                            logger.debug("Return least used {} on {} after waiting", leastUsed.getConnectionInfo(), host);
                         return leastUsed;
                     }
                 }