log message fixes in DeviceManager

Change-Id: Ia07cfa936d171a31c619e1ee13d6df5f80d7e629
This commit is contained in:
Yuta HIGUCHI 2014-10-31 11:38:04 -07:00
parent 13c0b87df5
commit 2d3cd31c61

View File

@ -259,9 +259,13 @@ public class DeviceManager
final NodeId myNodeId = clusterService.getLocalNode().id(); final NodeId myNodeId = clusterService.getLocalNode().id();
if (!myNodeId.equals(term.master())) { if (!myNodeId.equals(term.master())) {
// lost mastership after requestRole told this instance was MASTER. // lost mastership after requestRole told this instance was MASTER.
log.info("lost mastership before getting term info."); log.info("Role of this node is STANDBY for {}", deviceId);
// TODO: Do we need to explicitly tell the Provider that
// this instance is no longer the MASTER?
//applyRole(deviceId, MastershipRole.STANDBY);
return; return;
} }
log.info("Role of this node is MASTER for {}", deviceId);
// tell clock provider if this instance is the master // tell clock provider if this instance is the master
deviceClockProviderService.setMastershipTerm(deviceId, term); deviceClockProviderService.setMastershipTerm(deviceId, term);
@ -295,6 +299,7 @@ public class DeviceManager
checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(deviceId, DEVICE_ID_NULL);
checkValidity(); checkValidity();
log.info("Device {} disconnected from this node", deviceId);
DeviceEvent event = null; DeviceEvent event = null;
try { try {
@ -318,18 +323,18 @@ public class DeviceManager
final NodeId myNodeId = clusterService.getLocalNode().id(); final NodeId myNodeId = clusterService.getLocalNode().id();
// TODO: Move this type of check inside device clock manager, etc. // TODO: Move this type of check inside device clock manager, etc.
if (myNodeId.equals(term.master())) { if (myNodeId.equals(term.master())) {
log.info("Marking {} offline", deviceId); log.info("Retry marking {} offline", deviceId);
deviceClockProviderService.setMastershipTerm(deviceId, term); deviceClockProviderService.setMastershipTerm(deviceId, term);
event = store.markOffline(deviceId); event = store.markOffline(deviceId);
} else { } else {
log.error("Failed again marking {} offline. {}", deviceId, role); log.info("Failed again marking {} offline. {}", deviceId, role);
} }
} finally { } finally {
//relinquish master role and ability to be backup. //relinquish master role and ability to be backup.
mastershipService.relinquishMastership(deviceId); mastershipService.relinquishMastership(deviceId);
if (event != null) { if (event != null) {
log.info("Device {} disconnected", deviceId); log.info("Device {} disconnected from cluster", deviceId);
post(event); post(event);
} }
} }