public abstract class AbstractPoolAccessor extends Object implements PoolAccessor<PoolParticipant>
Modifier and Type | Field and Description |
---|---|
protected SizeOfEngine |
sizeOfEngine
SizeOfEngine used by the accessor. |
Constructor and Description |
---|
AbstractPoolAccessor(Pool pool,
PoolParticipant participant,
SizeOfEngine sizeOfEngine)
Creates an accessor for the specified participant to access the specified pool.
|
Modifier and Type | Method and Description |
---|---|
protected abstract long |
add(long sizeOf,
boolean force)
Add a specific number of bytes to the pool.
|
long |
add(Object key,
Object value,
Object container,
boolean force)
Add an element to the pool.
|
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
|
boolean |
canAddWithoutEvicting(Object key,
Object value,
Object container)
Check if there is enough room in the pool to add an element without provoking any eviction
|
protected void |
checkLinked()
Throws
IllegalStateException if this accessor is not linked to it's pool. |
void |
clear()
Free resources used by this accessor.
|
protected abstract void |
doClear()
Free resources used by this accessor.
|
PoolParticipant |
getParticipant()
Return the store that uses this accessor
|
protected Pool |
getPool()
Return the pool this accessor is associated with.
|
long |
getPoolOccupancy()
Returns the occupied size for this pool.
|
long |
getPoolSize()
Returns the size of this pool.
|
boolean |
hasAbortedSizeOf()
Check if the store may contain elements which the SizeOf engine could not fully size.
|
long |
replace(long currentSize,
Object key,
Object value,
Object container,
boolean force)
Delete a fixed number of bytes from the pool with the given objects.
|
void |
setMaxSize(long newValue)
Sets the max size for this pool
|
void |
unlink()
unlink this PoolAccessor from its pool.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
delete, getSize
protected final SizeOfEngine sizeOfEngine
SizeOfEngine
used by the accessor.public AbstractPoolAccessor(Pool pool, PoolParticipant participant, SizeOfEngine sizeOfEngine)
pool
- pool to be accessedparticipant
- accessing participantpublic final long add(Object key, Object value, Object container, boolean force)
add
in interface PoolAccessor<PoolParticipant>
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 resourcespublic final boolean canAddWithoutEvicting(Object key, Object value, Object container)
canAddWithoutEvicting
in interface PoolAccessor<PoolParticipant>
key
- the key of the elementvalue
- the value of the elementcontainer
- the element-container objectprotected abstract long add(long sizeOf, boolean force) throws IllegalArgumentException
sizeOf
- number of bytes to addforce
- true if the pool should accept adding the element, even if it's out of resourcesIllegalArgumentException
- when sizeOf is negativeprotected abstract boolean canAddWithoutEvicting(long sizeOf)
sizeOf
- number of bytes to test againstpublic final long replace(long currentSize, Object key, Object value, Object container, boolean force)
replace
in interface PoolAccessor<PoolParticipant>
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 resourcesLong.MIN_VALUE
if replace failed.public final void clear()
clear
in interface PoolAccessor<PoolParticipant>
protected abstract void doClear()
clear()
.public final void unlink()
unlink
in interface PoolAccessor<PoolParticipant>
public final PoolParticipant getParticipant()
getParticipant
in interface PoolAccessor<PoolParticipant>
public void setMaxSize(long newValue)
setMaxSize
in interface PoolAccessor<PoolParticipant>
newValue
- the value in bytespublic long getPoolOccupancy()
getPoolOccupancy
in interface PoolAccessor<PoolParticipant>
public long getPoolSize()
getPoolSize
in interface PoolAccessor<PoolParticipant>
protected final void checkLinked() throws IllegalStateException
IllegalStateException
if this accessor is not linked to it's pool.IllegalStateException
- if not linkedprotected final Pool getPool()
public boolean hasAbortedSizeOf()
hasAbortedSizeOf
in interface PoolAccessor<PoolParticipant>
Copyright © 2003–2016 Terracotta, Inc.. All rights reserved.