+ public void addFollower(String followerId, FollowerState followerState) {
+ FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl(followerId, -1, context);
+ followerLogInformation.setFollowerState(followerState);
+ followerToLog.put(followerId, followerLogInformation);
+
+ if(heartbeatSchedule == null) {
+ scheduleHeartBeat(context.getConfigParams().getHeartBeatInterval());
+ }
+ }
+
+ 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;
+ }
+
+ protected int getMinIsolatedLeaderPeerCount(){
+ return minIsolatedLeaderPeerCount;
+ }
+