Search in sources :

Example 6 with BlobRequestOptions

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

the class BlobServiceUtil method getRequestOptions.

public static BlobServiceRequestOptions getRequestOptions(Exchange exchange) {
    BlobServiceRequestOptions opts = exchange.getIn().getHeader(BlobServiceConstants.BLOB_SERVICE_REQUEST_OPTIONS, BlobServiceRequestOptions.class);
    if (opts != null) {
        return opts;
    } else {
        opts = new BlobServiceRequestOptions();
    }
    AccessCondition accessCond = exchange.getIn().getHeader(BlobServiceConstants.ACCESS_CONDITION, AccessCondition.class);
    BlobRequestOptions requestOpts = exchange.getIn().getHeader(BlobServiceConstants.BLOB_REQUEST_OPTIONS, BlobRequestOptions.class);
    OperationContext opContext = exchange.getIn().getHeader(BlobServiceConstants.OPERATION_CONTEXT, OperationContext.class);
    opts.setAccessCond(accessCond);
    opts.setOpContext(opContext);
    opts.setRequestOpts(requestOpts);
    return opts;
}
Also used : OperationContext(com.microsoft.azure.storage.OperationContext) BlobRequestOptions(com.microsoft.azure.storage.blob.BlobRequestOptions) AccessCondition(com.microsoft.azure.storage.AccessCondition)

Example 7 with BlobRequestOptions

use of com.microsoft.azure.storage.blob.BlobRequestOptions in project hadoop by apache.

the class BlockBlobAppendStream method commitAppendBlocks.

/**
   * Method to commit all the uncommited blocks to azure storage.
   * If the commit fails then blocks are automatically cleaned up
   * by Azure storage.
   * @throws IOException
   */
private synchronized void commitAppendBlocks() throws IOException {
    SelfRenewingLease lease = null;
    try {
        if (uncommittedBlockEntries.size() > 0) {
            //Acquiring lease on the blob.
            lease = new SelfRenewingLease(blob);
            // Downloading existing blocks
            List<BlockEntry> blockEntries = blob.downloadBlockList(BlockListingFilter.COMMITTED, new BlobRequestOptions(), opContext);
            // Adding uncommitted blocks.
            blockEntries.addAll(uncommittedBlockEntries);
            AccessCondition accessCondition = new AccessCondition();
            accessCondition.setLeaseID(lease.getLeaseID());
            blob.commitBlockList(blockEntries, accessCondition, new BlobRequestOptions(), opContext);
            uncommittedBlockEntries.clear();
        }
    } catch (StorageException ex) {
        LOG.error("Storage exception encountered during block commit phase of append for blob" + " : {} Storage Exception : {} Error Code: {}", key, ex, ex.getErrorCode());
        throw new IOException("Encountered Exception while committing append blocks", ex);
    } finally {
        if (lease != null) {
            try {
                lease.free();
            } catch (StorageException ex) {
                LOG.debug("Exception encountered while releasing lease for " + "blob : {} StorageException : {} ErrorCode : {}", key, ex, ex.getErrorCode());
            // Swallowing exception here as the lease is cleaned up by the SelfRenewingLease object.
            }
        }
    }
}
Also used : BlobRequestOptions(com.microsoft.azure.storage.blob.BlobRequestOptions) BlockEntry(com.microsoft.azure.storage.blob.BlockEntry) AccessCondition(com.microsoft.azure.storage.AccessCondition) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException)

Example 8 with BlobRequestOptions

use of com.microsoft.azure.storage.blob.BlobRequestOptions in project hadoop by apache.

the class AzureNativeFileSystemStore method getUploadOptions.

private BlobRequestOptions getUploadOptions() {
    BlobRequestOptions options = new BlobRequestOptions();
    options.setStoreBlobContentMD5(sessionConfiguration.getBoolean(KEY_STORE_BLOB_MD5, false));
    options.setUseTransactionalContentMD5(getUseTransactionalContentMD5());
    options.setConcurrentRequestCount(concurrentWrites);
    options.setRetryPolicyFactory(new RetryExponentialRetry(minBackoff, deltaBackoff, maxBackoff, maxRetries));
    return options;
}
Also used : BlobRequestOptions(com.microsoft.azure.storage.blob.BlobRequestOptions) RetryExponentialRetry(com.microsoft.azure.storage.RetryExponentialRetry)

Example 9 with BlobRequestOptions

use of com.microsoft.azure.storage.blob.BlobRequestOptions in project hadoop by apache.

the class PageBlobFormatHelpers method withMD5Checking.

public static BlobRequestOptions withMD5Checking() {
    BlobRequestOptions options = new BlobRequestOptions();
    options.setUseTransactionalContentMD5(true);
    return options;
}
Also used : BlobRequestOptions(com.microsoft.azure.storage.blob.BlobRequestOptions)

Aggregations

BlobRequestOptions (com.microsoft.azure.storage.blob.BlobRequestOptions)9 StorageException (com.microsoft.azure.storage.StorageException)4 IOException (java.io.IOException)4 RetryExponentialRetry (com.microsoft.azure.storage.RetryExponentialRetry)3 AccessCondition (com.microsoft.azure.storage.AccessCondition)2 BlockEntry (com.microsoft.azure.storage.blob.BlockEntry)2 BufferedInputStream (java.io.BufferedInputStream)2 InputStream (java.io.InputStream)2 URISyntaxException (java.net.URISyntaxException)2 OperationContext (com.microsoft.azure.storage.OperationContext)1 CloudBlockBlob (com.microsoft.azure.storage.blob.CloudBlockBlob)1 PageRange (com.microsoft.azure.storage.blob.PageRange)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 FileInputStream (java.io.FileInputStream)1 OutputStream (java.io.OutputStream)1 CloudBlobWrapper (org.apache.hadoop.fs.azure.StorageInterface.CloudBlobWrapper)1 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)1