public class SnapshotReplicationManager extends Object
Constructor and Description |
---|
SnapshotReplicationManager(RaftJournalSystem journalSystem,
org.apache.ratis.statemachine.impl.SimpleStateMachineStorage storage) |
Modifier and Type | Method and Description |
---|---|
org.apache.ratis.protocol.Message |
handleRequest(JournalQueryRequest queryRequest)
Handles snapshot requests.
|
CompletableFuture<org.apache.ratis.server.protocol.TermIndex> |
installSnapshotFromLeader()
Downloads and installs a snapshot from the leader.
|
long |
maybeCopySnapshotFromFollower()
Attempts to copy a snapshot from one of the followers.
|
io.grpc.stub.StreamObserver<UploadSnapshotPRequest> |
receiveSnapshotFromFollower(io.grpc.stub.StreamObserver<UploadSnapshotPResponse> responseStreamObserver)
Receives a snapshot from follower.
|
io.grpc.stub.StreamObserver<DownloadSnapshotPRequest> |
sendSnapshotToFollower(io.grpc.stub.StreamObserver<DownloadSnapshotPResponse> responseObserver)
Sends a snapshot to a follower.
|
void |
sendSnapshotToLeader()
Sends a snapshot to the leader.
|
public SnapshotReplicationManager(RaftJournalSystem journalSystem, org.apache.ratis.statemachine.impl.SimpleStateMachineStorage storage)
journalSystem
- the raft journal systemstorage
- the snapshot storagepublic CompletableFuture<org.apache.ratis.server.protocol.TermIndex> installSnapshotFromLeader()
public void sendSnapshotToLeader() throws IOException
IOException
- if error occurs while initializing the data streampublic long maybeCopySnapshotFromFollower()
RaftLog.INVALID_LOG_INDEX
.
- If a download is in progress, it returns RaftLog.INVALID_LOG_INDEX
immediately.
- If a download is completed, it moves the downloaded file to the snapshot directory and
returns the snapshot index.RaftLog.INVALID_LOG_INDEX
if no snapshot is installed.public io.grpc.stub.StreamObserver<UploadSnapshotPRequest> receiveSnapshotFromFollower(io.grpc.stub.StreamObserver<UploadSnapshotPResponse> responseStreamObserver)
responseStreamObserver
- the response stream observerpublic org.apache.ratis.protocol.Message handleRequest(JournalQueryRequest queryRequest) throws IOException
queryRequest
- the query requestIOException
- if any error occurred while handling the requestpublic io.grpc.stub.StreamObserver<DownloadSnapshotPRequest> sendSnapshotToFollower(io.grpc.stub.StreamObserver<DownloadSnapshotPResponse> responseObserver)
responseObserver
- the response stream observerCopyright © 2023. All Rights Reserved.