K
- type of keypublic class GridBucket<K extends Serializable> extends AbstractBucket
INFINITY_DURATION
Modifier and Type | Method and Description |
---|---|
protected CompletableFuture<Void> |
addTokensAsyncImpl(long tokensToAdd) |
protected void |
addTokensImpl(long tokensToAdd) |
protected long |
consumeAsMuchAsPossibleImpl(long limit) |
protected CompletableFuture<Long> |
consumeIgnoringRateLimitsAsyncImpl(long tokensToConsume) |
protected long |
consumeIgnoringRateLimitsImpl(long tokensToConsume) |
static <T extends Serializable> |
createInitializedBucket(T key,
BucketConfiguration configuration,
GridProxy<T> gridProxy,
RecoveryStrategy recoveryStrategy) |
static <T extends Serializable> |
createLazyBucket(T key,
Supplier<BucketConfiguration> configurationSupplier,
GridProxy<T> gridProxy) |
BucketState |
createSnapshot()
Creates the copy of internal state.
|
protected CompletableFuture<EstimationProbe> |
estimateAbilityToConsumeAsyncImpl(long tokensToEstimate) |
protected EstimationProbe |
estimateAbilityToConsumeImpl(long numTokens) |
long |
getAvailableTokens()
Returns amount of available tokens in this bucket.
|
boolean |
isAsyncModeSupported()
Describes whether or not this bucket supports asynchronous mode.
|
protected CompletableFuture<Void> |
replaceConfigurationAsyncImpl(BucketConfiguration newConfiguration) |
protected void |
replaceConfigurationImpl(BucketConfiguration newConfiguration) |
protected CompletableFuture<Long> |
reserveAndCalculateTimeToSleepAsyncImpl(long tokensToConsume,
long maxWaitTimeNanos) |
protected long |
reserveAndCalculateTimeToSleepImpl(long tokensToConsume,
long waitIfBusyNanosLimit) |
Bucket |
toListenable(BucketListener listener)
Returns new copy of this bucket instance decorated by
listener . |
protected CompletableFuture<ConsumptionProbe> |
tryConsumeAndReturnRemainingTokensAsyncImpl(long tokensToConsume) |
protected ConsumptionProbe |
tryConsumeAndReturnRemainingTokensImpl(long tokensToConsume) |
protected CompletableFuture<Long> |
tryConsumeAsMuchAsPossibleAsyncImpl(long limit) |
protected CompletableFuture<Boolean> |
tryConsumeAsyncImpl(long tokensToConsume) |
protected boolean |
tryConsumeImpl(long tokensToConsume) |
addTokens, asAsync, asAsyncScheduler, asScheduler, consume, consumeIgnoringRateLimits, consumeUninterruptibly, estimateAbilityToConsume, replaceConfiguration, tryConsume, tryConsume, tryConsumeAndReturnRemaining, tryConsumeAsMuchAsPossible, tryConsumeAsMuchAsPossible, tryConsumeUninterruptibly
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
consume, consumeUninterruptibly, tryConsume, tryConsume, tryConsume, tryConsumeUninterruptibly, tryConsumeUninterruptibly, tryConsumeUninterruptibly
public static <T extends Serializable> GridBucket<T> createLazyBucket(T key, Supplier<BucketConfiguration> configurationSupplier, GridProxy<T> gridProxy)
public static <T extends Serializable> GridBucket<T> createInitializedBucket(T key, BucketConfiguration configuration, GridProxy<T> gridProxy, RecoveryStrategy recoveryStrategy)
public Bucket toListenable(BucketListener listener)
Bucket
listener
.
The created bucket will share same tokens with source bucket and vice versa.
See javadocs for BucketListener
in order to understand semantic of listener.listener
- the listener of bucket events.listener
public boolean isAsyncModeSupported()
Bucket
If asynchronous mode is not supported any attempt to call Bucket.asAsync()
will fail with UnsupportedOperationException
protected long consumeAsMuchAsPossibleImpl(long limit)
consumeAsMuchAsPossibleImpl
in class AbstractBucket
protected CompletableFuture<Long> tryConsumeAsMuchAsPossibleAsyncImpl(long limit)
tryConsumeAsMuchAsPossibleAsyncImpl
in class AbstractBucket
protected boolean tryConsumeImpl(long tokensToConsume)
tryConsumeImpl
in class AbstractBucket
protected CompletableFuture<Boolean> tryConsumeAsyncImpl(long tokensToConsume)
tryConsumeAsyncImpl
in class AbstractBucket
protected ConsumptionProbe tryConsumeAndReturnRemainingTokensImpl(long tokensToConsume)
tryConsumeAndReturnRemainingTokensImpl
in class AbstractBucket
protected EstimationProbe estimateAbilityToConsumeImpl(long numTokens)
estimateAbilityToConsumeImpl
in class AbstractBucket
protected CompletableFuture<ConsumptionProbe> tryConsumeAndReturnRemainingTokensAsyncImpl(long tokensToConsume)
tryConsumeAndReturnRemainingTokensAsyncImpl
in class AbstractBucket
protected CompletableFuture<EstimationProbe> estimateAbilityToConsumeAsyncImpl(long tokensToEstimate)
estimateAbilityToConsumeAsyncImpl
in class AbstractBucket
protected long reserveAndCalculateTimeToSleepImpl(long tokensToConsume, long waitIfBusyNanosLimit)
reserveAndCalculateTimeToSleepImpl
in class AbstractBucket
protected long consumeIgnoringRateLimitsImpl(long tokensToConsume)
consumeIgnoringRateLimitsImpl
in class AbstractBucket
protected CompletableFuture<Long> reserveAndCalculateTimeToSleepAsyncImpl(long tokensToConsume, long maxWaitTimeNanos)
reserveAndCalculateTimeToSleepAsyncImpl
in class AbstractBucket
protected void addTokensImpl(long tokensToAdd)
addTokensImpl
in class AbstractBucket
protected CompletableFuture<Void> addTokensAsyncImpl(long tokensToAdd)
addTokensAsyncImpl
in class AbstractBucket
protected void replaceConfigurationImpl(BucketConfiguration newConfiguration)
replaceConfigurationImpl
in class AbstractBucket
protected CompletableFuture<Void> replaceConfigurationAsyncImpl(BucketConfiguration newConfiguration)
replaceConfigurationAsyncImpl
in class AbstractBucket
protected CompletableFuture<Long> consumeIgnoringRateLimitsAsyncImpl(long tokensToConsume)
consumeIgnoringRateLimitsAsyncImpl
in class AbstractBucket
public long getAvailableTokens()
Bucket
This method designed to be used only for monitoring and testing, you should never use this method for business cases, because available tokens can be changed by concurrent transactions for case of multithreaded/multi-process environment.
public BucketState createSnapshot()
Bucket
This method is designed to be used only for monitoring and testing, you should never use this method for business cases.
Copyright © 2020. All rights reserved.