use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceUtilTest method testGetConfiguredClient.
@Test
public void testGetConfiguredClient() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureBlobClient", client);
BlobServiceComponent component = new BlobServiceComponent(context);
BlobServiceEndpoint endpoint = (BlobServiceEndpoint) component.createEndpoint("azure-blob://camelazure/container/blob?azureBlobClient=#azureBlobClient&publicForRead=true");
assertSame(client, BlobServiceUtil.getConfiguredClient(endpoint.getConfiguration()));
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project jackrabbit-oak by apache.
the class AzureBlobStoreBackend method addMetadataRecordImpl.
private void addMetadataRecordImpl(final InputStream input, String name, long recordLength) throws DataStoreException {
try {
CloudBlobDirectory metaDir = getAzureContainer().getDirectoryReference(META_DIR_NAME);
CloudBlockBlob blob = metaDir.getBlockBlobReference(name);
blob.upload(input, recordLength);
} catch (StorageException e) {
LOG.info("Error adding metadata record. metadataName={} length={}", name, recordLength, e);
throw new DataStoreException(e);
} catch (URISyntaxException | IOException e) {
throw new DataStoreException(e);
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class LocalSASKeyGeneratorImpl method getRelativeBlobSASUri.
/**
* Implementation for generation of Relative Path Blob SAS Uri.
*/
@Override
public URI getRelativeBlobSASUri(String accountName, String container, String relativePath) throws SASKeyGenerationException {
CloudBlobContainer sc = null;
CloudBlobClient client = null;
try {
CloudStorageAccount account = getSASKeyBasedStorageAccountInstance(accountName);
client = account.createCloudBlobClient();
sc = client.getContainerReference(container);
} catch (URISyntaxException uriSyntaxEx) {
throw new SASKeyGenerationException("Encountered URISyntaxException " + "while getting container references for container " + container + " inside storage account : " + accountName, uriSyntaxEx);
} catch (StorageException stoEx) {
throw new SASKeyGenerationException("Encountered StorageException while " + "getting container references for container " + container + " inside storage account : " + accountName, stoEx);
}
CloudBlockBlob blob = null;
try {
blob = sc.getBlockBlobReference(relativePath);
} catch (URISyntaxException uriSyntaxEx) {
throw new SASKeyGenerationException("Encountered URISyntaxException while " + "getting Block Blob references for container " + container + " inside storage account : " + accountName, uriSyntaxEx);
} catch (StorageException stoEx) {
throw new SASKeyGenerationException("Encountered StorageException while " + "getting Block Blob references for container " + container + " inside storage account : " + accountName, stoEx);
}
try {
return client.getCredentials().transformUri(blob.getUri());
} catch (StorageException stoEx) {
throw new SASKeyGenerationException("Encountered StorageException while " + "generating SAS key for Blob: " + relativePath + " inside " + "container : " + container + " in Storage Account : " + accountName, stoEx);
} catch (URISyntaxException uriSyntaxEx) {
throw new SASKeyGenerationException("Encountered URISyntaxException " + "while generating SAS key for Blob: " + relativePath + " inside " + "container: " + container + " in Storage Account : " + accountName, uriSyntaxEx);
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_rename_rootLevelFiles.
// WASB must force explicit parent directories in create, delete, mkdirs, rename.
// scenario for this particular test described at MONARCH-HADOOP-764
@Test
public void outOfBandFolder_rename_rootLevelFiles() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
CloudBlockBlob blob = testAccount.getBlobReference("fileX");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("/fileX");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("/fileXrename");
fs.rename(srcFilePath, destFilePath);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandSingleFile_rename.
// Verify that you can rename a file which is the only file in an implicit folder in the
// WASB file system.
// scenario for this particular test described at MONARCH-HADOOP-892
@Test
public void outOfBandSingleFile_rename() throws Exception {
//NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("testFolder5/a/input/file");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("testFolder5/file2");
fs.rename(srcFilePath, destFilePath);
}
Aggregations