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.ObjectUsed for retry throttling.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intmaxTokens1000 times the maxTokens field of the retryThrottling policy in service config.private static intTHREE_DECIMAL_PLACES_SCALE_UP(package private) intthresholdHalf ofmaxTokens.(package private) java.util.concurrent.atomic.AtomicIntegertokenCount(package private) inttokenRatio1000 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 booleanequals(java.lang.Object o)inthashCode()(package private) booleanisAboveThreshold()(package private) booleanonQualifiedFailureThenCheckIsAboveThreshold()Counts down the token on qualified failure and checks if it is above the threshold atomically.(package private) voidonSuccess()
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-