Top Description Fields Constructors Methods
net.sf.ehcache.pool.impl

public abstract Class AbstractPool

extends Object
implements Pool
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.pool.Pool
Known Direct Subclasses
net.sf.ehcache.pool.impl.BoundedPool, net.sf.ehcache.pool.impl.StrictlyBoundedPool
Imports
java.util.Collection, .Collections, .List, java.util.concurrent.CopyOnWriteArrayList, net.sf.ehcache.pool.Pool, .PoolAccessor, .PoolEvictor, .PoolParticipant, .SizeOfEngine

An abstract pool implementation.

This contains all the logic of a pool except for the actual creation of accessor instances.

Authors
Chris Dennis, Alex Snaps

Field Summary

Modifier and TypeField and Description
private final SizeOfEngine
private final PoolEvictor<T extends PoolParticipant>
private volatile long
private final List<PoolAccessor<T extends PoolParticipant>>
private final List<PoolAccessor<T extends PoolParticipant>>

Constructor Summary

AccessConstructor and Description
public
AbstractPool(long
the maximum size of the pool, in bytes.
maximumPoolSize
,
PoolEvictor<T extends PoolParticipant>
the pool evictor, for cross-store eviction.
evictor
,
SizeOfEngine
the default SizeOf engine used by the accessors.
defaultSizeOfEngine
)

Create an AbstractPool instance

Method Summary

Modifier and TypeMethod and Description
public PoolAccessor<T extends PoolParticipant>
createPoolAccessor(PoolParticipant
the participant which will use the created accessor.
participant
,
int
maximum depth of the object graph to traverse
maxDepth
,
boolean
true if the object traversal should be aborted when the max depth is exceeded
abortWhenMaxDepthExceeded
)

Implements net.sf.ehcache.pool.Pool.createPoolAccessor.

Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.
public PoolEvictor<T extends PoolParticipant>
getEvictor()

Implements net.sf.ehcache.pool.Pool.getEvictor.

Return the pool evictor used by this pool.
public long
getMaxSize()

Implements net.sf.ehcache.pool.Pool.getMaxSize.

Return the maximum size of the pool.
public Collection<PoolAccessor<T extends PoolParticipant>>
getPoolAccessors()

Implements net.sf.ehcache.pool.Pool.getPoolAccessors.

Return the participants accessing this pool.
public long
getSize()

Implements net.sf.ehcache.pool.Pool.getSize.

Return the used size of the pool.
public void
registerPoolAccessor(PoolAccessor<T extends PoolParticipant>
accessor to be registered
accessor
)

Implements net.sf.ehcache.pool.Pool.registerPoolAccessor.

Register an accessor implementation with this pool.
public void
removePoolAccessor(PoolAccessor<T extends PoolParticipant>
accessor to be removed
accessor
)

Implements net.sf.ehcache.pool.Pool.removePoolAccessor.

Remove the supplied accessor from this pool.
public void
setMaxSize(long
the new pool size.
newSize
)

Implements net.sf.ehcache.pool.Pool.setMaxSize.

Change the maximum size of the pool.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultSizeOfEngineback to summary
private final SizeOfEngine defaultSizeOfEngine
evictorback to summary
private final PoolEvictor<T extends PoolParticipant> evictor
maximumPoolSizeback to summary
private volatile long maximumPoolSize
poolAccessorsback to summary
private final List<PoolAccessor<T extends PoolParticipant>> poolAccessors
poolAccessorsViewback to summary
private final List<PoolAccessor<T extends PoolParticipant>> poolAccessorsView

Constructor Detail

AbstractPoolback to summary
public AbstractPool(long maximumPoolSize, PoolEvictor<T extends PoolParticipant> evictor, SizeOfEngine defaultSizeOfEngine)

Create an AbstractPool instance

Parameters
maximumPoolSize:long

the maximum size of the pool, in bytes.

evictor:PoolEvictor<T extends PoolParticipant>

the pool evictor, for cross-store eviction.

defaultSizeOfEngine:SizeOfEngine

the default SizeOf engine used by the accessors.

Method Detail

createPoolAccessorback to summary
public PoolAccessor<T extends PoolParticipant> createPoolAccessor(PoolParticipant participant, int maxDepth, boolean abortWhenMaxDepthExceeded)

Implements net.sf.ehcache.pool.Pool.createPoolAccessor.

Doc from net.sf.ehcache.pool.Pool.createPoolAccessor.

Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.

Parameters
participant:PoolParticipant

the participant which will use the created accessor.

maxDepth:int

maximum depth of the object graph to traverse

abortWhenMaxDepthExceeded:boolean

true if the object traversal should be aborted when the max depth is exceeded

Returns:PoolAccessor<T extends PoolParticipant>

a PoolAccessor whose consumption is tracked by this pool.

getEvictorback to summary
public PoolEvictor<T extends PoolParticipant> getEvictor()

Implements net.sf.ehcache.pool.Pool.getEvictor.

Doc from net.sf.ehcache.pool.Pool.getEvictor.

Return the pool evictor used by this pool.

Returns:PoolEvictor<T extends PoolParticipant>

the pool evictor

getMaxSizeback to summary
public long getMaxSize()

Implements net.sf.ehcache.pool.Pool.getMaxSize.

Doc from net.sf.ehcache.pool.Pool.getMaxSize.

Return the maximum size of the pool.

Returns:long

the maximum size of the pool.

getPoolAccessorsback to summary
public Collection<PoolAccessor<T extends PoolParticipant>> getPoolAccessors()

Implements net.sf.ehcache.pool.Pool.getPoolAccessors.

Doc from net.sf.ehcache.pool.Pool.getPoolAccessors.

Return the participants accessing this pool.

Returns:Collection<PoolAccessor<T extends PoolParticipant>>

participants using this pool

getSizeback to summary
public long getSize()

Implements net.sf.ehcache.pool.Pool.getSize.

Doc from net.sf.ehcache.pool.Pool.getSize.

Return the used size of the pool.

Returns:long

used size of the pool.

registerPoolAccessorback to summary
public void registerPoolAccessor(PoolAccessor<T extends PoolParticipant> accessor)

Implements net.sf.ehcache.pool.Pool.registerPoolAccessor.

Doc from net.sf.ehcache.pool.Pool.registerPoolAccessor.

Register an accessor implementation with this pool.

Parameters
accessor:PoolAccessor<T extends PoolParticipant>

accessor to be registered

removePoolAccessorback to summary
public void removePoolAccessor(PoolAccessor<T extends PoolParticipant> accessor)

Implements net.sf.ehcache.pool.Pool.removePoolAccessor.

Doc from net.sf.ehcache.pool.Pool.removePoolAccessor.

Remove the supplied accessor from this pool.

Parameters
accessor:PoolAccessor<T extends PoolParticipant>

accessor to be removed

setMaxSizeback to summary
public void setMaxSize(long newSize)

Implements net.sf.ehcache.pool.Pool.setMaxSize.

Doc from net.sf.ehcache.pool.Pool.setMaxSize.

Change the maximum size of the pool.

Parameters
newSize:long

the new pool size.