import org.opendaylight.controller.cluster.raft.messages.InstallSnapshotReply;
import org.opendaylight.controller.cluster.raft.messages.RaftRPC;
import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
+import org.opendaylight.controller.cluster.raft.messages.UnInitializedFollowerSnapshotReply;
import scala.concurrent.duration.FiniteDuration;
/**
private final Collection<ClientRequestTracker> trackerList = new LinkedList<>();
- protected final int minReplicationCount;
+ private int minReplicationCount;
- protected final int minIsolatedLeaderPeerCount;
+ private int minIsolatedLeaderPeerCount;
private Optional<SnapshotHolder> snapshot;
LOG.debug("{}: Election: Leader has following peers: {}", logName(), getFollowerIds());
- minReplicationCount = getMajorityVoteCount(getFollowerIds().size());
-
- // the isolated Leader peer count will be 1 less than the majority vote count.
- // this is because the vote count has the self vote counted in it
- // for e.g
- // 0 peers = 1 votesRequired , minIsolatedLeaderPeerCount = 0
- // 2 peers = 2 votesRequired , minIsolatedLeaderPeerCount = 1
- // 4 peers = 3 votesRequired, minIsolatedLeaderPeerCount = 2
- minIsolatedLeaderPeerCount = minReplicationCount > 0 ? (minReplicationCount - 1) : 0;
+ updateMinReplicaCountAndMinIsolatedLeaderPeerCount();
snapshot = Optional.absent();
followerToLog.put(followerId, followerLogInformation);
}
+ public void removeFollower(String followerId) {
+ followerToLog.remove(followerId);
+ }
+
+ public void updateMinReplicaCountAndMinIsolatedLeaderPeerCount(){
+ minReplicationCount = getMajorityVoteCount(getFollowerIds().size());
+
+ //the isolated Leader peer count will be 1 less than the majority vote count.
+ //this is because the vote count has the self vote counted in it
+ //for e.g
+ //0 peers = 1 votesRequired , minIsolatedLeaderPeerCount = 0
+ //2 peers = 2 votesRequired , minIsolatedLeaderPeerCount = 1
+ //4 peers = 3 votesRequired, minIsolatedLeaderPeerCount = 2
+ minIsolatedLeaderPeerCount = minReplicationCount > 0 ? (minReplicationCount - 1) : 0;
+ }
+
+ public int getMinIsolatedLeaderPeerCount(){
+ return minIsolatedLeaderPeerCount;
+ }
+
@VisibleForTesting
void setSnapshot(@Nullable Snapshot snapshot) {
if(snapshot != null) {
setSnapshot(null);
}
wasLastChunk = true;
-
+ FollowerState followerState = followerLogInformation.getFollowerState();
+ if(followerState == FollowerState.VOTING_NOT_INITIALIZED){
+ UnInitializedFollowerSnapshotReply unInitFollowerSnapshotSuccess =
+ new UnInitializedFollowerSnapshotReply(followerId);
+ context.getActor().tell(unInitFollowerSnapshotSuccess, context.getActor());
+ LOG.debug("Sent message UnInitializedFollowerSnapshotReply to self");
+ }
} else {
followerToSnapshot.markSendStatus(true);
}