Committed by
Gerrit Code Review
Dynamic Clustering fixes
Addresses [ONOS-4501] and maybe [ONOS-4404] Change-Id: I2bce2d60106e6887d692de484d22b109678ffd46 (cherry picked from commit 1195afbc)
Showing
1 changed file
with
14 additions
and
8 deletions
| ... | @@ -200,18 +200,24 @@ public class StoragePartition implements Managed<StoragePartition> { | ... | @@ -200,18 +200,24 @@ public class StoragePartition implements Managed<StoragePartition> { |
| 200 | return server != null && server.isOpen() ? Optional.of(server.info()) : Optional.empty(); | 200 | return server != null && server.isOpen() ? Optional.of(server.info()) : Optional.empty(); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | + /** | ||
| 204 | + * Process updates to partitions and handles joining or leaving a partition. | ||
| 205 | + * @param newValue new Partition | ||
| 206 | + */ | ||
| 203 | public void onUpdate(Partition newValue) { | 207 | public void onUpdate(Partition newValue) { |
| 204 | - if (partition.getMembers().contains(localNodeId) && newValue.getMembers().contains(localNodeId)) { | 208 | + |
| 205 | - return; | 209 | + boolean wasPresent = partition.getMembers().contains(localNodeId); |
| 206 | - } | 210 | + boolean isPresent = newValue.getMembers().contains(localNodeId); |
| 207 | - if (!partition.getMembers().contains(localNodeId) && !newValue.getMembers().contains(localNodeId)) { | 211 | + this.partition = newValue; |
| 212 | + if ((wasPresent && isPresent) || (!wasPresent && !isPresent)) { | ||
| 213 | + // no action needed | ||
| 208 | return; | 214 | return; |
| 209 | } | 215 | } |
| 210 | - this.partition = newValue; | 216 | + //only need to do action if our membership changed |
| 211 | - if (partition.getMembers().contains(localNodeId)) { | 217 | + if (wasPresent) { |
| 212 | - joinCluster(); | ||
| 213 | - } else if (!partition.getMembers().contains(localNodeId)) { | ||
| 214 | leaveCluster(); | 218 | leaveCluster(); |
| 219 | + } else if (isPresent) { | ||
| 220 | + joinCluster(); | ||
| 215 | } | 221 | } |
| 216 | } | 222 | } |
| 217 | } | 223 | } | ... | ... |
-
Please register or login to post a comment