+ // 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());
+
+ try {
+ final InstallSnapshotReply reply = new InstallSnapshotReply(
+ currentTerm(), context.getId(), installSnapshot.getChunkIndex(), true);
+
+ if (snapshotTracker.addChunk(installSnapshot.getChunkIndex(), installSnapshot.getData(),
+ installSnapshot.getLastChunkHashCode())) {
+
+ log.info("{}: Snapshot installed from leader: {}", logName(), installSnapshot.getLeaderId());
+
+ Snapshot snapshot = Snapshot.create(
+ context.getSnapshotManager().convertSnapshot(snapshotTracker.getSnapshotBytes()),
+ List.of(),
+ installSnapshot.getLastIncludedIndex(),
+ installSnapshot.getLastIncludedTerm(),
+ installSnapshot.getLastIncludedIndex(),
+ installSnapshot.getLastIncludedTerm(),
+ context.getTermInformation().getCurrentTerm(),
+ context.getTermInformation().getVotedFor(),
+ installSnapshot.getServerConfig().orElse(null));
+
+ ApplySnapshot.Callback applySnapshotCallback = new ApplySnapshot.Callback() {
+ @Override
+ public void onSuccess() {
+ log.debug("{}: handleInstallSnapshot returning: {}", logName(), reply);
+
+ sender.tell(reply, actor());
+ }
+
+ @Override
+ public void onFailure() {
+ sender.tell(new InstallSnapshotReply(currentTerm(), context.getId(), -1, false), actor());
+ }
+ };
+
+ actor().tell(new ApplySnapshot(snapshot, applySnapshotCallback), actor());
+
+ closeSnapshotTracker();