Package net.sf.ehcache.pool
Interface PoolAccessor<T extends PoolParticipant>
-
- Type Parameters:
T- Type representing this "other" side of this accessor (i.e. a store), so the evictor can interact with it
- All Known Implementing Classes:
AbstractPoolAccessor
public interface PoolAccessor<T extends PoolParticipant>PoolAccessors are used by stores to tell the pools about their resource consumption- Author:
- Ludovic Orban, Alex Snaps
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longadd(java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)Add an element to the pool.booleancanAddWithoutEvicting(java.lang.Object key, java.lang.Object value, java.lang.Object container)Check if there is enough room in the pool to add an element without provoking any evictionvoidclear()Free resources used by this accessor.longdelete(long size)Delete a fixed number of bytes from the pool.TgetParticipant()Return the store that uses this accessorlonggetPoolOccupancy()Returns the occupied size for this pool.longgetPoolSize()Returns the size of this pool.longgetSize()Return how many bytes this accessor consumes from the pool.booleanhasAbortedSizeOf()Check if the store may contain elements which the SizeOf engine could not fully size.longreplace(long currentSize, java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)Delete a fixed number of bytes from the pool with the given objects.voidsetMaxSize(long newValue)Sets the max size for this poolvoidunlink()unlink this PoolAccessor from its pool.
-
-
-
Method Detail
-
add
long add(java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)Add an element to the pool.- Parameters:
key- the key of the elementvalue- the value of the elementcontainer- the element-container objectforce- true if the pool should accept adding the element, even if it's out of resources- Returns:
- how many bytes have been added to the pool or -1 if add failed.
-
canAddWithoutEvicting
boolean canAddWithoutEvicting(java.lang.Object key, java.lang.Object value, java.lang.Object container)Check if there is enough room in the pool to add an element without provoking any eviction- Parameters:
key- the key of the elementvalue- the value of the elementcontainer- the element-container object- Returns:
- true if there is enough room left
-
delete
long delete(long size) throws java.lang.IllegalArgumentExceptionDelete a fixed number of bytes from the pool.- Parameters:
size- number of bytes- Returns:
- how many bytes have been freed from the pool.
- Throws:
java.lang.IllegalArgumentException- when sizeOf is negative
-
replace
long replace(long currentSize, java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)Delete a fixed number of bytes from the pool with the given objects.- Parameters:
currentSize- the size of the object(s) being replacedkey- the key of the elementvalue- the value of the elementcontainer- the element-container objectforce- true if the pool should accept replacing the element, even if it's out of resources- Returns:
- the change in size of the pool, or
Long.MIN_VALUEif replace failed.
-
getSize
long getSize()
Return how many bytes this accessor consumes from the pool.- Returns:
- how many bytes this accessor consumes from the pool.
-
unlink
void unlink()
unlink this PoolAccessor from its pool.
-
clear
void clear()
Free resources used by this accessor.
-
getParticipant
T getParticipant()
Return the store that uses this accessor- Returns:
- store using this accessor
-
setMaxSize
void setMaxSize(long newValue)
Sets the max size for this pool- Parameters:
newValue- the value in bytes
-
getPoolOccupancy
long getPoolOccupancy()
Returns the occupied size for this pool.- Returns:
- occupied pool size
-
getPoolSize
long getPoolSize()
Returns the size of this pool.- Returns:
- pool size
-
hasAbortedSizeOf
boolean hasAbortedSizeOf()
Check if the store may contain elements which the SizeOf engine could not fully size.- Returns:
- true if the store may contain partially sized objects
-
-