+
+ private void onGetSnapshot(ActorRef sender) {
+ log.debug("{}: onGetSnapshot", context.getId());
+
+ if(context.getPersistenceProvider().isRecoveryApplicable()) {
+ CaptureSnapshot captureSnapshot = context.getSnapshotManager().newCaptureSnapshot(
+ context.getReplicatedLog().last(), -1, false);
+
+ ActorRef snapshotReplyActor = context.actorOf(GetSnapshotReplyActor.props(captureSnapshot,
+ ImmutableElectionTerm.copyOf(context.getTermInformation()), sender,
+ snapshotReplyActorTimeout, context.getId(), context.getPeerServerInfo()));
+
+ cohort.createSnapshot(snapshotReplyActor);
+ } else {
+ Snapshot snapshot = Snapshot.create(new byte[0], Collections.<ReplicatedLogEntry>emptyList(), -1, -1, -1, -1,
+ context.getTermInformation().getCurrentTerm(), context.getTermInformation().getVotedFor(),
+ context.getPeerServerInfo());
+
+ sender.tell(new GetSnapshotReply(context.getId(), SerializationUtils.serialize(snapshot)),
+ context.getActor());
+ }
+ }
+
+ @VisibleForTesting
+ void setSnapshotReplyActorTimeout(Duration snapshotReplyActorTimeout) {
+ this.snapshotReplyActorTimeout = snapshotReplyActorTimeout;
+ }