use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.
the class AzureStorageServiceTests method testGetSelectedClientDefaultTimeout.
public void testGetSelectedClientDefaultTimeout() {
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(settings);
CloudBlobClient client1 = azureStorageService.getSelectedClient("azure1", LocationMode.PRIMARY_ONLY);
assertThat(client1.getDefaultRequestOptions().getTimeoutIntervalInMs(), nullValue());
CloudBlobClient client3 = azureStorageService.getSelectedClient("azure3", LocationMode.PRIMARY_ONLY);
assertThat(client3.getDefaultRequestOptions().getTimeoutIntervalInMs(), is(30 * 1000));
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.
the class AzureStorageServiceTests method testGetDefaultClientWithNoSecondary.
public void testGetDefaultClientWithNoSecondary() {
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(Settings.builder().put("cloud.azure.storage.azure1.account", "myaccount1").put("cloud.azure.storage.azure1.key", "mykey1").build());
CloudBlobClient client = azureStorageService.getSelectedClient(null, LocationMode.PRIMARY_ONLY);
assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.
the class AzureStorageServiceImpl method createContainer.
@Override
public void createContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException {
try {
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blobContainer = client.getContainerReference(container);
logger.trace("creating container [{}]", container);
SocketAccess.doPrivilegedException(blobContainer::createIfNotExists);
} catch (IllegalArgumentException e) {
logger.trace((Supplier<?>) () -> new ParameterizedMessage("fails creating container [{}]", container), e);
throw new RepositoryException(container, e.getMessage(), e);
}
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.
the class AzureStorageServiceImpl method getInputStream.
@Override
public InputStream getInputStream(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException {
logger.trace("reading container [{}], blob [{}]", container, blob);
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlockBlob blockBlobReference = client.getContainerReference(container).getBlockBlobReference(blob);
return SocketAccess.doPrivilegedException(blockBlobReference::openInputStream);
}
use of com.microsoft.azure.storage.blob.CloudBlobClient in project elasticsearch by elastic.
the class AzureStorageServiceImpl method removeContainer.
@Override
public void removeContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException {
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blobContainer = client.getContainerReference(container);
logger.trace("removing container [{}]", container);
SocketAccess.doPrivilegedException(blobContainer::deleteIfExists);
}
Aggregations