activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: Logging cleanup, don't need all the if checks, use string substitution more effectively.
Date Thu, 19 Sep 2013 19:19:55 GMT
Updated Branches:
  refs/heads/trunk c38752221 -> c7d33ad5e


Logging cleanup, don't need all the if checks, use string substitution
more effectively.  

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/c7d33ad5
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/c7d33ad5
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/c7d33ad5

Branch: refs/heads/trunk
Commit: c7d33ad5e43a11c929d8840fd4f89a7eab13f8d0
Parents: c387522
Author: Timothy Bish <tabish121@gmai.com>
Authored: Thu Sep 19 15:18:02 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Thu Sep 19 15:19:24 2013 -0400

----------------------------------------------------------------------
 .../transport/AbstractInactivityMonitor.java    | 46 ++++++--------------
 .../transport/stomp/StompInactivityMonitor.java | 12 ++---
 2 files changed, 18 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/c7d33ad5/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
index a797645..8fbf623 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
@@ -80,8 +80,8 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
             long now = System.currentTimeMillis();
             long elapsed = (now - lastRunTime);
 
-            if (lastRunTime != 0 && LOG.isDebugEnabled()) {
-                LOG.debug("" + elapsed + " ms elapsed since last read check.");
+            if (lastRunTime != 0) {
+                LOG.debug("{}ms elapsed since last read check.", elapsed);
             }
 
             // Perhaps the timer executed a read check late.. and then executes
@@ -89,10 +89,9 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
             // read checks to be small..
 
             // If less than 90% of the read check Time elapsed then abort this
-            // readcheck.
-            if (!allowReadCheck(elapsed)) { // FUNKY qdox bug does not allow me
-                                            // to inline this expression.
-                LOG.debug("Aborting read check.. Not enough time elapsed since last read
check.");
+            // read check.
+            if (!allowReadCheck(elapsed)) {
+                LOG.debug("Aborting read check...Not enough time elapsed since last read
check.");
                 return;
             }
 
@@ -116,9 +115,8 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
         @Override
         public void run() {
             long now = System.currentTimeMillis();
-            if (lastRunTime != 0 && LOG.isDebugEnabled()) {
-                LOG.debug(this + " " + (now - lastRunTime) + " ms elapsed since last write
check.");
-
+            if (lastRunTime != 0) {
+                LOG.debug("{}: {}ms elapsed since last write check.", this, (now - lastRunTime));
             }
             lastRunTime = now;
             writeCheck();
@@ -149,25 +147,18 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
 
     final void writeCheck() {
         if (inSend.get()) {
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("A send is in progress");
-            }
+            LOG.trace("Send in progress. Skipping write check.");
             return;
         }
 
         if (!commandSent.get() && useKeepAlive && monitorStarted.get() &&
!ASYNC_TASKS.isTerminating() && !ASYNC_TASKS.isTerminated()) {
-
-            if (LOG.isTraceEnabled()) {
-                LOG.trace(this + " no message sent since last write check, sending a KeepAliveInfo");
-            }
+            LOG.trace("{} no message sent since last write check, sending a KeepAliveInfo",
this);
 
             try {
                 ASYNC_TASKS.execute(new Runnable() {
                     @Override
                     public void run() {
-                        if (LOG.isDebugEnabled()) {
-                            LOG.debug("Running {}", this);
-                        }
+                        LOG.debug("Running {}", this);
                         if (monitorStarted.get()) {
                             try {
                                 // If we can't get the lock it means another
@@ -200,9 +191,7 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
                 }
             }
         } else {
-            if (LOG.isTraceEnabled()) {
-                LOG.trace(this + " message sent since last write check, resetting flag");
-            }
+            LOG.trace("{} message sent since last write check, resetting flag.", this);
         }
 
         commandSent.set(false);
@@ -212,24 +201,17 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
         int currentCounter = next.getReceiveCounter();
         int previousCounter = lastReceiveCounter.getAndSet(currentCounter);
         if (inReceive.get() || currentCounter != previousCounter) {
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("A receive is in progress");
-            }
+            LOG.trace("A receive is in progress, skipping read check.");
             return;
         }
         if (!commandReceived.get() && monitorStarted.get() && !ASYNC_TASKS.isTerminating()
&& !ASYNC_TASKS.isTerminated()) {
-
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("No message received since last read check for " + toString() +
". Throwing InactivityIOException.");
-            }
+            LOG.debug("No message received since last read check for {}. Throwing InactivityIOException.",
this);
 
             try {
                 ASYNC_TASKS.execute(new Runnable() {
                     @Override
                     public void run() {
-                        if (LOG.isDebugEnabled()) {
-                            LOG.debug("Running {}", this);
-                        }
+                        LOG.debug("Running {}", this);
                         onException(new InactivityIOException("Channel was inactive for too
(>" + readCheckTime + ") long: " + next.getRemoteAddress()));
                     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/c7d33ad5/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompInactivityMonitor.java
----------------------------------------------------------------------
diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompInactivityMonitor.java
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompInactivityMonitor.java
index c76ead9..8b1bc33 100755
--- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompInactivityMonitor.java
+++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompInactivityMonitor.java
@@ -49,7 +49,7 @@ public class StompInactivityMonitor extends AbstractInactivityMonitor {
     }
 
     @Override
-    protected void processOutboundWireFormatInfo(WireFormatInfo info) throws IOException{
+    protected void processOutboundWireFormatInfo(WireFormatInfo info) throws IOException
{
     }
 
     @Override
@@ -59,13 +59,9 @@ public class StompInactivityMonitor extends AbstractInactivityMonitor {
             return false;
         }
 
-        LOG.debug("Stomp Inactivity Monitor read check: " + getReadCheckTime() +
-                  ", write check: " + getWriteCheckTime());
+        LOG.debug("Stomp Inactivity Monitor read check interval: {}ms, write check interval:
{}ms",
+                  getReadCheckTime(), getWriteCheckTime());
 
-        if (this.getReadCheckTime() >= 0 && this.getWriteCheckTime() >= 0)
{
-            return true;
-        }
-
-        return false;
+        return this.getReadCheckTime() >= 0 && this.getWriteCheckTime() >=
0;
     }
 }


Mime
View raw message