- All Implemented Interfaces:
- Enclosing class:
Note: This class will ignore the
segments.gen file since it's optional and might
change concurrently for safety reasons.
- See Also:
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Field SummaryModifier and TypeFieldDescription
static final Store.MetadataSnapshot
(Map<String, StoreFileMetadata> metadata, Map<String, String> commitUserData, long numDocs)Read from a stream.
Method SummaryModifier and TypeMethodDescription
booleanReturns true iff this metadata contains the given file.returns the history uuid the store points at, or null if nonexistent.
longReturns the number of documents in this store snapshotReturns the segments file that this metadata snapshot represents or null if the snapshot is empty.Returns the sync id of the commit point that this MetadataSnapshot represents.
(org.apache.lucene.util.BytesRefBuilder fileHash, InputStream in, long size)Computes a strong hash value for small files.
(Store.MetadataSnapshot targetSnapshot)Returns a diff between the two snapshots that can be used for recovery.
size()Returns the number of files in this snapshot
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
EMPTYpublic static final Store.MetadataSnapshot EMPTY
(StreamInput in) throws IOExceptionRead from a stream.
writeTopublic void writeTo
(StreamOutput out) throws IOExceptionDescription copied from interface:
- Specified by:
getNumDocspublic long getNumDocs()Returns the number of documents in this store snapshot
hashFilepublic static void hashFile
(org.apache.lucene.util.BytesRefBuilder fileHash, InputStream in, long size) throws IOExceptionComputes a strong hash value for small files. Note that this method should only be used for files < 1MB
iteratorpublic Iterator<StoreFileMetadata> iterator()
- Specified by:
getpublic StoreFileMetadata get
recoveryDiffpublic Store.RecoveryDiff recoveryDiff
(Store.MetadataSnapshot targetSnapshot)Returns a diff between the two snapshots that can be used for recovery. The given snapshot is treated as the recovery target and this snapshot as the source. The returned diff will hold a list of files that are:
- identical: they exist in both snapshots and they can be considered the same ie. they don't need to be recovered
- different: they exist in both snapshots but their they are not identical
- missing: files that exist in the source but not in the target
Individual files are compared by name, length, checksum and (if present) a UUID that was assigned when the file was originally written. The segment info (
*.si) files and the segments file (
segments_N) are also checked to be a byte-for-byte match.
Files are collected together into a group for each segment plus one group of "per-commit" (
segments_N) files. Each per-segment group is subdivided into a nongenerational group (most of them) and a generational group (e.g.
*.dvdthat have been updated by subsequent commits).
For each segment, if any nongenerational files are different then the whole segment is considered to be different and will be recovered in full. If all the nongenerational files are the same but any generational files are different then all the generational files are considered to be different and will be recovered in full, but the nongenerational files are left alone. Finally, if any file is different then all the per-commit files are recovered too.
sizepublic int size()Returns the number of files in this snapshot
getHistoryUUIDpublic String getHistoryUUID()returns the history uuid the store points at, or null if nonexistent.
containspublic boolean contains
(String existingFile)Returns true iff this metadata contains the given file.
getSegmentsFilepublic StoreFileMetadata getSegmentsFile()Returns the segments file that this metadata snapshot represents or null if the snapshot is empty.
getSyncIdpublic String getSyncId()Returns the sync id of the commit point that this MetadataSnapshot represents.
- sync id if exists, else null