public class SnapshotExecutorImpl extends Object implements SnapshotExecutor
Describer.DefaultPrinter, Describer.Printer| Constructor and Description |
|---|
SnapshotExecutorImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
describe(Describer.Printer out) |
void |
doSnapshot(Closure done)
Start to snapshot StateMachine, and |done| is called after the
execution finishes or fails.
|
void |
doSnapshotSync(Closure done)
Start to snapshot StateMachine immediately with the latest log applied to state machine.
|
long |
getLastSnapshotIndex()
Only for test
|
long |
getLastSnapshotTerm()
Only for test
|
NodeImpl |
getNode()
Return the owner NodeImpl
|
SnapshotStorage |
getSnapshotStorage()
Returns the backing snapshot storage
|
boolean |
init(SnapshotExecutorOptions opts)
Initialize the service.
|
void |
installSnapshot(RpcRequests.InstallSnapshotRequest request,
RpcRequests.InstallSnapshotResponse.Builder response,
RpcRequestClosure done)
Install snapshot according to the very RPC from leader
After the installing succeeds (StateMachine is reset with the snapshot)
or fails, done will be called to respond
Errors:
- Term mismatches: which happens interrupt_downloading_snapshot was
called before install_snapshot, indicating that this RPC was issued by
the old leader.
|
void |
interruptDownloadingSnapshots(long newTerm)
Interrupt the downloading if possible.
|
boolean |
isInstallingSnapshot()
Returns true if this is currently installing a snapshot, either
downloading or loading.
|
void |
join()
Block the current thread until all the running job finishes (including failure)
|
void |
shutdown()
Dispose the resources for service.
|
@OnlyForTest public long getLastSnapshotTerm()
@OnlyForTest public long getLastSnapshotIndex()
public boolean init(SnapshotExecutorOptions opts)
Lifecycleinit in interface Lifecycle<SnapshotExecutorOptions>public void shutdown()
Lifecycleshutdown in interface Lifecycle<SnapshotExecutorOptions>public NodeImpl getNode()
SnapshotExecutorgetNode in interface SnapshotExecutorpublic void doSnapshot(Closure done)
SnapshotExecutordoSnapshot in interface SnapshotExecutordone - snapshot callbackpublic void doSnapshotSync(Closure done)
SnapshotExecutorStateMachine callback methods to trigger a snapshot synchronously, otherwise throws IllegalStateException.
And |done| is called after the execution finishes or fails.doSnapshotSync in interface SnapshotExecutordone - snapshot callbackpublic void installSnapshot(RpcRequests.InstallSnapshotRequest request, RpcRequests.InstallSnapshotResponse.Builder response, RpcRequestClosure done)
SnapshotExecutorinstallSnapshot in interface SnapshotExecutorpublic void interruptDownloadingSnapshots(long newTerm)
SnapshotExecutorinterruptDownloadingSnapshots in interface SnapshotExecutornewTerm - new term numpublic boolean isInstallingSnapshot()
SnapshotExecutorisInstallingSnapshot in interface SnapshotExecutorpublic SnapshotStorage getSnapshotStorage()
SnapshotExecutorgetSnapshotStorage in interface SnapshotExecutorpublic void join()
throws InterruptedException
SnapshotExecutorjoin in interface SnapshotExecutorInterruptedExceptionpublic void describe(Describer.Printer out)
Copyright © 2024. All rights reserved.