|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.perseus.cache.lib.BasicCacheManager
This class is an implementation of a cache. The data structure is a Hahsed map between cache entry identifier and an entry instance. This class is a fractal component.
Nested Class Summary | |
protected class |
BasicCacheManager.CapacityEvent
This class is a basic implementation of the CacheCapacityEvent interface. |
protected class |
BasicCacheManager.Event
This class is a basic implementation of the CacheEvent interface. |
Field Summary | |
protected Logger |
bgclogger
|
protected java.util.Map |
cache
This field is the cache. |
static java.lang.String |
CACHE_CAPACTITY_LISTENER_BINDING
|
static java.lang.String |
CACHE_ENTRY_FACTORY_BINDING
|
static java.lang.String |
CACHE_LISTENER_BINDING
|
protected int |
cacheMaxSize
This field is the max size of the cache. |
protected int |
cacheThresHold
|
protected java.lang.String |
cacheThresHoldStr
|
protected java.util.HashMap |
ccels
This field is the list of CacheEventListener registered. |
protected CacheEntryFactory |
cef
This field is the factory of CacheEntry instances. |
protected java.util.HashMap |
cels
This field is the list of CacheEventListener registered. |
static java.lang.String |
DEFAULT_AUTO_CLEAN_SIZE
|
protected Logger |
logger
|
protected java.lang.ref.ReferenceQueue |
queue
Queue used to register the weak references stored in the cache. |
static java.lang.String |
REPLACEMENT_MANAGER_BINDING
|
protected ReplacementManager |
rm
|
Fields inherited from interface org.objectweb.perseus.cache.api.CacheAttributeController |
NO_LIMIT |
Constructor Summary | |
BasicCacheManager()
It builds a BasicCacheManager with an empty CacheEventListener list, an empty cache and the default max size. |
Method Summary | |
CacheEntry |
bind(java.lang.Object id,
java.lang.Object object)
This method allows a in-memory object (incarnation) to be placed in the cache. |
void |
bindFc(java.lang.String s,
java.lang.Object o)
|
void |
fix(CacheEntry _ce)
This method notifies the cache manager the intention to use the object identified by lid. |
void |
fix(CacheEntryFilter filter)
This method notifies the cache manager the intention to use objects in the cache. |
java.lang.String |
getAutoCleanSize()
|
java.lang.String |
getAutoCleanThreshold()
|
BackgroundCleaner |
getBgcleaner()
|
java.util.Collection |
getCurrentEntryIdentifiers()
|
int |
getCurrentMemorySize()
|
int |
getCurrentSize()
|
java.lang.String |
getFcState()
|
int |
getMaxObjects()
This method retrieves the maximum number of objects to be held by the cache. |
int |
getMemorySize()
This method returns the maximum main-memory size allocated to the cache. |
java.lang.String[] |
listFc()
|
CacheEntry |
lookup(java.lang.Object id)
This method searches the object, identified by lid, within the cache. |
java.lang.Object |
lookupFc(java.lang.String s)
|
void |
setAutoCleanSize(java.lang.String size)
Assignes the number of element which can be removed when the cache is full. |
void |
setAutoCleanThreshold(java.lang.String size)
Assignes the cache size value since the cache try to decrease the number of entries. |
void |
setMaxObjects(int size)
This method allows to set the maximum number of objects to be held by the cache manager. |
void |
setMemorySize(int size)
This method allows to set the maximum main-memory size allocated to the cache. |
void |
startFc()
|
void |
stopFc()
|
void |
touch(CacheEntry ce)
Called whenever an object has been accessed. |
java.util.Collection |
unbind(CacheEntryFilter filter,
boolean force)
Evicts the entries which are accepted by the filter. |
boolean |
unbind(java.lang.Object oid,
boolean force)
Evicts an instance from the cache. |
java.util.Collection |
unbindAll(java.util.Collection oids,
boolean force)
Evicts instances from the cache. |
void |
unbindFc(java.lang.String s)
|
java.util.Collection |
unbindUnfixed(boolean force)
Try to evict unfixed instances. |
void |
unfix(CacheEntry ce)
This method is used to notify the cache manager that the object identified by lid is not longer to be used. |
void |
unfix(CacheEntryFilter filter)
This method is used to notify the cache manager that objects are not longer to be used. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String DEFAULT_AUTO_CLEAN_SIZE
public static final java.lang.String CACHE_ENTRY_FACTORY_BINDING
public static final java.lang.String REPLACEMENT_MANAGER_BINDING
public static final java.lang.String CACHE_LISTENER_BINDING
public static final java.lang.String CACHE_CAPACTITY_LISTENER_BINDING
protected CacheEntryFactory cef
protected ReplacementManager rm
protected java.util.Map cache
protected java.lang.ref.ReferenceQueue queue
protected int cacheMaxSize
protected int cacheThresHold
protected java.lang.String cacheThresHoldStr
protected Logger logger
protected Logger bgclogger
protected java.util.HashMap cels
protected java.util.HashMap ccels
Constructor Detail |
public BasicCacheManager()
Method Detail |
public BackgroundCleaner getBgcleaner()
public java.lang.String getFcState()
public void startFc()
public void stopFc()
public java.lang.String[] listFc()
public java.lang.Object lookupFc(java.lang.String s)
public void bindFc(java.lang.String s, java.lang.Object o)
public void unbindFc(java.lang.String s)
public void setMaxObjects(int size) throws java.lang.IllegalArgumentException, CacheException
CacheAttributeController
setMaxObjects
in interface CacheAttributeController
size
- The maximum number of objects to be held in cache.
(It must be a positive number).
java.lang.IllegalArgumentException
- if the size is invalid (e.g. negative).
CacheException
- if it is not possible to reduce the cache size
because all entries are fixed.public int getMaxObjects()
CacheAttributeController
getMaxObjects
in interface CacheAttributeController
public int getCurrentSize()
getCurrentSize
in interface CacheAttributeController
public java.util.Collection getCurrentEntryIdentifiers()
getCurrentEntryIdentifiers
in interface CacheAttributeController
public void setMemorySize(int size) throws java.lang.IllegalArgumentException
CacheAttributeController
setMemorySize
in interface CacheAttributeController
size
- The maximum memory size.
(It must be a positive number).
java.lang.IllegalArgumentException
- if the size is invalid (e.g. negative).public int getMemorySize()
CacheAttributeController
getMemorySize
in interface CacheAttributeController
public int getCurrentMemorySize()
getCurrentMemorySize
in interface CacheAttributeController
public void setAutoCleanSize(java.lang.String size)
CacheAttributeController
setAutoCleanSize
in interface CacheAttributeController
public java.lang.String getAutoCleanSize()
getAutoCleanSize
in interface CacheAttributeController
public void setAutoCleanThreshold(java.lang.String size)
CacheAttributeController
setAutoCleanThreshold
in interface CacheAttributeController
public java.lang.String getAutoCleanThreshold()
getAutoCleanThreshold
in interface CacheAttributeController
public CacheEntry bind(java.lang.Object id, java.lang.Object object) throws CacheException
CacheManager
bind
in interface CacheManager
id
- The corresponding object identifier.
(It must be generated elsewhere, e.g. by a naming
service).object
- The object to be cached.
CacheException
- If object/lid are already registered
or either object or lid are null.public CacheEntry lookup(java.lang.Object id)
CacheManager
lookup
in interface CacheManager
id
- The corresponding object identifier.
public void fix(CacheEntry _ce) throws CacheException
CacheManager
fix
in interface CacheManager
_ce
-
CacheException
- If the object is not in the cache.public void fix(CacheEntryFilter filter) throws CacheException
CacheManager
fix
in interface CacheManager
filter
-
CacheException
- If the object is not in the cache.public void unfix(CacheEntry ce) throws CacheException
CacheManager
unfix
in interface CacheManager
ce
-
CacheException
- If the object has not been previously fixed.public void unfix(CacheEntryFilter filter) throws CacheException
CacheManager
unfix
in interface CacheManager
filter
- indicates which instances have to be unfixed among entries
in the cache.
CacheException
- If the object has not been previously fixed.public void touch(CacheEntry ce) throws CacheException
CacheManager
touch
in interface CacheManager
ce
- The cache entry that has been accessed.
CacheException
- Whenever an internal error occurs.public boolean unbind(java.lang.Object oid, boolean force) throws CacheException
UnbindManager
unbind
in interface UnbindManager
oid
- is the identifier associated to the cache entry to evictforce
- is a boolean value indicating if the cache must remove the
entry or let the GC does its job.
CacheException
- is raised when the entry is already unbound from
the cache.public java.util.Collection unbind(CacheEntryFilter filter, boolean force) throws CacheException
UnbindManager
unbind
in interface UnbindManager
filter
- is a cacheentry filter indicating wich entry has to be
evictedforce
- is a boolean value indicating if the cache must remove the
entries or let the GC does its job.
CacheException
public java.util.Collection unbindAll(java.util.Collection oids, boolean force) throws CacheException
UnbindManager
unbindAll
in interface UnbindManager
oids
- is a collection of the identifier associated to cache entries
to evictforce
- is a boolean value indicating if the cache must remove the
entries or let the GC does its job.
CacheException
- is raised when entries are already unbound from
the cache.public java.util.Collection unbindUnfixed(boolean force) throws CacheException
UnbindManager
unbindUnfixed
in interface UnbindManager
force
- is a boolean value indicating if the cache must remove the
entries or let the GC does its job.
CacheException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |