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} method
    T readBlob​(BlobContainer blobContainer, java.lang.String blobName)
    Reads blob with specified name without resolving the blobName using using blobName(java.lang.String) method.
    void write​(T obj, BlobContainer blobContainer, java.lang.String name, boolean failIfAlreadyExists)
    Writes blob with resolving the blob name using blobName(java.lang.String) method.
    void writeAtomic​(T obj, BlobContainer blobContainer, java.lang.String name)
    Writes blob in atomic manner with resolving the blob name using blobName(java.lang.String) method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 name
      blobNameFormat - format of the blobname in String.format(java.lang.String, java.lang.Object...) format
      reader - prototype object that can deserialize T from XContent
      compress - true if the content should be compressed
  • Method Details

    • read

      public T read​(BlobContainer blobContainer, java.lang.String name) throws java.io.IOException
      Reads and parses the blob with given name, applying name translation using the {link #blobName} method
      Parameters:
      blobContainer - blob container
      name - 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.IOException
      Reads blob with specified name without resolving the blobName using using blobName(java.lang.String) method.
      Parameters:
      blobContainer - blob container
      blobName - blob name
      Throws:
      java.io.IOException
    • writeAtomic

      public void writeAtomic​(T obj, BlobContainer blobContainer, java.lang.String name) throws java.io.IOException
      Writes blob in atomic manner with resolving the blob name using blobName(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 serialized
      blobContainer - blob container
      name - blob name
      Throws:
      java.io.IOException
    • write

      public void write​(T obj, BlobContainer blobContainer, java.lang.String name, boolean failIfAlreadyExists) throws java.io.IOException
      Writes blob with resolving the blob name using blobName(java.lang.String) method.

      The blob will be compressed and checksum will be written if required.

      Parameters:
      obj - object to be serialized
      blobContainer - blob container
      name - blob name
      failIfAlreadyExists - Whether to fail if the blob already exists
      Throws:
      java.io.IOException