keith-turner commented on a change in pull request #368: ACCUMULO-4777: fix log
messages
URL: https://github.com/apache/accumulo/pull/368#discussion_r164920845
##########
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:
Random thought, not advocating for this. In 2.0.0-SNAP which uses java 8,
could pass in a lambda that does the actual logging. This code just decides
whether or not to call it. Not sure, but this may remove the need to inspect
the stack trace to get info about caller.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services