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

public abstract Class AbstractPoolAccessor

extends Object
implements PoolAccessor<PoolParticipant>
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.pool.PoolAccessor
Known Direct Subclasses
net.sf.ehcache.pool.impl.AtomicPoolAccessor, net.sf.ehcache.pool.impl.LockedPoolAccessor
Imports
java.util.concurrent.atomic.AtomicBoolean, net.sf.ehcache.pool.Pool, .PoolAccessor, .PoolParticipant, .Size, .SizeOfEngine

Abstract PoolAccessor implementation providing pool to store binding functionality.
Authors
Chris Dennis, Alex Snaps

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final Pool
private final PoolParticipant
protected final SizeOfEngine
sizeOfEngine

SizeOfEngine used by the accessor.

private final AtomicBoolean

Constructor Summary

AccessConstructor and Description
public
AbstractPoolAccessor(Pool
pool to be accessed
pool
,
PoolParticipant
accessing participant
participant
,
SizeOfEngine sizeOfEngine)

Creates an accessor for the specified participant to access the specified pool.

Method Summary

Modifier and TypeMethod and Description
public final long
add(Object
the key of the element
key
,
Object
the value of the element
value
,
Object
the element-container object
container
,
boolean
true if the pool should accept adding the element, even if it's out of resources
force
)

Implements net.sf.ehcache.pool.PoolAccessor.add.

Add an element to the pool.
protected abstract long

Returns:

how many bytes have been added to the pool or -1 if add failed.
add
(long
number of bytes to add
sizeOf
,
boolean
true if the pool should accept adding the element, even if it's out of resources
force
)

Add a specific number of bytes to the pool.

public final boolean
canAddWithoutEvicting(Object
the key of the element
key
,
Object
the value of the element
value
,
Object
the element-container object
container
)

Implements net.sf.ehcache.pool.PoolAccessor.canAddWithoutEvicting.

Check if there is enough room in the pool to add an element without provoking any eviction
protected abstract boolean

Returns:

true if there is enough room left
canAddWithoutEvicting
(long
number of bytes to test against
sizeOf
)

Check if there is enough room in the pool to add a specific number of bytes without provoking any eviction

protected final void
checkLinked()

Throws IllegalStateException if this accessor is not linked to it's pool.

public final void
clear()

Implements net.sf.ehcache.pool.PoolAccessor.clear.

Free resources used by this accessor.
protected abstract void
doClear()

Free resources used by this accessor.

public final PoolParticipant
getParticipant()

Implements net.sf.ehcache.pool.PoolAccessor.getParticipant.

Return the store that uses this accessor
protected final Pool

Returns:

associated pool
getPool
()

Return the pool this accessor is associated with.

public long
getPoolOccupancy()

Implements net.sf.ehcache.pool.PoolAccessor.getPoolOccupancy.

Returns the occupied size for this pool.
public long
getPoolSize()

Implements net.sf.ehcache.pool.PoolAccessor.getPoolSize.

Returns the size of this pool.
public boolean
hasAbortedSizeOf()

Implements net.sf.ehcache.pool.PoolAccessor.hasAbortedSizeOf.

Check if the store may contain elements which the SizeOf engine could not fully size.
public final long
replace(long
the size of the object(s) being replaced
currentSize
,
Object
the key of the element
key
,
Object
the value of the element
value
,
Object
the element-container object
container
,
boolean
true if the pool should accept replacing the element, even if it's out of resources
force
)

Implements net.sf.ehcache.pool.PoolAccessor.replace.

Delete a fixed number of bytes from the pool with the given objects.
public void
setMaxSize(final long
the value in bytes
newValue
)

Implements net.sf.ehcache.pool.PoolAccessor.setMaxSize.

Sets the max size for this pool
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

abortedSizeOfback to summary
private volatile boolean abortedSizeOf
poolback to summary
private final Pool pool
poolParticipantback to summary
private final PoolParticipant poolParticipant
sizeOfEngineback to summary
protected final SizeOfEngine sizeOfEngine

SizeOfEngine used by the accessor.

unlinkedback to summary
private final AtomicBoolean unlinked

Constructor Detail

AbstractPoolAccessorback to summary
public AbstractPoolAccessor(Pool pool, PoolParticipant participant, SizeOfEngine sizeOfEngine)

Creates an accessor for the specified participant to access the specified pool.

Parameters
pool:Pool

pool to be accessed

participant:PoolParticipant

accessing participant

Method Detail

addback to summary
public final long add(Object key, Object value, Object container, boolean force)

Implements net.sf.ehcache.pool.PoolAccessor.add.

Doc from net.sf.ehcache.pool.PoolAccessor.add.

Add an element to the pool.

Parameters
key:Object

the key of the element

value:Object

the value of the element

container:Object

the element-container object

force:boolean

true if the pool should accept adding the element, even if it's out of resources

Returns:long

how many bytes have been added to the pool or -1 if add failed.

addback to summary
protected abstract long add(long sizeOf, boolean force) throws IllegalArgumentException

Add a specific number of bytes to the pool.

Parameters
sizeOf:long

number of bytes to add

force:boolean

true if the pool should accept adding the element, even if it's out of resources

Returns:long

how many bytes have been added to the pool or -1 if add failed.

Exceptions
IllegalArgumentException:
when sizeOf is negative
canAddWithoutEvictingback to summary
public final boolean canAddWithoutEvicting(Object key, Object value, Object container)

Implements net.sf.ehcache.pool.PoolAccessor.canAddWithoutEvicting.

Doc from net.sf.ehcache.pool.PoolAccessor.canAddWithoutEvicting.

Check if there is enough room in the pool to add an element without provoking any eviction

Parameters
key:Object

the key of the element

value:Object

the value of the element

container:Object

the element-container object

Returns:boolean

true if there is enough room left

canAddWithoutEvictingback to summary
protected abstract boolean canAddWithoutEvicting(long sizeOf)

Check if there is enough room in the pool to add a specific number of bytes without provoking any eviction

Parameters
sizeOf:long

number of bytes to test against

Returns:boolean

true if there is enough room left

checkLinkedback to summary
protected final void checkLinked() throws IllegalStateException

Throws IllegalStateException if this accessor is not linked to it's pool.

Exceptions
IllegalStateException:
if not linked
clearback to summary
public final void clear()

Implements net.sf.ehcache.pool.PoolAccessor.clear.

Doc from net.sf.ehcache.pool.PoolAccessor.clear.

Free resources used by this accessor.

doClearback to summary
protected abstract void doClear()

Free resources used by this accessor. This method is called by clear().

getParticipantback to summary
public final PoolParticipant getParticipant()

Implements net.sf.ehcache.pool.PoolAccessor.getParticipant.

Doc from net.sf.ehcache.pool.PoolAccessor.getParticipant.

Return the store that uses this accessor

Returns:PoolParticipant

store using this accessor

getPoolback to summary
protected final Pool getPool()

Return the pool this accessor is associated with.

Returns:Pool

associated pool

getPoolOccupancyback to summary
public long getPoolOccupancy()

Implements net.sf.ehcache.pool.PoolAccessor.getPoolOccupancy.

Doc from net.sf.ehcache.pool.PoolAccessor.getPoolOccupancy.

Returns the occupied size for this pool.

Returns:long

occupied pool size

getPoolSizeback to summary
public long getPoolSize()

Implements net.sf.ehcache.pool.PoolAccessor.getPoolSize.

Doc from net.sf.ehcache.pool.PoolAccessor.getPoolSize.

Returns the size of this pool.

Returns:long

pool size

hasAbortedSizeOfback to summary
public boolean hasAbortedSizeOf()

Implements net.sf.ehcache.pool.PoolAccessor.hasAbortedSizeOf.

Doc from net.sf.ehcache.pool.PoolAccessor.hasAbortedSizeOf.

Check if the store may contain elements which the SizeOf engine could not fully size.

Returns:boolean

true if the store may contain partially sized objects

replaceback to summary
public final long replace(long currentSize, Object key, Object value, Object container, boolean force)

Implements net.sf.ehcache.pool.PoolAccessor.replace.

Doc from net.sf.ehcache.pool.PoolAccessor.replace.

Delete a fixed number of bytes from the pool with the given objects.

Parameters
currentSize:long

the size of the object(s) being replaced

key:Object

the key of the element

value:Object

the value of the element

container:Object

the element-container object

force:boolean

true if the pool should accept replacing the element, even if it's out of resources

Returns:long

the change in size of the pool, or Long#MIN_VALUE if replace failed.

setMaxSizeback to summary
public void setMaxSize(final long newValue)

Implements net.sf.ehcache.pool.PoolAccessor.setMaxSize.

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

Sets the max size for this pool

Parameters
newValue:long

the value in bytes