-public class Leader extends AbstractRaftActorBehavior {
-
-
- private final Map<String, FollowerLogInformation> followerToLog =
- new HashMap();
-
- private final Set<String> followers;
-
- private Cancellable heartbeatSchedule = null;
- private Cancellable appendEntriesSchedule = null;
- private Cancellable installSnapshotSchedule = null;
-
- private List<ClientRequestTracker> trackerList = new ArrayList<>();
-
- private final int minReplicationCount;
-
- public Leader(RaftActorContext context) {
- super(context);
-
- if (lastIndex() >= 0) {
- context.setCommitIndex(lastIndex());
- }
-
- followers = context.getPeerAddresses().keySet();
-
- for (String followerId : followers) {
- FollowerLogInformation followerLogInformation =
- new FollowerLogInformationImpl(followerId,
- new AtomicLong(lastIndex()),
- new AtomicLong(-1));
-
- followerToLog.put(followerId, followerLogInformation);
- }
-
- context.getLogger().debug("Election:Leader has following peers:"+ followers);
-
- if (followers.size() > 0) {
- minReplicationCount = (followers.size() + 1) / 2 + 1;
- } else {
- minReplicationCount = 0;
- }
-
-
- // Immediately schedule a heartbeat
- // Upon election: send initial empty AppendEntries RPCs
- // (heartbeat) to each server; repeat during idle periods to
- // prevent election timeouts (§5.2)
- scheduleHeartBeat(new FiniteDuration(0, TimeUnit.SECONDS));
+public class Leader extends AbstractLeader {
+ /**
+ * Internal message sent to periodically check if this leader has become isolated and should transition
+ * to {@link IsolatedLeader}.
+ */
+ @VisibleForTesting
+ static final Object ISOLATED_LEADER_CHECK = new Object();