Skip to content

Commit

Permalink
isSuspiciousTransportException -> getLogLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Ershov committed Mar 8, 2019
1 parent 0b19f03 commit 737e7f8
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.cluster.coordination;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand Down Expand Up @@ -190,24 +191,22 @@ private static class FailedJoinAttempt {
}

void maybeLogNow() {
if (isSuspiciousTransportException(exception)) {
logger.info(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception);
} else {
logger.debug(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception);
}
logger.log(getLogLevel(exception),
() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest),
exception);
}

boolean isSuspiciousTransportException(TransportException e) {
static Level getLogLevel(TransportException e) {
if (e instanceof RemoteTransportException) {
Throwable cause = e.getCause();
if (cause != null &&
cause instanceof CoordinationStateRejectedException ||
cause instanceof FailedToCommitClusterStateException ||
cause instanceof NotMasterException) {
return false;
return Level.DEBUG;
}
}
return true;
return Level.INFO;
}

void logWarnWithTimestamp() {
Expand Down

0 comments on commit 737e7f8

Please sign in to comment.