- All Superinterfaces:
Bucket
- All Known Implementing Classes:
LockFreeBucket,SynchronizedBucket,ThreadUnsafeBucket
Represents the bucket inside current JVM.
-
Method Summary
Modifier and TypeMethodDescriptionstatic LocalBucketfromBinarySnapshot(byte[] snapshot) Reconstructs a bucket from binary snapshot.static LocalBucketfromJsonCompatibleSnapshot(Map<String, Object> snapshot) Reconstructs a bucket from JSON snapshot.Returns configuration of this bucket.Returns the synchronization strategy that is used by this bucketReturns the clock that is used by this bucketdefault byte[]Takes the binary snapshot of this bucket that later can be used as parameter forfromBinarySnapshot(byte[])to restore bucket from snapshot.Takes the JSON snapshot of this bucket that later can be used as parameter forfromJsonCompatibleSnapshot(Map)to restore bucket from snapshot.Methods inherited from interface io.github.bucket4j.Bucket
addTokens, asBlocking, asScheduler, asVerbose, consumeIgnoringRateLimits, estimateAbilityToConsume, forceAddTokens, getAvailableTokens, replaceConfiguration, reset, toListenable, tryConsume, tryConsumeAndReturnRemaining, tryConsumeAsMuchAsPossible, tryConsumeAsMuchAsPossible
-
Method Details
-
getConfiguration
BucketConfiguration getConfiguration()Returns configuration of this bucket.- Returns:
- configuration
-
getTimeMeter
TimeMeter getTimeMeter()Returns the clock that is used by this bucket- Returns:
- the clock that is used by this bucket
-
getSynchronizationStrategy
SynchronizationStrategy getSynchronizationStrategy()Returns the synchronization strategy that is used by this bucket- Returns:
- synchronization strategy that is used by this bucket
-
toBinarySnapshot
Takes the binary snapshot of this bucket that later can be used as parameter forfromBinarySnapshot(byte[])to restore bucket from snapshot.- Returns:
- the binary snapshot of this bucket
- Throws:
IOException
-
fromBinarySnapshot
Reconstructs a bucket from binary snapshot.- Parameters:
snapshot- binary snapshot- Returns:
- bucket reconstructed from binary snapshot
- Throws:
IOException
-
toJsonCompatibleSnapshot
Takes the JSON snapshot of this bucket that later can be used as parameter forfromJsonCompatibleSnapshot(Map)to restore bucket from snapshot.- Returns:
- the map that transparently can be serialized to JSON via any JSON library
- Throws:
IOException
-
fromJsonCompatibleSnapshot
Reconstructs a bucket from JSON snapshot.- Parameters:
snapshot- the snapshot Map that was deserialized from JSON via any JSON library- Returns:
- bucket reconstructed from binary snapshot
- Throws:
IOException
-