Search in sources :

Example 16 with BlobContainer

use of org.elasticsearch.common.blobstore.BlobContainer in project elasticsearch by elastic.

the class BlobStoreFormatIT method testBlobStoreOperations.

public void testBlobStoreOperations() throws IOException {
    BlobStore blobStore = createTestBlobStore();
    BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath());
    ChecksumBlobStoreFormat<BlobObj> checksumJSON = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent, xContentRegistry(), false, XContentType.JSON);
    ChecksumBlobStoreFormat<BlobObj> checksumSMILE = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent, xContentRegistry(), false, XContentType.SMILE);
    ChecksumBlobStoreFormat<BlobObj> checksumSMILECompressed = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent, xContentRegistry(), true, XContentType.SMILE);
    // Write blobs in different formats
    checksumJSON.write(new BlobObj("checksum json"), blobContainer, "check-json");
    checksumSMILE.write(new BlobObj("checksum smile"), blobContainer, "check-smile");
    checksumSMILECompressed.write(new BlobObj("checksum smile compressed"), blobContainer, "check-smile-comp");
    // Assert that all checksum blobs can be read by all formats
    assertEquals(checksumJSON.read(blobContainer, "check-json").getText(), "checksum json");
    assertEquals(checksumSMILE.read(blobContainer, "check-json").getText(), "checksum json");
    assertEquals(checksumJSON.read(blobContainer, "check-smile").getText(), "checksum smile");
    assertEquals(checksumSMILE.read(blobContainer, "check-smile").getText(), "checksum smile");
    assertEquals(checksumJSON.read(blobContainer, "check-smile-comp").getText(), "checksum smile compressed");
    assertEquals(checksumSMILE.read(blobContainer, "check-smile-comp").getText(), "checksum smile compressed");
}
Also used : ChecksumBlobStoreFormat(org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat) BlobContainer(org.elasticsearch.common.blobstore.BlobContainer) FsBlobStore(org.elasticsearch.common.blobstore.fs.FsBlobStore) BlobStore(org.elasticsearch.common.blobstore.BlobStore)

Aggregations

BlobContainer (org.elasticsearch.common.blobstore.BlobContainer)16 BlobStore (org.elasticsearch.common.blobstore.BlobStore)9 BlobPath (org.elasticsearch.common.blobstore.BlobPath)8 IOException (java.io.IOException)5 BytesArray (org.elasticsearch.common.bytes.BytesArray)5 InputStream (java.io.InputStream)4 BlobMetaData (org.elasticsearch.common.blobstore.BlobMetaData)4 FsBlobStore (org.elasticsearch.common.blobstore.fs.FsBlobStore)4 IndexId (org.elasticsearch.repositories.IndexId)4 ChecksumBlobStoreFormat (org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat)4 ElasticsearchParseException (org.elasticsearch.ElasticsearchParseException)3 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)3 RepositoryData (org.elasticsearch.repositories.RepositoryData)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 EOFException (java.io.EOFException)2 NoSuchFileException (java.nio.file.NoSuchFileException)2 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)2 Supplier (org.apache.logging.log4j.util.Supplier)2 ElasticsearchCorruptionException (org.elasticsearch.ElasticsearchCorruptionException)2 MetaData (org.elasticsearch.cluster.metadata.MetaData)2