Module io.github.bucket4j.core
Class TryConsumeAndReturnRemainingTokensCommand
java.lang.Object
io.github.bucket4j.distributed.remote.commands.TryConsumeAndReturnRemainingTokensCommand
- All Implemented Interfaces:
RemoteCommand<ConsumptionProbe>,ComparableByContent<TryConsumeAndReturnRemainingTokensCommand>
public class TryConsumeAndReturnRemainingTokensCommand
extends Object
implements RemoteCommand<ConsumptionProbe>, ComparableByContent<TryConsumeAndReturnRemainingTokensCommand>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SerializationHandle<TryConsumeAndReturnRemainingTokensCommand> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongexecute(MutableBucketEntry mutableEntry, long currentTimeNanos) longgetConsumedTokens(ConsumptionProbe result) longbooleanisImmediateSyncRequired(long unsynchronizedTokens, long nanosSinceLastSync) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.bucket4j.distributed.remote.RemoteCommand
asVerbose, canBeMerged, getMergedCommandsCount, isInitializationCommand, isMerged, mergeInto, toMergedCommand, unwrapOneResult
-
Field Details
-
SERIALIZATION_HANDLE
public static final SerializationHandle<TryConsumeAndReturnRemainingTokensCommand> SERIALIZATION_HANDLE
-
-
Constructor Details
-
TryConsumeAndReturnRemainingTokensCommand
public TryConsumeAndReturnRemainingTokensCommand(long tokensToConsume)
-
-
Method Details
-
execute
public CommandResult<ConsumptionProbe> execute(MutableBucketEntry mutableEntry, long currentTimeNanos) - Specified by:
executein interfaceRemoteCommand<ConsumptionProbe>
-
getTokensToConsume
public long getTokensToConsume() -
getSerializationHandle
- Specified by:
getSerializationHandlein interfaceRemoteCommand<ConsumptionProbe>
-
equalsByContent
- Specified by:
equalsByContentin interfaceComparableByContent<TryConsumeAndReturnRemainingTokensCommand>
-
isImmediateSyncRequired
public boolean isImmediateSyncRequired(long unsynchronizedTokens, long nanosSinceLastSync) - Specified by:
isImmediateSyncRequiredin interfaceRemoteCommand<ConsumptionProbe>
-
estimateTokensToConsume
public long estimateTokensToConsume()- Specified by:
estimateTokensToConsumein interfaceRemoteCommand<ConsumptionProbe>
-
getConsumedTokens
- Specified by:
getConsumedTokensin interfaceRemoteCommand<ConsumptionProbe>
-
getRequiredVersion
- Specified by:
getRequiredVersionin interfaceRemoteCommand<ConsumptionProbe>
-