Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

feat: deprecate RetrySettings.isJittered [gax-java] #1308

Merged
merged 3 commits into from Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -187,7 +187,7 @@ public boolean shouldRetry(TimedAttemptSettings nextAttemptSettings) {

// Injecting Random is not possible here, as Random does not provide nextLong(long bound) method
protected long nextRandomLong(long bound) {
return bound > 0 && globalSettings.isJittered()
return bound > 0 && globalSettings.isJittered() // Jitter check needed for testing purposes.
? ThreadLocalRandom.current().nextLong(bound)
: bound;
}
Expand Down
15 changes: 12 additions & 3 deletions gax/src/main/java/com/google/api/gax/retrying/RetrySettings.java
Expand Up @@ -30,6 +30,7 @@
package com.google.api.gax.retrying;

import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
import org.threeten.bp.Duration;

Expand Down Expand Up @@ -112,7 +113,11 @@ public abstract class RetrySettings implements Serializable {
* <pre>{@code actualDelay = rand_between(0, min(maxRetryDelay, delay))}</pre>
*
* The default value is {@code true}.
*
* @deprecated Retries always jitter.
*/
@Deprecated
@VisibleForTesting
public abstract boolean isJittered();

/**
Expand Down Expand Up @@ -194,13 +199,17 @@ public abstract static class Builder {
public abstract Builder setMaxAttempts(int maxAttempts);

/**
* Jitter determines if the delay time should be randomized. In most cases, if jitter is set to
* {@code true} the actual delay time is calculated in the following way:
* Jitter determines if the delay time should be randomized. If jitter is set to {@code true}
* the actual delay time is calculated in the following way:
*
* <pre>{@code actualDelay = rand_between(0, min(maxRetryDelay, exponentialDelay))}</pre>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment should be updated to specify it's a no-op

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

*
* The default value is {@code true}.
* The default value is {@code true}, and this method will be a no-op soon.
*
* @deprecated Retries always jitter.
*/
@Deprecated
@VisibleForTesting
public abstract Builder setJittered(boolean jittered);

/**
Expand Down