From b3a9e76d21e27a6c1b193d976dedac241a19722f Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Thu, 8 Oct 2009 18:38:36 +0000 Subject: [PATCH] added timeout parameter for builders git-svn-id: http://jclouds.googlecode.com/svn/trunk@1951 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../org/jclouds/aws/s3/S3ContextBuilder.java | 5 +++++ .../storage/blob/AzureBlobContextBuilder.java | 5 +++++ .../blobstore/BlobStoreContextBuilder.java | 9 +++++++++ .../internal/BaseContainerIntegrationTest.java | 16 ++++++++-------- .../cloudfiles/CloudFilesContextBuilder.java | 9 +++++++-- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java index fbc2d8b571..2ded8eccf3 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java @@ -90,6 +90,11 @@ public class S3ContextBuilder extends return (S3ContextBuilder) super.relaxSSLHostname(); } + @Override + public S3ContextBuilder withRequestTimeout(long milliseconds) { + return (S3ContextBuilder) super.withRequestTimeout(milliseconds); + } + @Override public S3ContextBuilder withExecutorService(ExecutorService service) { return (S3ContextBuilder) super.withExecutorService(service); diff --git a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java index 75b33f16b4..4106928262 100755 --- a/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java +++ b/azure/storage/blob/core/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java @@ -145,6 +145,11 @@ public class AzureBlobContextBuilder extends return (AzureBlobContextBuilder) super.withPoolMaxConnections(poolMaxConnections); } + @Override + public AzureBlobContextBuilder withRequestTimeout(long milliseconds) { + return (AzureBlobContextBuilder) super.withRequestTimeout(milliseconds); + } + @Override public AzureBlobContextBuilder withPoolMaxSessionFailures(int poolMaxSessionFailures) { return (AzureBlobContextBuilder) super.withPoolMaxSessionFailures(poolMaxSessionFailures); diff --git a/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java b/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java index 880e4e2f76..9a85acbdbc 100644 --- a/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java +++ b/blobstore/core/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java @@ -30,6 +30,7 @@ import java.util.concurrent.ExecutorService; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ContainerMetadata; +import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.cloud.CloudContextBuilder; import com.google.inject.Key; @@ -54,6 +55,14 @@ public abstract class BlobStoreContextBuilder) super.withHttpMaxRedirects(httpMaxRedirects); } + /** + * longest time a single synchronous operation can take before throwing an exception. + */ + public BlobStoreContextBuilder withRequestTimeout(long milliseconds) { + properties.setProperty(BlobStoreConstants.PROPERTY_BLOBSTORE_TIMEOUT, Long.toString(milliseconds)); + return this; + } + @SuppressWarnings("unchecked") @Override public BlobStoreContextBuilder withHttpMaxRetries(int httpMaxRetries) { diff --git a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 110dc9e369..a0caee7aff 100755 --- a/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -52,8 +52,8 @@ public class BaseContainerIntegrationTest container = context.getBlobStore().listBlobs(containerName).get(10, + SortedSet container = context.getBlobStore().listBlobs(containerName).get(60, TimeUnit.SECONDS); assertEquals(container.size(), 15); } finally { @@ -126,7 +126,7 @@ public class BaseContainerIntegrationTest