Search in sources :

Example 1 with CloudBlockBlob

use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.

the class BlobServiceProducer method getBlobBlockList.

private void getBlobBlockList(Exchange exchange) throws Exception {
    CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
    BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
    LOG.trace("Getting the blob block list [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange);
    BlockListingFilter filter = exchange.getIn().getBody(BlockListingFilter.class);
    if (filter == null) {
        filter = BlockListingFilter.COMMITTED;
    }
    List<BlockEntry> blockEntries = client.downloadBlockList(filter, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
    ExchangeUtil.getMessageForResponse(exchange).setBody(blockEntries);
}
Also used : BlockListingFilter(com.microsoft.azure.storage.blob.BlockListingFilter) BlockEntry(com.microsoft.azure.storage.blob.BlockEntry) CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob)

Example 2 with CloudBlockBlob

use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.

the class BlobServiceProducer method uploadBlobBlocks.

private void uploadBlobBlocks(Exchange exchange) throws Exception {
    Object object = exchange.getIn().getMandatoryBody();
    List<BlobBlock> blobBlocks = null;
    if (object instanceof List) {
        blobBlocks = (List<BlobBlock>) blobBlocks;
    } else if (object instanceof BlobBlock) {
        blobBlocks = Collections.singletonList((BlobBlock) object);
    }
    if (blobBlocks == null || blobBlocks.isEmpty()) {
        throw new IllegalArgumentException("Illegal storageBlocks payload");
    }
    CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
    configureCloudBlobForWrite(client);
    BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
    LOG.trace("Putting a blob [{}] from blocks from exchange [{}]...", getConfiguration().getBlobName(), exchange);
    List<BlockEntry> blockEntries = new LinkedList<BlockEntry>();
    for (BlobBlock blobBlock : blobBlocks) {
        blockEntries.add(blobBlock.getBlockEntry());
        client.uploadBlock(blobBlock.getBlockEntry().getId(), blobBlock.getBlockStream(), -1, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
    }
    Boolean commitBlockListLater = exchange.getIn().getHeader(BlobServiceConstants.COMMIT_BLOCK_LIST_LATER, Boolean.class);
    if (Boolean.TRUE != commitBlockListLater) {
        client.commitBlockList(blockEntries, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
    }
}
Also used : BlockEntry(com.microsoft.azure.storage.blob.BlockEntry) LinkedList(java.util.LinkedList) List(java.util.List) CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) LinkedList(java.util.LinkedList)

Example 3 with CloudBlockBlob

use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.

the class BlobServiceUtil method getBlockBlob.

private static void getBlockBlob(Exchange exchange, BlobServiceConfiguration cfg) throws Exception {
    CloudBlockBlob client = createBlockBlobClient(cfg);
    doGetBlob(client, exchange, cfg);
}
Also used : CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob)

Example 4 with CloudBlockBlob

use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.

the class BlobServiceComponentConfigurationTest method testClientWithoutCredentials.

@Test
public void testClientWithoutCredentials() throws Exception {
    CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
    doTestClientWithoutCredentials(client);
}
Also used : CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) Test(org.junit.Test)

Example 5 with CloudBlockBlob

use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.

the class BlobServiceComponentConfigurationTest method testClientWithoutAnonymousCredentials.

@Test
public void testClientWithoutAnonymousCredentials() throws Exception {
    CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), StorageCredentialsAnonymous.ANONYMOUS);
    doTestClientWithoutCredentials(client);
}
Also used : CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) Test(org.junit.Test)

Aggregations

CloudBlockBlob (com.microsoft.azure.storage.blob.CloudBlockBlob)42 Test (org.junit.Test)17 StorageException (com.microsoft.azure.storage.StorageException)11 Path (org.apache.hadoop.fs.Path)11 URISyntaxException (java.net.URISyntaxException)10 BlobOutputStream (com.microsoft.azure.storage.blob.BlobOutputStream)9 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)9 CloudBlobClient (com.microsoft.azure.storage.blob.CloudBlobClient)8 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)6 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)6 FileNotFoundException (java.io.FileNotFoundException)5 BlockEntry (com.microsoft.azure.storage.blob.BlockEntry)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 JndiRegistry (org.apache.camel.impl.JndiRegistry)4 URI (java.net.URI)3 InvalidKeyException (java.security.InvalidKeyException)3 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)2 CloudBlobDirectory (com.microsoft.azure.storage.blob.CloudBlobDirectory)2