Yuta HIGUCHI

added FIXME for disconnection corner case

- disconnection event triggered while
  DeviceManager recognition of mastership is not in sync yet.

Change-Id: I03959ca59a4220a8e91b88f2f8565c883e39a93f
...@@ -276,9 +276,15 @@ public class DeviceManager ...@@ -276,9 +276,15 @@ public class DeviceManager
276 //there are times when this node will correctly have mastership, BUT 276 //there are times when this node will correctly have mastership, BUT
277 //that isn't reflected in the ClockManager before the device disconnects. 277 //that isn't reflected in the ClockManager before the device disconnects.
278 //we want to let go of the device anyways, so make sure this happens. 278 //we want to let go of the device anyways, so make sure this happens.
279 +
280 + // FIXME: Come up with workaround for above scenario.
279 MastershipTerm term = termService.getMastershipTerm(deviceId); 281 MastershipTerm term = termService.getMastershipTerm(deviceId);
280 - deviceClockProviderService.setMastershipTerm(deviceId, term); 282 + final NodeId myNodeId = clusterService.getLocalNode().id();
281 - event = store.markOffline(deviceId); 283 + // TODO: Move this type of check inside device clock manager, etc.
284 + if (myNodeId.equals(term.master())) {
285 + deviceClockProviderService.setMastershipTerm(deviceId, term);
286 + event = store.markOffline(deviceId);
287 + }
282 } finally { 288 } finally {
283 //relinquish master role and ability to be backup. 289 //relinquish master role and ability to be backup.
284 mastershipService.relinquishMastership(deviceId); 290 mastershipService.relinquishMastership(deviceId);
......