Skip to content

Commit de33a66

Browse files
committed
---
yaml --- r: 4771 b: refs/heads/logging-alpha c: bdc472a h: refs/heads/master i: 4769: 20726e0 4767: e686a7d
1 parent 726a563 commit de33a66

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: a8ec412e31e65a5a846c737828f7b17a187f5aeb
15+
refs/heads/logging-alpha: bdc472a9737e6b21fca699130aef5007bfdb7891
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/gcloud-java-core/src/main/java/com/google/gcloud/RetryParams.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ public final class RetryParams implements Serializable {
4848

4949
private static final long serialVersionUID = -8492751576749007700L;
5050

51+
/**
52+
* Note that App Engine Standard Environment front-end modules have a 60 second deadline for HTTP
53+
* requests. For that reason, we set the default total retry period to less than 60 seconds.
54+
*/
55+
public static final long DEFAULT_TOTAL_RETRY_PERIOD_MILLIS = 50_000L;
5156
public static final int DEFAULT_RETRY_MIN_ATTEMPTS = 3;
5257
public static final int DEFAULT_RETRY_MAX_ATTEMPTS = 6;
53-
public static final long DEFAULT_INITIAL_RETRY_DELAY_MILLIS = 250L;
54-
public static final long DEFAULT_MAX_RETRY_DELAY_MILLIS = 10_000L;
58+
public static final long DEFAULT_INITIAL_RETRY_DELAY_MILLIS = 1000L;
59+
public static final long DEFAULT_MAX_RETRY_DELAY_MILLIS = 32_000L;
5560
public static final double DEFAULT_RETRY_DELAY_BACKOFF_FACTOR = 2.0;
56-
public static final long DEFAULT_TOTAL_RETRY_PERIOD_MILLIS = 50_000L;
5761

5862
private final int retryMinAttempts;
5963
private final int retryMaxAttempts;
@@ -62,6 +66,9 @@ public final class RetryParams implements Serializable {
6266
private final double retryDelayBackoffFactor;
6367
private final long totalRetryPeriodMillis;
6468

69+
// Some services may have different backoff requirements listed in their SLAs. Be sure to override
70+
// ServiceOptions.defaultRetryParams() in options subclasses when the service's backoff
71+
// requirement differs from the default parameters used here.
6572
private static final RetryParams DEFAULT_INSTANCE = new RetryParams(new Builder());
6673
private static final RetryParams NO_RETRIES =
6774
builder().retryMaxAttempts(1).retryMinAttempts(1).build();
@@ -156,7 +163,9 @@ public Builder retryDelayBackoffFactor(double retryDelayBackoffFactor) {
156163
}
157164

158165
/**
159-
* Sets totalRetryPeriodMillis.
166+
* Sets totalRetryPeriodMillis. Note that App Engine Standard Environment front-end modules have
167+
* a 60 second deadline for HTTP requests. For that reason, you should set the total retry
168+
* period to under 60 seconds if you are using it on an App Engine front-end module.
160169
*
161170
* @param totalRetryPeriodMillis the totalRetryPeriodMillis to set
162171
* @return the Builder for chaining
@@ -295,4 +304,8 @@ public String toString() {
295304
public static Builder builder() {
296305
return new Builder();
297306
}
307+
308+
public Builder toBuilder() {
309+
return new Builder(this);
310+
}
298311
}

branches/logging-alpha/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> ser
333333
authCredentials =
334334
builder.authCredentials != null ? builder.authCredentials : defaultAuthCredentials();
335335
authCredentialsState = authCredentials != null ? authCredentials.capture() : null;
336-
retryParams = firstNonNull(builder.retryParams, RetryParams.defaultInstance());
336+
retryParams = firstNonNull(builder.retryParams, defaultRetryParams());
337337
serviceFactory = firstNonNull(builder.serviceFactory,
338338
getFromServiceLoader(serviceFactoryClass, defaultServiceFactory()));
339339
serviceFactoryClassName = serviceFactory.getClass().getName();
@@ -654,6 +654,15 @@ private static <T> T newInstance(String className) throws IOException, ClassNotF
654654

655655
public abstract <B extends Builder<ServiceT, ServiceRpcT, OptionsT, B>> B toBuilder();
656656

657+
/**
658+
* Some services may have different backoff requirements listed in their SLAs. Be sure to override
659+
* this method in options subclasses when the service's backoff requirement differs from the
660+
* default parameters listed in {@link RetryParams}.
661+
*/
662+
protected RetryParams defaultRetryParams() {
663+
return RetryParams.defaultInstance();
664+
}
665+
657666
private static <T> T getFromServiceLoader(Class<? extends T> clazz, T defaultInstance) {
658667
return Iterables.getFirst(ServiceLoader.load(clazz), defaultInstance);
659668
}

0 commit comments

Comments
 (0)