use of org.apache.ratis.statemachine.SnapshotInfo in project alluxio by Alluxio.
the class SnapshotReplicationManager method sendSnapshotToFollower.
/**
* Sends a snapshot to a follower.
*
* @param responseObserver the response stream observer
* @return the request stream observer
*/
public StreamObserver<DownloadSnapshotPRequest> sendSnapshotToFollower(StreamObserver<DownloadSnapshotPResponse> responseObserver) {
SnapshotInfo snapshot = mStorage.getLatestSnapshot();
LOG.debug("Received snapshot download request from {}", ClientIpAddressInjector.getIpAddress());
SnapshotUploader<DownloadSnapshotPResponse, DownloadSnapshotPRequest> requestStreamObserver = SnapshotUploader.forLeader(mStorage, snapshot, responseObserver);
if (snapshot == null) {
responseObserver.onError(Status.NOT_FOUND.withDescription("Cannot find a valid snapshot to download.").asException());
return requestStreamObserver;
}
responseObserver.onNext(DownloadSnapshotPResponse.newBuilder().setData(SnapshotData.newBuilder().setSnapshotTerm(snapshot.getTerm()).setSnapshotIndex(snapshot.getIndex()).setOffset(0)).build());
return requestStreamObserver;
}
Aggregations