Class Store.MetadataSnapshot
- All Implemented Interfaces:
Iterable<StoreFileMetadata>
,Writeable
- Enclosing class:
- Store
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
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMetadataSnapshot
(Map<String, StoreFileMetadata> metadata, Map<String, String> commitUserData, long numDocs) Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionasMap()
boolean
Returns true iff this metadata contains the given file.returns the history uuid the store points at, or null if nonexistent.long
Returns 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.static void
hashFile
(org.apache.lucene.util.BytesRefBuilder fileHash, InputStream in, long size) Computes a strong hash value for small files.iterator()
recoveryDiff
(Store.MetadataSnapshot targetSnapshot) Returns a diff between the two snapshots that can be used for recovery.int
size()
Returns the number of files in this snapshotvoid
writeTo
(StreamOutput out) Write this into the StreamOutput.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
forEach, spliterator
-
Field Details
-
EMPTY
-
-
Constructor Details
-
MetadataSnapshot
-
MetadataSnapshot
Read from a stream.- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
getNumDocs
public long getNumDocs()Returns the number of documents in this store snapshot -
getCommitVersion
-
hashFile
public static void hashFile(org.apache.lucene.util.BytesRefBuilder fileHash, InputStream in, long size) throws IOException Computes a strong hash value for small files. Note that this method should only be used for files < 1MB- Throws:
IOException
-
iterator
- Specified by:
iterator
in interfaceIterable<StoreFileMetadata>
-
get
-
asMap
-
recoveryDiff
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.*.liv
,*.fnm
,*.dvm
,*.dvd
that 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.
-
size
public int size()Returns the number of files in this snapshot -
getCommitUserData
-
getHistoryUUID
returns the history uuid the store points at, or null if nonexistent. -
contains
Returns true iff this metadata contains the given file. -
getSegmentsFile
Returns the segments file that this metadata snapshot represents or null if the snapshot is empty. -
getSyncId
Returns the sync id of the commit point that this MetadataSnapshot represents.- Returns:
- sync id if exists, else null
-