Package org.apache.cassandra.net
Interface ResourceLimits.Limit
-
- All Known Implementing Classes:
ResourceLimits.Basic,ResourceLimits.Concurrent
- Enclosing class:
- ResourceLimits
public static interface ResourceLimits.LimitRepresents permits to utilise a resource and ways to allocate and release them. Two implementations are currently provided: 1.ResourceLimits.Concurrent, for shared limits, which is thread-safe; 2.ResourceLimits.Basic, for limits that are not shared between threads, is not thread-safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidallocate(long amount)Allocates an amount independent of permits available from this limit.longlimit()ResourceLimits.Outcomerelease(long amount)longremaining()longsetLimit(long newLimit)Sets the total amount of permits represented by thisResourceLimits.Limit- the capacity If the old limit has been reached and the new limit is large enough to allow for more permits to be acquired, subsequent calls toallocate(long)ortryAllocate(long)will succeed.booleantryAllocate(long amount)Attempts to allocate an amount of permits from this limit.longusing()
-
-
-
Method Detail
-
limit
long limit()
- Returns:
- total amount of permits represented by this
ResourceLimits.Limit- the capacity
-
setLimit
long setLimit(long newLimit)
Sets the total amount of permits represented by thisResourceLimits.Limit- the capacity If the old limit has been reached and the new limit is large enough to allow for more permits to be acquired, subsequent calls toallocate(long)ortryAllocate(long)will succeed. If the new limit is lower than the current amount of allocated permits then subsequent calls toallocate(long)ortryAllocate(long)will block or fail respectively.- Returns:
- the old limit
-
remaining
long remaining()
- Returns:
- remaining, unallocated permit amount
-
using
long using()
- Returns:
- amount of permits currently in use
-
tryAllocate
boolean tryAllocate(long amount)
Attempts to allocate an amount of permits from this limit. If allocated, MUST eventually be released back withrelease(long).- Returns:
trueif the allocation was successful,falseotherwise
-
allocate
void allocate(long amount)
Allocates an amount independent of permits available from this limit. MUST eventually be released back withrelease(long).
-
release
ResourceLimits.Outcome release(long amount)
- Parameters:
amount- return the amount of permits back to this limit- Returns:
ABOVE_LIMITif there aren't enough permits available even after the release, orBELOW_LIMITif there are enough permits available after the releaese.
-
-