private void updateTimeoutInMs() { if (serviceClient != null && timeoutIntervalInMs > 0) { serviceClient.getDefaultRequestOptions().setTimeoutIntervalInMs(timeoutIntervalInMs); } }
private void updateRetryPolicy() { if (serviceClient != null && retryPolicyFactory != null) { serviceClient.getDefaultRequestOptions().setRetryPolicyFactory(retryPolicyFactory); } }
public CloudBlobContainer makeObject() throws URISyntaxException, StorageException { SDFSLogger.getLog().info("pool size is " + this.passiveObjects.size()); CloudBlobClient serviceClient = account.createCloudBlobClient(); serviceClient = account.createCloudBlobClient(); serviceClient.getDefaultRequestOptions().setConcurrentRequestCount( Main.dseIOThreads * 2); serviceClient.getDefaultRequestOptions().setTimeoutIntervalInMs( 10 * 1000); serviceClient.getDefaultRequestOptions().setRetryPolicyFactory( new RetryExponentialRetry(500, 5)); CloudBlobContainer container = serviceClient .getContainerReference(this.bucket); container.createIfNotExists(); return container; }
protected CloudBlobContainer getAzureContainer() throws DataStoreException { CloudBlobContainer container = Utils.getBlobContainer(connectionString, containerName); RequestOptions requestOptions = container.getServiceClient().getDefaultRequestOptions(); if (retryPolicy != null) { requestOptions.setRetryPolicyFactory(retryPolicy); } if (requestTimeout != null) { requestOptions.setTimeoutIntervalInMs(requestTimeout); } return container; }
/** * Uses the concurrent request count from the specified client if <code>null</code>, sets a default value for * everything else, and sets defaults as defined in the parent class. * * @param options * The input options to copy from when applying defaults * @param blobType * BlobType of the current operation * @param client * A {@link CloudBlobClient} object that represents the service client used to set the default timeout * interval and retry policy, if they are <code>null</code>. Additionally, the default value of * {@link #concurrentRequestCount} is <code>1</code>. * @param setStartTime * whether to initialize the startTimeInMs field, or not */ protected static final BlobRequestOptions populateAndApplyDefaults(final BlobRequestOptions options, final BlobType blobType, final CloudBlobClient client, final boolean setStartTime) { BlobRequestOptions modifiedOptions = new BlobRequestOptions(options); BlobRequestOptions.populateRequestOptions(modifiedOptions, client.getDefaultRequestOptions(), setStartTime); BlobRequestOptions.applyDefaults(modifiedOptions, blobType); return modifiedOptions; }
/** * Uses the concurrent request count from the specified client if <code>null</code>, sets a default value for * everything else, and sets defaults as defined in the parent class. * * @param options * The input options to copy from when applying defaults * @param blobType * BlobType of the current operation * @param client * A {@link CloudBlobClient} object that represents the service client used to set the default timeout * interval and retry policy, if they are <code>null</code>. Additionally, if the * {@link #concurrentRequestCount} field's value is null, it will be set to the value specified by the * cloud blob client's {@link CloudBlobClient#getConcurrentRequestCount} method. * @param setStartTime * whether to initialize the startTimeInMs field, or not */ protected static final BlobRequestOptions populateAndApplyDefaults(final BlobRequestOptions options, final BlobType blobType, final CloudBlobClient client, final boolean setStartTime) { BlobRequestOptions modifiedOptions = new BlobRequestOptions(options); BlobRequestOptions.populateRequestOptions(modifiedOptions, client.getDefaultRequestOptions(), setStartTime); BlobRequestOptions.applyDefaults(modifiedOptions, blobType); return modifiedOptions; }
@Override public CloudBlobContainerWrapper getContainerReference(String name) throws URISyntaxException, StorageException { try { CloudBlobContainer container = new CloudBlobContainer(sasKeyGenerator.getContainerSASUri( storageAccount, name)); if (retryPolicy != null) { container.getServiceClient().getDefaultRequestOptions().setRetryPolicyFactory(retryPolicy); } if (timeoutIntervalInMs > 0) { container.getServiceClient().getDefaultRequestOptions().setTimeoutIntervalInMs(timeoutIntervalInMs); } return (useContainerSasKeyForAllAccess) ? new SASCloudBlobContainerWrapperImpl(storageAccount, container, null) : new SASCloudBlobContainerWrapperImpl(storageAccount, container, sasKeyGenerator); } catch (SASKeyGenerationException sasEx) { String errorMsg = "Encountered SASKeyGeneration exception while " + "generating SAS Key for container : " + name + " inside Storage account : " + storageAccount; LOG.error(errorMsg); throw new StorageException(SAS_ERROR_CODE, errorMsg, sasEx); } }
serviceClient.getDefaultRequestOptions().setConcurrentRequestCount(Main.dseIOThreads * 2); if (tier != null && (tier.equals(StandardBlobTier.ARCHIVE) || tier.equals(StandardBlobTier.COOL))) { this.bio = new BlobDataIO(this.name + "table", this.accessKey, this.secretKey, connectionProtocol);
@NotNull public static CloudBlobClient getCloudBlobClient(@NotNull final StorageInputs inputs) throws Exception { final String storageConnectionString = String.format(STORAGE_AUTH_ENDPOINT, inputs.getStorageAccount(), inputs.getKey()); OperationContext.setDefaultProxy(getProxy(inputs.getProxyHost(), inputs.getProxyPort(), inputs.getProxyUsername(), inputs.getProxyPassword())); final CloudBlobClient client = CloudStorageAccount.parse(storageConnectionString).createCloudBlobClient(); if (inputs.getTimeout() != 0) { client.getDefaultRequestOptions().setTimeoutIntervalInMs(inputs.getTimeout()); } return client; } }
@Override public CloudBlobWrapper getBlockBlobReference(String relativePath) throws URISyntaxException, StorageException { try { CloudBlockBlob blob = (sasKeyGenerator!=null) ? new CloudBlockBlob(sasKeyGenerator.getRelativeBlobSASUri(storageAccount, getName(), relativePath)) : container.getBlockBlobReference(relativePath); blob.getServiceClient().setDefaultRequestOptions( container.getServiceClient().getDefaultRequestOptions()); return new SASCloudBlockBlobWrapperImpl(blob); } catch (SASKeyGenerationException sasEx) { String errorMsg = "Encountered SASKeyGeneration exception while " + "generating SAS Key for relativePath : " + relativePath + " inside container : " + getName() + " Storage account : " + storageAccount; LOG.error(errorMsg); throw new StorageException(SAS_ERROR_CODE, errorMsg, sasEx); } }
@Override public CloudBlobWrapper getPageBlobReference(String relativePath) throws URISyntaxException, StorageException { try { CloudPageBlob blob = (sasKeyGenerator!=null) ? new CloudPageBlob(sasKeyGenerator.getRelativeBlobSASUri(storageAccount, getName(), relativePath)) : container.getPageBlobReference(relativePath); blob.getServiceClient().setDefaultRequestOptions( container.getServiceClient().getDefaultRequestOptions()); return new SASCloudPageBlobWrapperImpl(blob); } catch (SASKeyGenerationException sasEx) { String errorMsg = "Encountered SASKeyGeneration exception while " + "generating SAS Key for relativePath : " + relativePath + " inside container : " + getName() + " Storage account : " + storageAccount; LOG.error(errorMsg); throw new StorageException(SAS_ERROR_CODE, errorMsg, sasEx); } } }
@Test public void testNullRetryPolicy() throws URISyntaxException, StorageException { CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); blobClient.getDefaultRequestOptions().setRetryPolicyFactory(null); container.exists(); }
@Test @Category({ CloudTests.class }) public void testGetServiceStats() throws StorageException { CloudBlobClient bClient = BlobTestHelper.createCloudBlobClient(); bClient.getDefaultRequestOptions().setLocationMode(LocationMode.SECONDARY_ONLY); BlobTestHelper.verifyServiceStats(bClient.getServiceStats()); }
bClient.getDefaultRequestOptions().setSingleBlobPutThresholdInBytes( BlobConstants.MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES + 1); fail("Cannot set upload blob threshold above 64 MB"); bClient.getDefaultRequestOptions().setSingleBlobPutThresholdInBytes(Constants.MB - 1); fail("Cannot set upload blob threshold below 1 MB"); bClient.getDefaultRequestOptions().setSingleBlobPutThresholdInBytes(maxSize);
private static void testContainerDownloadAttributes(LocationMode optionsLocationMode, LocationMode clientLocationMode, StorageLocation initialLocation, List<RetryContext> retryContextList, List<RetryInfo> retryInfoList) throws URISyntaxException, StorageException { CloudBlobContainer container = BlobTestHelper.getRandomContainerReference(); MultiLocationTestHelper helper = new MultiLocationTestHelper(container.getServiceClient().getStorageUri(), initialLocation, retryContextList, retryInfoList); container.getServiceClient().getDefaultRequestOptions().setLocationMode(clientLocationMode); BlobRequestOptions options = new BlobRequestOptions(); options.setLocationMode(optionsLocationMode); options.setRetryPolicyFactory(helper.retryPolicy); try { container.downloadAttributes(null, options, helper.operationContext); } catch (StorageException ex) { assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode()); } finally { helper.close(); } }