public class DefaultBucketProxy extends AbstractBucket implements BucketProxy
INFINITY_DURATION, UNLIMITED_AMOUNT
Constructor and Description |
---|
DefaultBucketProxy(Supplier<BucketConfiguration> configurationSupplier,
CommandExecutor commandExecutor,
RecoveryStrategy recoveryStrategy) |
addTokens, asBlocking, asScheduler, asVerbose, completedFuture, consume, consume, consumeIgnoringRateLimits, consumeUninterruptibly, estimateAbilityToConsume, failedFuture, getListener, replaceConfiguration, tryConsume, tryConsume, tryConsume, tryConsumeAndReturnRemaining, tryConsumeAsMuchAsPossible, tryConsumeAsMuchAsPossible, tryConsumeUninterruptibly
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
syncImmediately
addTokens, asBlocking, asScheduler, asVerbose, builder, consumeIgnoringRateLimits, estimateAbilityToConsume, replaceConfiguration, tryConsume, tryConsumeAndReturnRemaining, tryConsumeAsMuchAsPossible, tryConsumeAsMuchAsPossible
consume, consumeUninterruptibly, tryConsume, tryConsume, tryConsume, tryConsumeUninterruptibly, tryConsumeUninterruptibly, tryConsumeUninterruptibly
tryConsume
public DefaultBucketProxy(Supplier<BucketConfiguration> configurationSupplier, CommandExecutor commandExecutor, RecoveryStrategy recoveryStrategy)
public BucketProxy 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.toListenable
in interface Bucket
toListenable
in interface BucketProxy
listener
- the listener of bucket events.listener
public void syncByCondition(long unsynchronizedTokens, Duration timeSinceLastSync)
syncByCondition
in interface BucketProxy
protected long consumeAsMuchAsPossibleImpl(long limit)
consumeAsMuchAsPossibleImpl
in class AbstractBucket
protected boolean tryConsumeImpl(long tokensToConsume)
tryConsumeImpl
in class AbstractBucket
protected ConsumptionProbe tryConsumeAndReturnRemainingTokensImpl(long tokensToConsume)
tryConsumeAndReturnRemainingTokensImpl
in class AbstractBucket
protected EstimationProbe estimateAbilityToConsumeImpl(long numTokens)
estimateAbilityToConsumeImpl
in class AbstractBucket
protected long reserveAndCalculateTimeToSleepImpl(long tokensToConsume, long waitIfBusyNanosLimit)
reserveAndCalculateTimeToSleepImpl
in class AbstractBucket
protected void addTokensImpl(long tokensToAdd)
addTokensImpl
in class AbstractBucket
protected BucketConfiguration replaceConfigurationImpl(BucketConfiguration newConfiguration)
replaceConfigurationImpl
in class AbstractBucket
protected long consumeIgnoringRateLimitsImpl(long tokensToConsume)
consumeIgnoringRateLimitsImpl
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.
getAvailableTokens
in interface Bucket
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.
createSnapshot
in interface Bucket
protected VerboseResult<Long> consumeAsMuchAsPossibleVerboseImpl(long limit)
consumeAsMuchAsPossibleVerboseImpl
in class AbstractBucket
protected VerboseResult<Boolean> tryConsumeVerboseImpl(long tokensToConsume)
tryConsumeVerboseImpl
in class AbstractBucket
protected VerboseResult<ConsumptionProbe> tryConsumeAndReturnRemainingTokensVerboseImpl(long tokensToConsume)
tryConsumeAndReturnRemainingTokensVerboseImpl
in class AbstractBucket
protected VerboseResult<EstimationProbe> estimateAbilityToConsumeVerboseImpl(long numTokens)
estimateAbilityToConsumeVerboseImpl
in class AbstractBucket
protected VerboseResult<Long> getAvailableTokensVerboseImpl()
getAvailableTokensVerboseImpl
in class AbstractBucket
protected VerboseResult<Nothing> addTokensVerboseImpl(long tokensToAdd)
addTokensVerboseImpl
in class AbstractBucket
protected VerboseResult<BucketConfiguration> replaceConfigurationVerboseImpl(BucketConfiguration newConfiguration)
replaceConfigurationVerboseImpl
in class AbstractBucket
protected VerboseResult<Long> consumeIgnoringRateLimitsVerboseImpl(long tokensToConsume)
consumeIgnoringRateLimitsVerboseImpl
in class AbstractBucket
Copyright © 2020. All rights reserved.