Committed by
Gerrit Code Review
Mastership role is determined by whether the node is leader or merely a candidat…
…e for device mastership topic. Change-Id: Ic2142aaa1ec0b215d2247596b934dbbfb0cedc25
Showing
1 changed file
with
2 additions
and
23 deletions
| ... | @@ -90,8 +90,6 @@ public class ConsistentDeviceMastershipStore | ... | @@ -90,8 +90,6 @@ public class ConsistentDeviceMastershipStore |
| 90 | private NodeId localNodeId; | 90 | private NodeId localNodeId; |
| 91 | private final Set<DeviceId> connectedDevices = Sets.newHashSet(); | 91 | private final Set<DeviceId> connectedDevices = Sets.newHashSet(); |
| 92 | 92 | ||
| 93 | - private static final MessageSubject ROLE_QUERY_SUBJECT = | ||
| 94 | - new MessageSubject("mastership-store-device-role-query"); | ||
| 95 | private static final MessageSubject ROLE_RELINQUISH_SUBJECT = | 93 | private static final MessageSubject ROLE_RELINQUISH_SUBJECT = |
| 96 | new MessageSubject("mastership-store-device-role-relinquish"); | 94 | new MessageSubject("mastership-store-device-role-relinquish"); |
| 97 | private static final MessageSubject TRANSITION_FROM_MASTER_TO_STANDBY_SUBJECT = | 95 | private static final MessageSubject TRANSITION_FROM_MASTER_TO_STANDBY_SUBJECT = |
| ... | @@ -129,11 +127,6 @@ public class ConsistentDeviceMastershipStore | ... | @@ -129,11 +127,6 @@ public class ConsistentDeviceMastershipStore |
| 129 | transferExecutor = | 127 | transferExecutor = |
| 130 | Executors.newSingleThreadScheduledExecutor( | 128 | Executors.newSingleThreadScheduledExecutor( |
| 131 | groupedThreads("onos/store/device/mastership", "mastership-transfer-executor")); | 129 | groupedThreads("onos/store/device/mastership", "mastership-transfer-executor")); |
| 132 | - clusterCommunicator.<DeviceId, MastershipRole>addSubscriber(ROLE_QUERY_SUBJECT, | ||
| 133 | - SERIALIZER::decode, | ||
| 134 | - deviceId -> getRole(localNodeId, deviceId), | ||
| 135 | - SERIALIZER::encode, | ||
| 136 | - messageHandlingExecutor); | ||
| 137 | clusterCommunicator.<DeviceId, MastershipEvent>addSubscriber(ROLE_RELINQUISH_SUBJECT, | 130 | clusterCommunicator.<DeviceId, MastershipEvent>addSubscriber(ROLE_RELINQUISH_SUBJECT, |
| 138 | SERIALIZER::decode, | 131 | SERIALIZER::decode, |
| 139 | this::relinquishLocalRole, | 132 | this::relinquishLocalRole, |
| ... | @@ -152,7 +145,6 @@ public class ConsistentDeviceMastershipStore | ... | @@ -152,7 +145,6 @@ public class ConsistentDeviceMastershipStore |
| 152 | 145 | ||
| 153 | @Deactivate | 146 | @Deactivate |
| 154 | public void deactivate() { | 147 | public void deactivate() { |
| 155 | - clusterCommunicator.removeSubscriber(ROLE_QUERY_SUBJECT); | ||
| 156 | clusterCommunicator.removeSubscriber(ROLE_RELINQUISH_SUBJECT); | 148 | clusterCommunicator.removeSubscriber(ROLE_RELINQUISH_SUBJECT); |
| 157 | clusterCommunicator.removeSubscriber(TRANSITION_FROM_MASTER_TO_STANDBY_SUBJECT); | 149 | clusterCommunicator.removeSubscriber(TRANSITION_FROM_MASTER_TO_STANDBY_SUBJECT); |
| 158 | messageHandlingExecutor.shutdown(); | 150 | messageHandlingExecutor.shutdown(); |
| ... | @@ -193,21 +185,8 @@ public class ConsistentDeviceMastershipStore | ... | @@ -193,21 +185,8 @@ public class ConsistentDeviceMastershipStore |
| 193 | if (leadership != null && nodeId.equals(leadership.leader())) { | 185 | if (leadership != null && nodeId.equals(leadership.leader())) { |
| 194 | return MastershipRole.MASTER; | 186 | return MastershipRole.MASTER; |
| 195 | } | 187 | } |
| 196 | - | 188 | + return leadershipService.getCandidates(leadershipTopic).contains(nodeId) ? |
| 197 | - if (localNodeId.equals(nodeId)) { | 189 | + MastershipRole.STANDBY : MastershipRole.NONE; |
| 198 | - if (connectedDevices.contains(deviceId)) { | ||
| 199 | - return MastershipRole.STANDBY; | ||
| 200 | - } else { | ||
| 201 | - return MastershipRole.NONE; | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - MastershipRole role = futureGetOrElse(clusterCommunicator.sendAndReceive( | ||
| 205 | - deviceId, | ||
| 206 | - ROLE_QUERY_SUBJECT, | ||
| 207 | - SERIALIZER::encode, | ||
| 208 | - SERIALIZER::decode, | ||
| 209 | - nodeId), null); | ||
| 210 | - return role == null ? MastershipRole.NONE : role; | ||
| 211 | } | 190 | } |
| 212 | 191 | ||
| 213 | @Override | 192 | @Override | ... | ... |
-
Please register or login to post a comment