Jon Hall
Committed by Gerrit Code Review

Dynamic Clustering fixes

Addresses [ONOS-4501] and maybe [ONOS-4404]

Change-Id: I2bce2d60106e6887d692de484d22b109678ffd46
......@@ -200,18 +200,24 @@ public class StoragePartition implements Managed<StoragePartition> {
return server != null && server.isOpen() ? Optional.of(server.info()) : Optional.empty();
}
/**
* Process updates to partitions and handles joining or leaving a partition.
* @param newValue new Partition
*/
public void onUpdate(Partition newValue) {
if (partition.getMembers().contains(localNodeId) && newValue.getMembers().contains(localNodeId)) {
return;
}
if (!partition.getMembers().contains(localNodeId) && !newValue.getMembers().contains(localNodeId)) {
boolean wasPresent = partition.getMembers().contains(localNodeId);
boolean isPresent = newValue.getMembers().contains(localNodeId);
this.partition = newValue;
if ((wasPresent && isPresent) || (!wasPresent && !isPresent)) {
// no action needed
return;
}
this.partition = newValue;
if (partition.getMembers().contains(localNodeId)) {
joinCluster();
} else if (!partition.getMembers().contains(localNodeId)) {
//only need to do action if our membership changed
if (wasPresent) {
leaveCluster();
} else if (isPresent) {
joinCluster();
}
}
}
......