Skip to content
This repository
Browse code

Added INFO level messages to better understand connection creation. E…

…xpet to remove most of this after debugging.

src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
- print out time to establish connection (if it takes longer than 1 ms)

src/java/voldemort/utils/pool/KeyedResourcePool.java
- print out info about object creation (connection establishment). In
  particular, how many outstanding creations (connection
  establishments) are in flight and how many idle resources are in the
  pool after the newly created resource is checked in.
  • Loading branch information...
commit e6ec7a0f69de075e0dd7d01b42b5e7d5b99efcab 1 parent b4994bb
Jay Wylie authored November 12, 2012
11  src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
@@ -166,7 +166,16 @@ public ClientRequestExecutor create(SocketDestination dest) throws Exception {
166 166
                         logger.warn(e, e);
167 167
                 }
168 168
             }
169  
-
  169
+            duration = System.currentTimeMillis() - startTime;
  170
+
  171
+            if(duration > 0) {
  172
+                if(logger.isInfoEnabled()) {
  173
+                    logger.info("Created socket " + numCreated + " for " + dest.getHost() + ":"
  174
+                                + dest.getPort() + " using protocol "
  175
+                                + dest.getRequestFormatType().getCode() + " after " + duration
  176
+                                + " ms.");
  177
+                }
  178
+            }
170 179
             if(logger.isDebugEnabled())
171 180
                 logger.debug("Created socket " + numCreated + " for " + dest.getHost() + ":"
172 181
                              + dest.getPort() + " using protocol "
19  src/java/voldemort/utils/pool/KeyedResourcePool.java
@@ -405,6 +405,7 @@ protected void checkNotClosed() {
405 405
 
406 406
         final private AtomicInteger size = new AtomicInteger(0);
407 407
         final private AtomicInteger blockingGets = new AtomicInteger(0);
  408
+        final private AtomicInteger createsInFlight = new AtomicInteger(0);
408 409
         final private int maxPoolSize;
409 410
         final private BlockingQueue<V> queue;
410 411
 
@@ -435,13 +436,29 @@ public Pool(ResourcePoolConfig resourcePoolConfig) {
435 436
 
436 437
             if(this.size.incrementAndGet() <= this.maxPoolSize) {
437 438
                 try {
438  
-                    V resource = objectFactory.create(key);
  439
+                    V resource = null;
  440
+                    int currentCreatesInFlight = 0;
  441
+                    try {
  442
+                        currentCreatesInFlight = createsInFlight.getAndIncrement();
  443
+                        resource = objectFactory.create(key);
  444
+                    } finally {
  445
+                        createsInFlight.decrementAndGet();
  446
+                    }
439 447
                     if(resource != null) {
440 448
                         if(!nonBlockingPut(resource)) {
441 449
                             this.size.decrementAndGet();
442 450
                             objectFactory.destroy(key, resource);
  451
+                            logger.info("attemptGrow established new connection for key "
  452
+                                        + key.toString() + " with " + currentCreatesInFlight
  453
+                                        + " other connection establishments in flight."
  454
+                                        + " And then promptly destroyed the new connection.");
443 455
                             return false;
444 456
                         }
  457
+                        logger.info("attemptGrow established new connection for key "
  458
+                                    + key.toString() + " with " + currentCreatesInFlight
  459
+                                    + " other connection establishments in flight."
  460
+                                    + " After checking in to KeyedResourcePool, there are "
  461
+                                    + queue.size() + " destinations checked in.");
445 462
                     }
446 463
                 } catch(Exception e) {
447 464
                     // If nonBlockingPut throws an exception, then we could leak

0 notes on commit e6ec7a0

Please sign in to comment.
Something went wrong with that request. Please try again.