Search in sources :

Example 21 with SnapshotInfo

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;
}
Also used : DownloadSnapshotPRequest(alluxio.grpc.DownloadSnapshotPRequest) SnapshotInfo(org.apache.ratis.statemachine.SnapshotInfo) SingleFileSnapshotInfo(org.apache.ratis.statemachine.impl.SingleFileSnapshotInfo) DownloadSnapshotPResponse(alluxio.grpc.DownloadSnapshotPResponse)

Aggregations

SnapshotInfo (org.apache.ratis.statemachine.SnapshotInfo)21 SingleFileSnapshotInfo (org.apache.ratis.statemachine.impl.SingleFileSnapshotInfo)7 TermIndex (org.apache.ratis.server.protocol.TermIndex)6 File (java.io.File)5 RaftClient (org.apache.ratis.client.RaftClient)3 RaftClientReply (org.apache.ratis.protocol.RaftClientReply)3 RaftPeerId (org.apache.ratis.protocol.RaftPeerId)3 RaftServer (org.apache.ratis.server.RaftServer)3 MiniRaftCluster (org.apache.ratis.server.impl.MiniRaftCluster)3 NotFoundException (alluxio.exception.status.NotFoundException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 AbortedException (alluxio.exception.status.AbortedException)1 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)1 DownloadSnapshotPRequest (alluxio.grpc.DownloadSnapshotPRequest)1 DownloadSnapshotPResponse (alluxio.grpc.DownloadSnapshotPResponse)1 JournalQueryResponse (alluxio.grpc.JournalQueryResponse)1 UploadSnapshotPRequest (alluxio.grpc.UploadSnapshotPRequest)1 UploadSnapshotPResponse (alluxio.grpc.UploadSnapshotPResponse)1 Timer (com.codahale.metrics.Timer)1