Package io.camunda.zeebe.snapshots.impl
Class SfvChecksumImpl
java.lang.Object
io.camunda.zeebe.snapshots.impl.SfvChecksumImpl
- All Implemented Interfaces:
ImmutableChecksumsSFV,MutableChecksumsSFV
Supports building individual CRCs compatible with SFV file format and also supports backward
compatibility with 'combinedChecksum' field.
https://en.wikipedia.org/wiki/Simple_file_verification
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns some combined checksum over all the file checksums.booleanReturns if all file checksums match exactly.voidsetSnapshotDirectoryComment(String headerComment) toString()voidupdateFromBytes(String fileName, byte[] bytes) Update the checksum collection, and add a new checksum from given bytes, likely a read file or soon to be written file.voidupdateFromChecksum(Path filePath, long checksum) Update the checksum map with the given checksumvoidupdateFromFile(Path filePath) Update the checksum collection, and add a new checksum from a given file path.voidupdateFromSfvFile(String... lines) Build the checksum collection from a SFV format string array.voidwrite(OutputStream stream) Write the checksum collection in SFV format to the given output stream.
-
Constructor Details
-
SfvChecksumImpl
public SfvChecksumImpl()
-
-
Method Details
-
write
Description copied from interface:ImmutableChecksumsSFVWrite the checksum collection in SFV format to the given output stream.- Specified by:
writein interfaceImmutableChecksumsSFV- Parameters:
stream- in which the data will be written to- Throws:
IOException
-
getChecksums
- Specified by:
getChecksumsin interfaceImmutableChecksumsSFV- Returns:
- the map containing the individual file checksums
-
sameChecksums
Description copied from interface:ImmutableChecksumsSFVReturns if all file checksums match exactly.- Specified by:
sameChecksumsin interfaceImmutableChecksumsSFV- Parameters:
o- The other checksum- Returns:
- boolean denoting match
-
getCombinedChecksum
public long getCombinedChecksum()Description copied from interface:ImmutableChecksumsSFVReturns some combined checksum over all the file checksums. If any of the individual checksums or file names change, the combined checksum will change as well.- Specified by:
getCombinedChecksumin interfaceImmutableChecksumsSFV
-
toString
-
setSnapshotDirectoryComment
-
updateFromFile
Description copied from interface:MutableChecksumsSFVUpdate the checksum collection, and add a new checksum from a given file path.- Specified by:
updateFromFilein interfaceMutableChecksumsSFV- Parameters:
filePath- the path to a file for which a checksum is created and added to the collection- Throws:
IOException- when reading of given file fails
-
updateFromBytes
Description copied from interface:MutableChecksumsSFVUpdate the checksum collection, and add a new checksum from given bytes, likely a read file or soon to be written file.Useful, if we want to avoid re-reading files etc.
- Specified by:
updateFromBytesin interfaceMutableChecksumsSFV- Parameters:
fileName- the name of the file (which relates to the given bytes), that is used in the checksum collection in SFV file formatbytes- the bytes for which the checksum should be created
-
updateFromSfvFile
Description copied from interface:MutableChecksumsSFVBuild the checksum collection from a SFV format string array.- Specified by:
updateFromSfvFilein interfaceMutableChecksumsSFV- Parameters:
lines- the lines (in SFV) to build up the checksum collection
-
updateFromChecksum
Description copied from interface:MutableChecksumsSFVUpdate the checksum map with the given checksum- Specified by:
updateFromChecksumin interfaceMutableChecksumsSFV- Parameters:
filePath- path to filechecksum- check of file given
-