Package net.sf.ehcache.pool.impl
Class AbstractPool
- java.lang.Object
-
- net.sf.ehcache.pool.impl.AbstractPool
-
- All Implemented Interfaces:
Pool
- Direct Known Subclasses:
BoundedPool,StrictlyBoundedPool
public abstract class AbstractPool extends java.lang.Object implements Pool
An abstract pool implementation.This contains all the logic of a pool except for the actual creation of accessor instances.
- Author:
- Chris Dennis, Alex Snaps
-
-
Constructor Summary
Constructors Constructor Description AbstractPool(long maximumPoolSize, PoolEvictor evictor, SizeOfEngine defaultSizeOfEngine)Create an AbstractPool instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PoolAccessorcreatePoolAccessor(PoolParticipant participant, int maxDepth, boolean abortWhenMaxDepthExceeded)Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.PoolEvictorgetEvictor()Return the pool evictor used by this pool.longgetMaxSize()Return the maximum size of the pool.java.util.Collection<PoolAccessor>getPoolAccessors()Return the participants accessing this pool.longgetSize()Return the used size of the pool.voidregisterPoolAccessor(PoolAccessor accessor)Register an accessor implementation with this pool.voidremovePoolAccessor(PoolAccessor accessor)Remove the supplied accessor from this pool.voidsetMaxSize(long newSize)Change the maximum size of the pool.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.ehcache.pool.Pool
createPoolAccessor
-
-
-
-
Constructor Detail
-
AbstractPool
public AbstractPool(long maximumPoolSize, PoolEvictor evictor, SizeOfEngine defaultSizeOfEngine)Create an AbstractPool instance- Parameters:
maximumPoolSize- the maximum size of the pool, in bytes.evictor- the pool evictor, for cross-store eviction.defaultSizeOfEngine- the default SizeOf engine used by the accessors.
-
-
Method Detail
-
getSize
public long getSize()
Return the used size of the pool.
-
getMaxSize
public long getMaxSize()
Return the maximum size of the pool.- Specified by:
getMaxSizein interfacePool- Returns:
- the maximum size of the pool.
-
setMaxSize
public void setMaxSize(long newSize)
Change the maximum size of the pool.- Specified by:
setMaxSizein interfacePool- Parameters:
newSize- the new pool size.
-
createPoolAccessor
public PoolAccessor createPoolAccessor(PoolParticipant participant, int maxDepth, boolean abortWhenMaxDepthExceeded)
Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.- Specified by:
createPoolAccessorin interfacePool- Parameters:
participant- the participant which will use the created accessor.maxDepth- maximum depth of the object graph to traverseabortWhenMaxDepthExceeded- true if the object traversal should be aborted when the max depth is exceeded- Returns:
- a PoolAccessor whose consumption is tracked by this pool.
-
registerPoolAccessor
public void registerPoolAccessor(PoolAccessor accessor)
Register an accessor implementation with this pool.- Specified by:
registerPoolAccessorin interfacePool- Parameters:
accessor- accessor to be registered
-
removePoolAccessor
public void removePoolAccessor(PoolAccessor accessor)
Remove the supplied accessor from this pool.- Specified by:
removePoolAccessorin interfacePool- Parameters:
accessor- accessor to be removed
-
getPoolAccessors
public java.util.Collection<PoolAccessor> getPoolAccessors()
Return the participants accessing this pool.- Specified by:
getPoolAccessorsin interfacePool- Returns:
- participants using this pool
-
getEvictor
public PoolEvictor getEvictor()
Return the pool evictor used by this pool.- Specified by:
getEvictorin interfacePool- Returns:
- the pool evictor
-
-