Thomas Vachuska
Committed by Gerrit Code Review

Fixed an issue where only the new device master node would receive mastership change events.

Change-Id: I08a6530c57c91f006994412b4dfbfb3c16571593
...@@ -400,25 +400,22 @@ public class ConsistentDeviceMastershipStore ...@@ -400,25 +400,22 @@ public class ConsistentDeviceMastershipStore
400 if (!isDeviceMastershipTopic(leadership.topic())) { 400 if (!isDeviceMastershipTopic(leadership.topic())) {
401 return; 401 return;
402 } 402 }
403 - NodeId nodeId = leadership.leader();
404 DeviceId deviceId = extractDeviceIdFromTopic(leadership.topic()); 403 DeviceId deviceId = extractDeviceIdFromTopic(leadership.topic());
405 - if (Objects.equal(nodeId, localNodeId) && connectedDevices.contains(deviceId)) { 404 + switch (event.type()) {
406 - switch (event.type()) { 405 + case LEADER_ELECTED:
407 - case LEADER_ELECTED: 406 + notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, getNodes(deviceId)));
408 - notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, getNodes(deviceId))); 407 + break;
409 - break; 408 + case LEADER_REELECTED:
410 - case LEADER_REELECTED: 409 + // There is no concept of leader re-election in the new distributed leadership manager.
411 - // There is no concept of leader re-election in the new distributed leadership manager. 410 + throw new IllegalStateException("Unexpected event type");
412 - throw new IllegalStateException("Unexpected event type"); 411 + case LEADER_BOOTED:
413 - case LEADER_BOOTED: 412 + notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, getNodes(deviceId)));
414 - notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, getNodes(deviceId))); 413 + break;
415 - break; 414 + case CANDIDATES_CHANGED:
416 - case CANDIDATES_CHANGED: 415 + notifyDelegate(new MastershipEvent(BACKUPS_CHANGED, deviceId, getNodes(deviceId)));
417 - notifyDelegate(new MastershipEvent(BACKUPS_CHANGED, deviceId, getNodes(deviceId))); 416 + break;
418 - break; 417 + default:
419 - default: 418 + return;
420 - return;
421 - }
422 } 419 }
423 } 420 }
424 } 421 }
......