+ ActorSelection leaderActor = context.getPeerActorSelection(leaderId);
+ if (leaderActor == null) {
+ return false;
+ }
+
+ Address leaderAddress = leaderActor.anchorPath().address();
+
+ CurrentClusterState state = cluster.get().state();
+ Set<Member> unreachable = state.getUnreachable();
+
+ log.debug("{}: Checking for leader {} in the cluster unreachable set {}", logName(), leaderAddress,
+ unreachable);
+
+ for (Member m: unreachable) {
+ if (leaderAddress.equals(m.address())) {
+ log.info("{}: Leader {} is unreachable", logName(), leaderAddress);
+ return false;
+ }
+ }
+
+ for (Member m: state.getMembers()) {
+ if (leaderAddress.equals(m.address())) {
+ if (m.status() == MemberStatus.up() || m.status() == MemberStatus.weaklyUp()) {
+ log.debug("{}: Leader {} cluster status is {} - leader is available", logName(),
+ leaderAddress, m.status());
+ return true;
+ } else {
+ log.debug("{}: Leader {} cluster status is {} - leader is unavailable", logName(),
+ leaderAddress, m.status());
+ return false;
+ }
+ }
+ }
+
+ log.debug("{}: Leader {} not found in the cluster member set", logName(), leaderAddress);
+
+ return false;
+ }
+
+ private boolean isThisFollowerIsolated() {
+ final Optional<Cluster> maybeCluster = context.getCluster();
+ if (!maybeCluster.isPresent()) {
+ return false;
+ }
+
+ final Cluster cluster = maybeCluster.get();
+ final Member selfMember = cluster.selfMember();
+
+ final CurrentClusterState state = cluster.state();
+ final Set<Member> unreachable = state.getUnreachable();
+ final Iterable<Member> members = state.getMembers();
+
+ log.debug("{}: Checking if this node is isolated in the cluster unreachable set {},"
+ + "all members {} self member: {}", logName(), unreachable, members, selfMember);
+
+ // no unreachable peers means we cannot be isolated
+ if (unreachable.isEmpty()) {
+ return false;
+ }
+
+ final Set<Member> membersToCheck = new HashSet<>();
+ members.forEach(membersToCheck::add);
+
+ membersToCheck.removeAll(unreachable);
+
+ // check if the only member not unreachable is us
+ return membersToCheck.size() == 1 && membersToCheck.iterator().next().equals(selfMember);
+ }
+
+ private void handleInstallSnapshot(final ActorRef sender, final InstallSnapshot installSnapshot) {
+
+ log.debug("{}: handleInstallSnapshot: {}", logName(), installSnapshot);
+
+ leaderId = installSnapshot.getLeaderId();
+
+ if (snapshotTracker == null) {
+ snapshotTracker = new SnapshotTracker(log, installSnapshot.getTotalChunks(), installSnapshot.getLeaderId(),
+ context);
+ }
+
+ updateInitialSyncStatus(installSnapshot.getLastIncludedIndex(), installSnapshot.getLeaderId());
+