Java Code Examples for com.microsoft.azure.storage.blob.BlobRequestOptions#setRetryPolicyFactory()
The following examples show how to use
com.microsoft.azure.storage.blob.BlobRequestOptions#setRetryPolicyFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericTests.java From azure-storage-android with Apache License 2.0 | 6 votes |
@Test public void testDefaultProxy() throws URISyntaxException, StorageException { CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); // Use a default proxy OperationContext.setDefaultProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.1.1.1", 8888))); // Turn off retries to make the failure happen faster BlobRequestOptions opt = new BlobRequestOptions(); opt.setRetryPolicyFactory(new RetryNoRetry()); // Unfortunately HttpURLConnection doesn't expose a getter and the usingProxy method it does have doesn't // work as one would expect and will always for us return false. So, we validate by making sure the request // fails when we set a bad proxy rather than check the proxy setting itself succeeding. try { container.exists(null, opt, null); fail("Bad proxy should throw an exception."); } catch (StorageException e) { if (e.getCause().getClass() != ConnectException.class && e.getCause().getClass() != SocketTimeoutException.class && e.getCause().getClass() != SocketException.class) { Assert.fail("Unepected exception for bad proxy"); } } }
Example 2
Source File: SecondaryTests.java From azure-storage-android with Apache License 2.0 | 6 votes |
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(); } }
Example 3
Source File: AzureNativeFileSystemStore.java From hadoop with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: AzureNativeFileSystemStore.java From hadoop with Apache License 2.0 | 5 votes |
private BlobRequestOptions getDownloadOptions() { BlobRequestOptions options = new BlobRequestOptions(); options.setRetryPolicyFactory( new RetryExponentialRetry(minBackoff, deltaBackoff, maxBackoff, maxRetries)); options.setUseTransactionalContentMD5(getUseTransactionalContentMD5()); return options; }
Example 5
Source File: AzureNativeFileSystemStore.java From big-c with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: AzureNativeFileSystemStore.java From big-c with Apache License 2.0 | 5 votes |
private BlobRequestOptions getDownloadOptions() { BlobRequestOptions options = new BlobRequestOptions(); options.setRetryPolicyFactory( new RetryExponentialRetry(minBackoff, deltaBackoff, maxBackoff, maxRetries)); options.setUseTransactionalContentMD5(getUseTransactionalContentMD5()); return options; }
Example 7
Source File: GenericTests.java From azure-storage-android with Apache License 2.0 | 5 votes |
@Test public void testProxy() throws URISyntaxException, StorageException { CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); // Use a request-level proxy OperationContext opContext = new OperationContext(); opContext.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.1.1.1", 8888))); // Turn of retries to make the failure happen faster BlobRequestOptions opt = new BlobRequestOptions(); opt.setRetryPolicyFactory(new RetryNoRetry()); // Unfortunately HttpURLConnection doesn't expose a getter and the usingProxy method it does have doesn't // work as one would expect and will always for us return false. So, we validate by making sure the request // fails when we set a bad proxy rather than check the proxy setting itself. try { container.exists(null, opt, opContext); fail("Bad proxy should throw an exception."); } catch (StorageException e) { if (e.getCause().getClass() != ConnectException.class && e.getCause().getClass() != SocketTimeoutException.class && e.getCause().getClass() != SocketException.class) { Assert.fail("Unepected exception for bad proxy"); } } }
Example 8
Source File: GenericTests.java From azure-storage-android with Apache License 2.0 | 5 votes |
@Test public void testProxyOverridesDefault() throws URISyntaxException, StorageException { CloudBlobClient blobClient = TestHelper.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); // Set a default proxy OperationContext.setDefaultProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.1.1.1", 8888))); // Turn off retries to make the failure happen faster BlobRequestOptions opt = new BlobRequestOptions(); opt.setRetryPolicyFactory(new RetryNoRetry()); // Unfortunately HttpURLConnection doesn't expose a getter and the usingProxy method it does have doesn't // work as one would expect and will always for us return false. So, we validate by making sure the request // fails when we set a bad proxy rather than check the proxy setting itself succeeding. try { container.exists(null, opt, null); fail("Bad proxy should throw an exception."); } catch (StorageException e) { if (e.getCause().getClass() != ConnectException.class && e.getCause().getClass() != SocketTimeoutException.class) { Assert.fail("Unepected exception for bad proxy"); } } // Override it with no proxy OperationContext opContext = new OperationContext(); opContext.setProxy(Proxy.NO_PROXY); // Should succeed as request-level proxy should override the bad default proxy container.exists(null, null, opContext); }