Class SnapStream
java.lang.Object
org.apache.zookeeper.server.persistence.SnapStream
Represent the Stream used in serialize and deserialize the Snapshot.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidVerify the integrity of the seal, only CheckedInputStream will verify the checkSum of the content.static CheckedInputStreamgetInputStream(File file) Return the CheckedInputStream based on the extension of the fileName.static CheckedOutputStreamgetOutputStream(File file, boolean fsync) Return the OutputStream based on predefined stream mode.static SnapStream.StreamModestatic SnapStream.StreamModegetStreamMode(String fileName) Detect the stream mode from file name extensionstatic booleanisValidSnapshot(File file) Verifies that the file is a valid snapshot.static voidWrite specific seal to the OutputArchive and close the OutputStream.static void
-
Field Details
-
ZOOKEEPER_SHAPSHOT_STREAM_MODE
- See Also:
-
-
Constructor Details
-
SnapStream
public SnapStream()
-
-
Method Details
-
getInputStream
Return the CheckedInputStream based on the extension of the fileName.- Parameters:
file- the file the InputStream read from- Returns:
- the specific InputStream
- Throws:
IOException
-
getOutputStream
Return the OutputStream based on predefined stream mode.- Parameters:
file- the file the OutputStream writes tofsync- sync the file immediately after write- Returns:
- the specific OutputStream
- Throws:
IOException
-
sealStream
Write specific seal to the OutputArchive and close the OutputStream. Currently, only CheckedOutputStream will write it's checkSum to the end of the stream.- Throws:
IOException
-
checkSealIntegrity
Verify the integrity of the seal, only CheckedInputStream will verify the checkSum of the content.- Throws:
IOException
-
isValidSnapshot
Verifies that the file is a valid snapshot. Snapshot may be invalid if it's incomplete as in a situation when the server dies while in the process of storing a snapshot. Any files that are improperly formated or corrupted are invalid. Any file that is not a snapshot is also an invalid snapshot.- Parameters:
file- file to verify- Returns:
- true if the snapshot is valid
- Throws:
IOException
-
setStreamMode
-
getStreamMode
-
getStreamMode
Detect the stream mode from file name extension- Parameters:
fileName-- Returns:
- the stream mode detected
-