accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner commented on a change in pull request #368: ACCUMULO-4777: fix log messages
Date Thu, 01 Jan 1970 00:00:00 GMT
keith-turner commented on a change in pull request #368: ACCUMULO-4777: fix log messages
URL: https://github.com/apache/accumulo/pull/368#discussion_r165090810
 
 

 ##########
 File path: fate/src/main/java/org/apache/accumulo/fate/zookeeper/Retry.java
 ##########
 @@ -125,12 +149,51 @@ public long retriesCompleted() {
   }
 
   public void waitForNextAttempt() throws InterruptedException {
-    log.debug("Sleeping for " + currentWait + "ms before retrying operation");
+    if (log.isDebugEnabled()) {
+      log.debug("Sleeping for " + currentWait + "ms before retrying operation: " + getCaller());
+    }
     sleep(currentWait);
     currentWait = Math.min(maxWait, currentWait + waitIncrement);
   }
 
   protected void sleep(long wait) throws InterruptedException {
     Thread.sleep(wait);
   }
+
+  public void logRetry(String message, Throwable t) {
+    // log the first time, and then after every logInterval
+    if (lastRetryLog < 0 || (System.currentTimeMillis() - lastRetryLog) > logInterval)
{
+      log.warn(getMessage(message), t);
+      lastRetryLog = System.currentTimeMillis();
+    }
+  }
+
+  public void logRetry(String message) {
 
 Review comment:
   Another possibility is to have the caller pass in a logger like `logRetry(Logger log, String
message)`.  If this is done, would the `getCaller()` method be needed?  Also the `setLogger()`
method would not be needed for testing.   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message