use of com.microsoft.azure.storage.blob.CloudPageBlob in project camel by apache.
the class BlobServiceProducer method deletePageBlob.
private void deletePageBlob(Exchange exchange) throws Exception {
CloudPageBlob client = BlobServiceUtil.createPageBlobClient(getConfiguration());
doDeleteBlock(client, exchange);
}
use of com.microsoft.azure.storage.blob.CloudPageBlob in project camel by apache.
the class BlobServiceProducer method getPageBlobRanges.
private void getPageBlobRanges(Exchange exchange) throws Exception {
CloudPageBlob client = BlobServiceUtil.createPageBlobClient(getConfiguration());
BlobServiceUtil.configureCloudBlobForRead(client, getConfiguration());
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
LOG.trace("Getting the page blob ranges [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange);
List<PageRange> ranges = client.downloadPageRanges(opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
ExchangeUtil.getMessageForResponse(exchange).setBody(ranges);
}
use of com.microsoft.azure.storage.blob.CloudPageBlob in project camel by apache.
the class BlobServiceProducer method createPageBlob.
private void createPageBlob(Exchange exchange) throws Exception {
CloudPageBlob client = BlobServiceUtil.createPageBlobClient(getConfiguration());
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
if (opts.getAccessCond() == null) {
// Default: do not reset the blob content if the blob already exists
opts.setAccessCond(AccessCondition.generateIfNotExistsCondition());
}
doCreatePageBlob(client, opts, exchange);
}
use of com.microsoft.azure.storage.blob.CloudPageBlob in project camel by apache.
the class BlobServiceUtil method createPageBlobClient.
public static CloudPageBlob createPageBlobClient(BlobServiceConfiguration cfg) throws Exception {
CloudPageBlob client = (CloudPageBlob) getConfiguredClient(cfg);
if (client == null) {
URI uri = prepareStorageBlobUri(cfg);
StorageCredentials creds = getAccountCredentials(cfg);
client = new CloudPageBlob(uri, creds);
}
return client;
}
use of com.microsoft.azure.storage.blob.CloudPageBlob in project hadoop by apache.
the class PageBlobOutputStream method conditionalExtendFile.
/**
* Extend the page blob file if we are close to the end.
*/
private void conditionalExtendFile() {
// maximum allowed size of an Azure page blob (1 terabyte)
final long MAX_PAGE_BLOB_SIZE = 1024L * 1024L * 1024L * 1024L;
// If blob is already at the maximum size, then don't try to extend it.
if (currentBlobSize == MAX_PAGE_BLOB_SIZE) {
return;
}
// If we are within the maximum write size of the end of the file,
if (currentBlobSize - currentBlobOffset <= MAX_RAW_BYTES_PER_REQUEST) {
// Extend the file. Retry up to 3 times with back-off.
CloudPageBlob cloudPageBlob = (CloudPageBlob) blob.getBlob();
long newSize = currentBlobSize + configuredPageBlobExtensionSize;
// Make sure we don't exceed maximum blob size.
if (newSize > MAX_PAGE_BLOB_SIZE) {
newSize = MAX_PAGE_BLOB_SIZE;
}
final int MAX_RETRIES = 3;
int retries = 1;
boolean resizeDone = false;
while (!resizeDone && retries <= MAX_RETRIES) {
try {
cloudPageBlob.resize(newSize);
resizeDone = true;
currentBlobSize = newSize;
} catch (StorageException e) {
LOG.warn("Failed to extend size of " + cloudPageBlob.getUri());
try {
// sleep 2, 8, 18 seconds for up to 3 retries
Thread.sleep(2000 * retries * retries);
} catch (InterruptedException e1) {
// Restore the interrupted status
Thread.currentThread().interrupt();
}
} finally {
retries++;
}
}
}
}
Aggregations