Package io.grpc.internal
Class RetriableStream.Throttle
- java.lang.Object
-
- io.grpc.internal.RetriableStream.Throttle
-
- Enclosing class:
- RetriableStream<ReqT>
static final class RetriableStream.Throttle extends java.lang.Object
Used for retry throttling.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
maxTokens
1000 times the maxTokens field of the retryThrottling policy in service config.private static int
THREE_DECIMAL_PLACES_SCALE_UP
(package private) int
threshold
Half ofmaxTokens
.(package private) java.util.concurrent.atomic.AtomicInteger
tokenCount
(package private) int
tokenRatio
1000 times the tokenRatio field of the retryThrottling policy in service config.
-
Constructor Summary
Constructors Constructor Description Throttle(float maxTokens, float tokenRatio)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
hashCode()
(package private) boolean
isAboveThreshold()
(package private) boolean
onQualifiedFailureThenCheckIsAboveThreshold()
Counts down the token on qualified failure and checks if it is above the threshold atomically.(package private) void
onSuccess()
-
-
-
Field Detail
-
THREE_DECIMAL_PLACES_SCALE_UP
private static final int THREE_DECIMAL_PLACES_SCALE_UP
- See Also:
- Constant Field Values
-
maxTokens
final int maxTokens
1000 times the maxTokens field of the retryThrottling policy in service config. The number of tokens starts at maxTokens. The token_count will always be between 0 and maxTokens.
-
threshold
final int threshold
Half ofmaxTokens
.
-
tokenRatio
final int tokenRatio
1000 times the tokenRatio field of the retryThrottling policy in service config.
-
tokenCount
final java.util.concurrent.atomic.AtomicInteger tokenCount
-
-
Method Detail
-
isAboveThreshold
boolean isAboveThreshold()
-
onQualifiedFailureThenCheckIsAboveThreshold
boolean onQualifiedFailureThenCheckIsAboveThreshold()
Counts down the token on qualified failure and checks if it is above the threshold atomically. Qualified failure is a failure with a retryable or non-fatal status code or with a not-to-retry pushback.
-
onSuccess
void onSuccess()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-