Logging improvements.
Change-Id: I79b9ff16a0000e4bd72022f02baef5c779ea1b48
diff --git a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
index 787b372..dcb2dbd 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DistributedLeadershipManager.java
@@ -87,7 +87,7 @@
private static final int DELAY_BETWEEN_LEADER_LOCK_ATTEMPTS_SEC = 2;
private static final int DEADLOCK_DETECTION_INTERVAL_SEC = 2;
- private static final int LEADERSHIP_STATUS_UPDATE_INTERVAL = 2;
+ private static final int LEADERSHIP_STATUS_UPDATE_INTERVAL_SEC = 2;
private static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
@@ -134,7 +134,7 @@
deadLockDetectionExecutor.scheduleWithFixedDelay(
this::purgeStaleLocks, 0, DEADLOCK_DETECTION_INTERVAL_SEC, TimeUnit.SECONDS);
leadershipStatusBroadcaster.scheduleWithFixedDelay(
- this::sendLeadershipStatus, 0, LEADERSHIP_STATUS_UPDATE_INTERVAL, TimeUnit.SECONDS);
+ this::sendLeadershipStatus, 0, LEADERSHIP_STATUS_UPDATE_INTERVAL_SEC, TimeUnit.SECONDS);
listenerRegistry = new AbstractListenerRegistry<>();
eventDispatcher.addSink(LeadershipEvent.class, listenerRegistry);
@@ -190,7 +190,7 @@
@Override
public void runForLeadership(String path) {
- log.info("Running for leadership for topic: {}", path);
+ log.trace("Running for leadership for topic: {}", path);
activeTopics.add(path);
tryLeaderLock(path);
}
@@ -200,11 +200,11 @@
activeTopics.remove(path);
try {
if (lockMap.remove(path, localNodeId)) {
- log.info("Sucessfully gave up leadership for {}", path);
+ log.info("Gave up leadership for {}", path);
}
// else we are not the current owner.
} catch (Exception e) {
- log.warn("Failed to verify (and clear) any lock this node might be holding for {}", path, e);
+ log.debug("Failed to verify (and clear) any lock this node might be holding for {}", path, e);
}
}
@@ -244,7 +244,7 @@
}
}
} catch (Exception e) {
- log.warn("Attempt to acquire leadership lock for topic {} failed", path, e);
+ log.debug("Attempt to acquire leadership lock for topic {} failed", path, e);
retry(path);
}
}
@@ -300,7 +300,7 @@
LeadershipEvent leadershipEvent =
SERIALIZER.decode(message.payload());
- log.trace("Leadership Event: time = {} type = {} event = {}",
+ log.debug("Leadership Event: time = {} type = {} event = {}",
leadershipEvent.time(), leadershipEvent.type(),
leadershipEvent);
@@ -350,7 +350,7 @@
log.info("Lock for {} is held by {} which is currently inactive", path, nodeId);
try {
if (lockMap.remove(path, epoch)) {
- log.info("Successfully purged stale lock held by {} for {}", nodeId, path);
+ log.info("Purged stale lock held by {} for {}", nodeId, path);
notifyRemovedLeader(path, nodeId, epoch);
}
} catch (Exception e) {
@@ -361,7 +361,7 @@
log.info("Lock for {} is held by {} when it not running for leadership.", path, nodeId);
try {
if (lockMap.remove(path, epoch)) {
- log.info("Successfully purged stale lock held by {} for {}", nodeId, path);
+ log.info("Purged stale lock held by {} for {}", nodeId, path);
notifyRemovedLeader(path, nodeId, epoch);
}
} catch (Exception e) {
@@ -370,20 +370,24 @@
}
});
} catch (Exception e) {
- log.warn("Failed cleaning up stale locks", e);
+ log.debug("Failed cleaning up stale locks", e);
}
}
private void sendLeadershipStatus() {
- leaderBoard.forEach((path, leadership) -> {
- if (leadership.leader().equals(localNodeId)) {
- LeadershipEvent event = new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED, leadership);
- clusterCommunicator.broadcast(
- new ClusterMessage(
- clusterService.getLocalNode().id(),
- LEADERSHIP_EVENT_MESSAGE_SUBJECT,
- SERIALIZER.encode(event)));
- }
- });
+ try {
+ leaderBoard.forEach((path, leadership) -> {
+ if (leadership.leader().equals(localNodeId)) {
+ LeadershipEvent event = new LeadershipEvent(LeadershipEvent.Type.LEADER_ELECTED, leadership);
+ clusterCommunicator.broadcast(
+ new ClusterMessage(
+ clusterService.getLocalNode().id(),
+ LEADERSHIP_EVENT_MESSAGE_SUBJECT,
+ SERIALIZER.encode(event)));
+ }
+ });
+ } catch (Exception e) {
+ log.debug("Failed to send leadership updates", e);
+ }
}
-}
\ No newline at end of file
+}