[Zen2] Minor logging improvements (#36818)

* Adds term number and greppable phrase 'coordinator becoming' to Coordinator
  mode changes
* Adds term and version to messages from the ClusterApplier about master
  changes
* Reduces some LeaderChecker messages to TRACE level
This commit is contained in:
David Turner 2018-12-20 15:31:52 +00:00 committed by GitHub
parent b42074c1cc
commit 52d34e45e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -403,7 +403,8 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
void becomeCandidate(String method) {
assert Thread.holdsLock(mutex) : "Coordinator mutex not held";
logger.debug("{}: becoming CANDIDATE (was {}, lastKnownLeader was [{}])", method, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming CANDIDATE in term {} (was {}, lastKnownLeader was [{}])",
method, getCurrentTerm(), mode, lastKnownLeader);
if (mode != Mode.CANDIDATE) {
mode = Mode.CANDIDATE;
@ -440,7 +441,8 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
assert mode == Mode.CANDIDATE : "expected candidate but was " + mode;
assert getLocalNode().isMasterNode() : getLocalNode() + " became a leader but is not master-eligible";
logger.debug("{}: becoming LEADER (was {}, lastKnownLeader was [{}])", method, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming LEADER in term {} (was {}, lastKnownLeader was [{}])",
method, getCurrentTerm(), mode, lastKnownLeader);
mode = Mode.LEADER;
joinAccumulator.close(mode);
@ -461,7 +463,8 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
assert Thread.holdsLock(mutex) : "Coordinator mutex not held";
assert leaderNode.isMasterNode() : leaderNode + " became a leader but is not master-eligible";
logger.debug("{}: becoming FOLLOWER of [{}] (was {}, lastKnownLeader was [{}])", method, leaderNode, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming FOLLOWER of [{}] in term {} (was {}, lastKnownLeader was [{}])",
method, leaderNode, getCurrentTerm(), mode, lastKnownLeader);
final boolean restartLeaderChecker = (mode == Mode.FOLLOWER && Optional.of(leaderNode).equals(lastKnownLeader)) == false;

View File

@ -203,7 +203,7 @@ public class LeaderChecker {
@Override
public void close() {
if (isClosed.compareAndSet(false, true) == false) {
logger.debug("already closed");
logger.trace("already closed, doing nothing");
} else {
logger.debug("closed");
}
@ -211,7 +211,7 @@ public class LeaderChecker {
void handleWakeUp() {
if (isClosed.get()) {
logger.debug("closed check scheduler woken up, doing nothing");
logger.trace("closed check scheduler woken up, doing nothing");
return;
}
@ -289,7 +289,7 @@ public class LeaderChecker {
if (isClosed.compareAndSet(false, true)) {
transportService.getThreadPool().generic().execute(onLeaderFailure);
} else {
logger.debug("already closed, not failing leader");
logger.trace("already closed, not failing leader");
}
}

View File

@ -446,7 +446,8 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements
if (nodesDelta.hasChanges() && logger.isInfoEnabled()) {
String summary = nodesDelta.shortSummary();
if (summary.length() > 0) {
logger.info("{}, reason: {}", summary, task.source);
logger.info("{}, term: {}, version: {}, reason: {}",
summary, newClusterState.term(), newClusterState.version(), task.source);
}
}

View File

@ -230,7 +230,8 @@ public class MasterService extends AbstractLifecycleComponent {
if (nodesDelta.hasChanges() && logger.isInfoEnabled()) {
String nodeSummary = nodesDelta.shortSummary();
if (nodeSummary.length() > 0) {
logger.info("{}, reason: {}", summary, nodeSummary);
logger.info("{}, term: {}, version: {}, reason: {}",
summary, newClusterState.term(), newClusterState.version(), nodeSummary);
}
}