Class ChecksumBlobStoreFormat<T extends ToXContent>
java.lang.Object
org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat<T>
public final class ChecksumBlobStoreFormat<T extends ToXContent>
extends java.lang.Object
Snapshot metadata file format used in v2.0 and above
-
Field Summary
Fields Modifier and Type Field Description static int
VERSION
-
Constructor Summary
Constructors Constructor Description ChecksumBlobStoreFormat(java.lang.String codec, java.lang.String blobNameFormat, CheckedFunction<XContentParser,T,java.io.IOException> reader, NamedXContentRegistry namedXContentRegistry, boolean compress)
-
Method Summary
Modifier and Type Method Description java.lang.String
blobName(java.lang.String name)
T
read(BlobContainer blobContainer, java.lang.String name)
Reads and parses the blob with given name, applying name translation using the {link #blobName} methodT
readBlob(BlobContainer blobContainer, java.lang.String blobName)
Reads blob with specified name without resolving the blobName using usingblobName(java.lang.String)
method.void
write(T obj, BlobContainer blobContainer, java.lang.String name, boolean failIfAlreadyExists)
Writes blob with resolving the blob name usingblobName(java.lang.String)
method.void
writeAtomic(T obj, BlobContainer blobContainer, java.lang.String name)
Writes blob in atomic manner with resolving the blob name usingblobName(java.lang.String)
method.
-
Field Details
-
VERSION
public static final int VERSION- See Also:
- Constant Field Values
-
-
Constructor Details
-
ChecksumBlobStoreFormat
public ChecksumBlobStoreFormat(java.lang.String codec, java.lang.String blobNameFormat, CheckedFunction<XContentParser,T,java.io.IOException> reader, NamedXContentRegistry namedXContentRegistry, boolean compress)- Parameters:
codec
- codec nameblobNameFormat
- format of the blobname inString.format(java.lang.String, java.lang.Object...)
formatreader
- prototype object that can deserialize T from XContentcompress
- true if the content should be compressed
-
-
Method Details
-
read
Reads and parses the blob with given name, applying name translation using the {link #blobName} method- Parameters:
blobContainer
- blob containername
- name to be translated into- Returns:
- parsed blob object
- Throws:
java.io.IOException
-
blobName
public java.lang.String blobName(java.lang.String name) -
readBlob
public T readBlob(BlobContainer blobContainer, java.lang.String blobName) throws java.io.IOExceptionReads blob with specified name without resolving the blobName using usingblobName(java.lang.String)
method.- Parameters:
blobContainer
- blob containerblobName
- blob name- Throws:
java.io.IOException
-
writeAtomic
public void writeAtomic(T obj, BlobContainer blobContainer, java.lang.String name) throws java.io.IOExceptionWrites blob in atomic manner with resolving the blob name usingblobName(java.lang.String)
method.The blob will be compressed and checksum will be written if required. Atomic move might be very inefficient on some repositories. It also cannot override existing files.
- Parameters:
obj
- object to be serializedblobContainer
- blob containername
- blob name- Throws:
java.io.IOException
-
write
public void write(T obj, BlobContainer blobContainer, java.lang.String name, boolean failIfAlreadyExists) throws java.io.IOExceptionWrites blob with resolving the blob name usingblobName(java.lang.String)
method.The blob will be compressed and checksum will be written if required.
- Parameters:
obj
- object to be serializedblobContainer
- blob containername
- blob namefailIfAlreadyExists
- Whether to fail if the blob already exists- Throws:
java.io.IOException
-