Skip to content

Commit 737e7f8

Browse files
author
Andrey Ershov
committed
isSuspiciousTransportException -> getLogLevel
1 parent 0b19f03 commit 737e7f8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.cluster.coordination;
2020

21+
import org.apache.logging.log4j.Level;
2122
import org.apache.logging.log4j.LogManager;
2223
import org.apache.logging.log4j.Logger;
2324
import org.apache.logging.log4j.message.ParameterizedMessage;
@@ -190,24 +191,22 @@ private static class FailedJoinAttempt {
190191
}
191192

192193
void maybeLogNow() {
193-
if (isSuspiciousTransportException(exception)) {
194-
logger.info(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception);
195-
} else {
196-
logger.debug(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception);
197-
}
194+
logger.log(getLogLevel(exception),
195+
() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest),
196+
exception);
198197
}
199198

200-
boolean isSuspiciousTransportException(TransportException e) {
199+
static Level getLogLevel(TransportException e) {
201200
if (e instanceof RemoteTransportException) {
202201
Throwable cause = e.getCause();
203202
if (cause != null &&
204203
cause instanceof CoordinationStateRejectedException ||
205204
cause instanceof FailedToCommitClusterStateException ||
206205
cause instanceof NotMasterException) {
207-
return false;
206+
return Level.DEBUG;
208207
}
209208
}
210-
return true;
209+
return Level.INFO;
211210
}
212211

213212
void logWarnWithTimestamp() {

0 commit comments

Comments
 (0)