T - accessing store typepublic abstract class AbstractPoolAccessor<T> extends Object implements PoolAccessor<T>
| Modifier and Type | Field and Description |
|---|---|
protected SizeOfEngine |
sizeOfEngine
SizeOfEngine used by the accessor. |
| Constructor and Description |
|---|
AbstractPoolAccessor(Pool<T> pool,
T store,
SizeOfEngine sizeOfEngine)
Creates an accessor for the specified store 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.
|
protected Pool<T> |
getPool()
Return the pool this accessor is associated with.
|
T |
getStore()
Return the store that uses this accessor
|
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, waitdelete, getSizeprotected final SizeOfEngine sizeOfEngine
SizeOfEngine used by the accessor.public AbstractPoolAccessor(Pool<T> pool, T store, SizeOfEngine sizeOfEngine)
pool - pool to be accessedstore - accessing storepublic final long add(Object key, Object value, Object container, boolean force)
add in interface PoolAccessor<T>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<T>key - the key of the elementvalue - the value of the elementcontainer - the element-container objectprotected abstract long add(long sizeOf,
boolean force)
sizeOf - number of bytes to addforce - true if the pool should accept adding the element, even if it's out of resourcesprotected 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<T>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 resourcespublic final void clear()
clear in interface PoolAccessor<T>protected abstract void doClear()
clear().public final void unlink()
unlink in interface PoolAccessor<T>public final T getStore()
getStore in interface PoolAccessor<T>public void setMaxSize(long newValue)
setMaxSize in interface PoolAccessor<T>newValue - the value in bytesprotected final void checkLinked()
throws IllegalStateException
IllegalStateException if this accessor is not linked to it's pool.IllegalStateException - if not linkedprotected final Pool<T> getPool()
public boolean hasAbortedSizeOf()
hasAbortedSizeOf in interface PoolAccessor<T>Copyright © 2003-2014 Terracotta, Inc.. All Rights Reserved.