Skip to content

Commit

Permalink
Set default retry strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Jan 12, 2016
1 parent 5a23e57 commit 2d1e836
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public void setUp() {
options = BigQueryOptions.builder()
.projectId(PROJECT)
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.noRetries())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ public B authCredentials(AuthCredentials authCredentials) {

/**
* Sets configuration parameters for request retries. If no configuration is set
* {@link RetryParams#noRetries()} is used.
* {@link RetryParams#defaultInstance()} is used. To disable retries, supply
* {@link RetryParams#noRetries()} here.
*
* @return the builder
*/
Expand Down Expand Up @@ -325,7 +326,7 @@ protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> ser
authCredentials =
builder.authCredentials != null ? builder.authCredentials : defaultAuthCredentials();
authCredentialsState = authCredentials != null ? authCredentials.capture() : null;
retryParams = builder.retryParams;
retryParams = firstNonNull(builder.retryParams, RetryParams.defaultInstance());
serviceFactory = firstNonNull(builder.serviceFactory,
getFromServiceLoader(serviceFactoryClass, defaultServiceFactory()));
serviceFactoryClassName = serviceFactory.getClass().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void setUp() {
options = DatastoreOptions.builder()
.projectId(PROJECT_ID)
.host("http://localhost:" + PORT)
.retryParams(RetryParams.noRetries())
.build();
datastore = options.service();
StructuredQuery<Key> query = Query.keyQueryBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.gcloud.AuthCredentials;
import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials;
import com.google.gcloud.RetryParams;
import com.google.gcloud.spi.StorageRpc.Tuple;
import com.google.gcloud.storage.Blob;
import com.google.gcloud.storage.BlobId;
Expand Down Expand Up @@ -549,8 +548,7 @@ public static void main(String... args) throws Exception {
printUsage();
return;
}
StorageOptions.Builder optionsBuilder =
StorageOptions.builder().retryParams(RetryParams.defaultInstance());
StorageOptions.Builder optionsBuilder = StorageOptions.builder();
StorageAction action;
String actionName;
if (args.length >= 2 && !ACTIONS.containsKey(args[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.google.common.collect.ImmutableMap;
import com.google.gcloud.Page;
import com.google.gcloud.RetryParams;
import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId;
import com.google.gcloud.resourcemanager.ResourceManager.ProjectField;
import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption;
Expand Down Expand Up @@ -271,7 +270,6 @@ public void testRetryableException() {
EasyMock.replay(rpcFactoryMock);
ResourceManager resourceManagerMock = ResourceManagerOptions.builder()
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.defaultInstance())
.build()
.service();
EasyMock.expect(resourceManagerRpcMock.get(PARTIAL_PROJECT.projectId(), EMPTY_RPC_OPTIONS))
Expand All @@ -291,7 +289,6 @@ public void testNonRetryableException() {
EasyMock.replay(rpcFactoryMock);
ResourceManager resourceManagerMock = ResourceManagerOptions.builder()
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.defaultInstance())
.build()
.service();
EasyMock.expect(resourceManagerRpcMock.get(PARTIAL_PROJECT.projectId(), EMPTY_RPC_OPTIONS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.gcloud.RestorableState;
import com.google.gcloud.RetryParams;
import com.google.gcloud.spi.StorageRpc;
import com.google.gcloud.spi.StorageRpcFactory;

Expand Down Expand Up @@ -65,6 +66,7 @@ public void setUp() {
options = StorageOptions.builder()
.projectId("projectId")
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.noRetries())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.gcloud.RestorableState;
import com.google.gcloud.RetryParams;
import com.google.gcloud.spi.StorageRpc;
import com.google.gcloud.spi.StorageRpcFactory;

Expand Down Expand Up @@ -74,6 +75,7 @@ public void setUp() {
options = StorageOptions.builder()
.projectId("projectid")
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.noRetries())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.google.common.collect.ImmutableMap;
import com.google.gcloud.RestorableState;
import com.google.gcloud.RetryParams;
import com.google.gcloud.spi.StorageRpc;
import com.google.gcloud.spi.StorageRpc.RewriteRequest;
import com.google.gcloud.spi.StorageRpc.RewriteResponse;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void setUp() {
options = StorageOptions.builder()
.projectId("projectid")
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.noRetries())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public void setUp() {
.projectId("projectId")
.clock(TIME_SOURCE)
.serviceRpcFactory(rpcFactoryMock)
.retryParams(RetryParams.noRetries())
.build();
}

Expand Down

0 comments on commit 2d1e836

Please sign in to comment.