Package com.terracottatech.store.usage
Interface SizedResource<E extends UsageEvent>
- All Superinterfaces:
Resource
- All Known Subinterfaces:
DiskResource
,OffHeapResource
,PhysicalResource
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
deRegisterUsageListener
(UUID listenerUuid) It can be used to deregister an existing registered listener or throw an IllegalArgumentException if the UUID passed is unknown.float
default UUID
registerUsageListener
(float threshold, UsageEventType usageEventType, Consumer<? super E> listener) It can be used to trigger actions from users when the resource usage crosses specific threshold.Methods inherited from interface com.terracottatech.store.usage.Resource
getIdentifier, getType
-
Method Details
-
getOccupancy
float getOccupancy()- Returns:
- resource usage in fraction i.e(used/total) between (0.0f - 1.0f).
-
registerUsageListener
default UUID registerUsageListener(float threshold, UsageEventType usageEventType, Consumer<? super E> listener) It can be used to trigger actions from users when the resource usage crosses specific threshold. Suppose, listener is registered with 0.8f threshold and RISING listenerType then the consumer will be called when the occupancy for the resource first crosses the 0.8f. Similarly, listener can be registered with FALLING listenerType but then the consumer will be called when the usage drops below the specific threshold for first time after it crosses the threshold.- Parameters:
threshold
- when usage reaches this occupancy.usageEventType
- whether the usage listener registered for RISING/FALLING threshold.listener
- consumer which will be consumed when the occupancy crosses the specific threshold.- Returns:
- UUID for unique identification of the registered listener.
-
deRegisterUsageListener
It can be used to deregister an existing registered listener or throw an IllegalArgumentException if the UUID passed is unknown.- Parameters:
listenerUuid
- UUID for the registered listener.- Throws:
IllegalArgumentException
-