Permalink
Browse files

Minor code clean up based on review feedback

Protected all logger.(debug|info) statements I added with an is(Debug|Info)Enabled() check.

Made AsyncRecoveryFailureDetector less verbose. When it polls a server to see if it is available, it now prints out a clean INFO level message. It had been printing out a WARN level message *with* a stacktrace that made this expected behavior look much scarier than it really is.
  • Loading branch information...
1 parent 4c69fb6 commit e365419c2b58bc291b4b78b4d9aa00731971e881 @jayjwylie jayjwylie committed Nov 17, 2012
@@ -117,12 +117,12 @@ public void run() {
if(logger.isDebugEnabled())
logger.debug("Verified previously unavailable node " + node.getId()
- + ", will mark as available...");
+ + "is now available.");
nodeRecovered(node);
} catch(UnreachableStoreException e) {
- if(logger.isEnabledFor(Level.WARN))
- logger.warn("Node " + node.getId() + " still unavailable", e);
+ if(logger.isInfoEnabled())
+ logger.info("Node " + node.getId() + " still unavailable.");
} catch(Exception e) {
if(logger.isEnabledFor(Level.ERROR))
logger.error("Node " + node.getId() + " unavailable due to error", e);
@@ -97,8 +97,11 @@ public ClientSocketStats(ClientSocketStats parent,
this.pool = pool;
this.jmxId = jmxId;
- logger.debug("Constructed ClientSocketStatsStats object (" + System.identityHashCode(this)
- + ") with parent object(" + System.identityHashCode(parent) + ")");
+ if(logger.isDebugEnabled()) {
+ logger.debug("Constructed ClientSocketStatsStats object ("
+ + System.identityHashCode(this) + ") with parent object("
+ + System.identityHashCode(parent) + ")");
+ }
}
/**
@@ -113,8 +116,11 @@ public ClientSocketStats(int jmxId) {
this.pool = null;
this.jmxId = jmxId;
- logger.debug("Constructed ClientSocketStatsStats object (" + System.identityHashCode(this)
- + ") with parent object(" + System.identityHashCode(parent) + ")");
+ if(logger.isDebugEnabled()) {
+ logger.debug("Constructed ClientSocketStatsStats object ("
+ + System.identityHashCode(this) + ") with parent object("
+ + System.identityHashCode(parent) + ")");
+ }
}
/* get per node stats, create one if not exist */
@@ -58,7 +58,9 @@ public Histogram(int nBuckets, int step) {
this.buckets = new int[nBuckets];
reset();
- logger.debug("Constructed a histogram with " + nBuckets + " buckets.");
+ if(logger.isDebugEnabled()) {
+ logger.debug("Constructed a histogram with " + nBuckets + " buckets.");
+ }
}
/**
@@ -34,8 +34,10 @@ public StoreStats(StoreStats parent) {
}
this.parent = parent;
- logger.debug("Constructed StoreStats object (" + System.identityHashCode(this)
- + ") with parent object (" + System.identityHashCode(parent) + ")");
+ if(logger.isDebugEnabled()) {
+ logger.debug("Constructed StoreStats object (" + System.identityHashCode(this)
+ + ") with parent object (" + System.identityHashCode(parent) + ")");
+ }
}
/**
@@ -298,7 +298,9 @@ public int getTotalResourceCount(K key) {
Pool<V> resourcePool = getResourcePoolForExistingKey(key);
return resourcePool.size.get();
} catch(IllegalArgumentException iae) {
- logger.debug("getTotalResourceCount called on invalid key: ", iae);
+ if(logger.isDebugEnabled()) {
+ logger.debug("getTotalResourceCount called on invalid key: ", iae);
+ }
}
}
return 0;
@@ -331,7 +333,9 @@ public int getCheckedInResourcesCount(K key) {
Pool<V> resourcePool = getResourcePoolForExistingKey(key);
return resourcePool.queue.size();
} catch(IllegalArgumentException iae) {
- logger.debug("getCheckedInResourceCount called on invalid key: ", iae);
+ if(logger.isDebugEnabled()) {
+ logger.debug("getCheckedInResourceCount called on invalid key: ", iae);
+ }
}
}
return 0;
@@ -364,7 +368,9 @@ public int getBlockingGetsCount(K key) {
Pool<V> resourcePool = getResourcePoolForExistingKey(key);
return resourcePool.blockingGets.get();
} catch(IllegalArgumentException iae) {
- logger.debug("getBlockingGetsCount called on invalid key: ", iae);
+ if(logger.isDebugEnabled()) {
+ logger.debug("getBlockingGetsCount called on invalid key: ", iae);
+ }
}
}
return 0;
@@ -438,10 +444,12 @@ public Pool(ResourcePoolConfig resourcePoolConfig) {
if(!nonBlockingPut(resource)) {
this.size.decrementAndGet();
objectFactory.destroy(key, resource);
- logger.info("attemptGrow established new connection for key "
- + key.toString()
- + " and immediately destroyed the new connection "
- + "because there were too many connections already established.");
+ if(logger.isInfoEnabled()) {
+ logger.info("attemptGrow established new connection for key "
+ + key.toString()
+ + " and immediately destroyed the new connection "
+ + "because there were too many connections already established.");
+ }
return false;
}
if(logger.isDebugEnabled()) {
@@ -340,7 +340,9 @@ public int getRegisteredResourceRequestCount(K key) {
// FYI: .size() is not constant time in the next call. ;)
return requestQueue.size();
} catch(IllegalArgumentException iae) {
- logger.debug("getRegisteredResourceRequestCount called on invalid key: ", iae);
+ if(logger.isDebugEnabled()) {
+ logger.debug("getRegisteredResourceRequestCount called on invalid key: ", iae);
+ }
}
}
return 0;
@@ -297,7 +297,6 @@ public void contendForResources() throws Exception {
try {
waitForCheckers.await();
assertEquals(this.pool.getCheckedInResourceCount(), this.pool.getTotalResourceCount());
- // assertEquals(POOL_SIZE, this.pool.getCheckedInResourceCount());
} catch(InterruptedException e) {
e.printStackTrace();
}

0 comments on commit e365419

Please sign in to comment.