public class LocalSnapshotWriter extends SnapshotWriter
JRAFT_SNAPSHOT_META_FILE, JRAFT_SNAPSHOT_PREFIX, REMOTE_SNAPSHOT_URI_SCHEME| Constructor and Description |
|---|
LocalSnapshotWriter(String path,
LocalSnapshotStorage snapshotStorage,
RaftOptions raftOptions) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addFile(String fileName,
com.google.protobuf.Message fileMeta)
Adds a snapshot file with metadata.
|
void |
close() |
void |
close(boolean keepDataOnError)
Close the writer.
|
com.google.protobuf.Message |
getFileMeta(String fileName)
Get file meta by fileName.
|
String |
getPath()
Get the path of the Snapshot
|
long |
getSnapshotIndex() |
boolean |
init(Void v)
Initialize the service.
|
Set<String> |
listFiles()
List all the existing files in the Snapshot currently
|
boolean |
removeFile(String fileName)
Remove a snapshot file.
|
boolean |
saveMeta(RaftOutter.SnapshotMeta meta)
Save a snapshot metadata.
|
void |
shutdown()
Dispose the resources for service.
|
boolean |
sync() |
addFile, getCurrentMetacopy, equals, getCode, getErrorMsg, getRaftError, hashCode, isOk, OK, reset, setCode, setError, setError, setErrorMsg, toStringpublic LocalSnapshotWriter(String path, LocalSnapshotStorage snapshotStorage, RaftOptions raftOptions)
public boolean init(Void v)
Lifecyclepublic long getSnapshotIndex()
public void shutdown()
Lifecyclepublic void close()
throws IOException
IOExceptionpublic void close(boolean keepDataOnError)
throws IOException
SnapshotWriterclose in class SnapshotWriterkeepDataOnError - whether to keep data when error happens.IOException - if occurred an IO errorpublic boolean saveMeta(RaftOutter.SnapshotMeta meta)
SnapshotWritersaveMeta in class SnapshotWritermeta - snapshot metadatapublic boolean sync()
throws IOException
IOExceptionpublic boolean addFile(String fileName, com.google.protobuf.Message fileMeta)
SnapshotWriteraddFile in class SnapshotWriterfileName - file namefileMeta - file metadatapublic boolean removeFile(String fileName)
SnapshotWriterremoveFile in class SnapshotWriterfileName - file namepublic String getPath()
Snapshotpublic Set<String> listFiles()
Snapshotpublic com.google.protobuf.Message getFileMeta(String fileName)
SnapshotgetFileMeta in class SnapshotCopyright © 2024. All rights reserved.