SolarMetric Kodo JDO 3.3.5 generated on August 31 2005

kodo.datacache
Class AbstractDataCache

java.lang.Object
  |
  +--serp.util.AbstractEventManager
        |
        +--kodo.datacache.AbstractDataCache
All Implemented Interfaces:
com.solarmetric.util.Closeable, Configurable, DataCache
Direct Known Subclasses:
DataCacheImpl, GemFireDataCache, TangosolCache

public abstract class AbstractDataCache
extends serp.util.AbstractEventManager
implements DataCache, Configurable

Abstract DataCache implementation that provides various statistics, logging, and timeout functionality common across cache implementations.


Field Summary
protected  JDOConfiguration conf
          The configuration set by the system.
protected  Log log
          The log to use.
 
Fields inherited from interface kodo.datacache.DataCache
DEFAULT_NAME
 
Constructor Summary
AbstractDataCache()
           
 
Method Summary
 void addExpirationListener(ExpirationListener listen)
          Add a new expiration event listener to this cache.
 void afterCommit(RemoteCommitEvent event)
          This method is part of the RemoteCommitListener interface.
 void clear()
          Remove all data from this cache.
protected abstract  void clearInternal()
          Clear the cache.
 void close()
          Free the resources used by this cache.
 void commit(Collection additions, Collection newUpdates, Collection existingUpdates, Collection deletes)
          Perform a batch update of the cache.
 boolean contains(Object key)
          Returns true if this cache contains data corresponding to oid; otherwise returns false.
 BitSet containsAll(Collection keys)
          Returns the indexes of the oids in this cache.
 void endConfiguration()
          Invoked upon completion of bean property configuration for this object.
protected  void fireEvent(Object event, Object listener)
           
 DataCachePCData get(Object key)
          Return the cached object for the given oid.
 String getEvictionSchedule()
           
 double getHitRate()
          Returns the percentage of hits.
 int getHits()
          Returns the number of cache hits for invocations of the get(java.lang.Object) method.
protected abstract  DataCachePCData getInternal(Object oid)
          Return the object for the given oid.
 int getMisses()
          Returns the number of cache misses for invocations of the get(java.lang.Object) method.
 String getName()
          Returns a string name that can be used by end-user-visible code to identify this cache.
 Collection getStatistics()
          Get statistics exported by this object.
 String getStatisticsString()
          Returns a localized string containing the number of hits, the number of misses, and the hit ratio (hits / (hits+misses)).
 void initialize(DataCacheManager manager)
          Initialize any resources associated with the given DataCacheManager.
 boolean isClosed()
           
protected  void keyRemoved(Object key, boolean expired)
          Invoke when a key is removed from this cache.
 boolean pin(Object key)
          Pin the value stored under oid into the cache.
 BitSet pinAll(Collection keys)
          Pin all oids to the cache.
protected abstract  boolean pinInternal(Object oid)
          Pin an object to the cache.
 DataCachePCData put(DataCachePCData data)
          Set the cached value for the given instance.
protected  void putAllInternal(Collection pcs)
          All all of the given objects to the cache.
protected abstract  DataCachePCData putInternal(Object oid, DataCachePCData pc)
          Add the given object to the cache, returning the old object under the given oid.
protected  boolean recacheUpdates()
          Return true if updates to data already in the cache (either in commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) or the update(kodo.datacache.DataCachePCData)) should be put back into the cache.
 DataCachePCData remove(Object key)
          Remove the value stored under the given oid.
 BitSet removeAll(Collection keys)
          Remove the values stored under the given oids.
protected  void removeAllInternal(Collection oids)
          Remove all objects under the given oids from the cache.
 boolean removeExpirationListener(ExpirationListener listen)
          Remove an expiration event listener from this cache.
protected abstract  DataCachePCData removeInternal(Object oid)
          Remove the object under the given oid from the cache.
 void resetStatistics()
          Reset the caching statistics.
 void setConfiguration(Configuration conf)
          Invoked prior to setting bean properties.
 void setEvictionSchedule(String s)
           
 void setName(String name)
          Sets a string name to be used to identify this cache to end-user needs.
 void startConfiguration()
          Invoked before bean property configuration is begun on this object.
 String toString()
           
 boolean unpin(Object key)
          Unpin the value stored under oid from the cache.
 BitSet unpinAll(Collection keys)
          Unpin all oids from the cache.
protected abstract  boolean unpinInternal(Object oid)
          Unpin an object from the cache.
 void update(DataCachePCData data)
          Update the cached value for the given instance.
 
Methods inherited from class serp.util.AbstractEventManager
fireEvent, getListeners, hasListener, hasListeners, registerListener, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conf

protected JDOConfiguration conf
The configuration set by the system.

log

protected Log log
The log to use.
Constructor Detail

AbstractDataCache

public AbstractDataCache()
Method Detail

getName

public String getName()
Description copied from interface: DataCache
Returns a string name that can be used by end-user-visible code to identify this cache.
Specified by:
getName in interface DataCache

setName

public void setName(String name)
Description copied from interface: DataCache
Sets a string name to be used to identify this cache to end-user needs.
Specified by:
setName in interface DataCache

getEvictionSchedule

public String getEvictionSchedule()

setEvictionSchedule

public void setEvictionSchedule(String s)

initialize

public void initialize(DataCacheManager manager)
Description copied from interface: DataCache
Initialize any resources associated with the given DataCacheManager.
Specified by:
initialize in interface DataCache

commit

public void commit(Collection additions,
                   Collection newUpdates,
                   Collection existingUpdates,
                   Collection deletes)
Description copied from interface: DataCache

Perform a batch update of the cache. Add all DataCachePCData objects in additions and in newUpdates, make the appropriate modifications to all DataCachePCDatas in existingUpdates, and delete all OIDs in deletes.

All changes made to cached data must be made via this method. It is this method that is responsible for performing any side-effects that should happen on meaningful cache changes.

Implementations should bear in mind that the deletes collection may contain oids that are also in the additions map. This is possible because it is valid for a user to delete an object with a particular oid and then add that object in the same batch.

Specified by:
commit in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Parameters:
additions - A collection of DataCachePCData objects. These represent data that have been newly created, and thus must be added to the cache.
newUpdates - A collection of DataCachePCData objects. These represent data that have been modified but were not originally in the cache, and thus must be added to the cache.
existingUpdates - A collection of DataCachePCData objects. These represent data that have been modified and were originally loaded from the cache. It is up to the cache implementation to decide if these values must be re-enlisted in the cache. Some caches may return live data from DataCache.get(java.lang.Object) invocations, in which case these values need not be re-enlisted.
deletes - A collection of object IDs that have been deleted and must therefore be dropped from the cache.

contains

public boolean contains(Object key)
Description copied from interface: DataCache
Returns true if this cache contains data corresponding to oid; otherwise returns false.
Specified by:
contains in interface DataCache

containsAll

public BitSet containsAll(Collection keys)
Description copied from interface: DataCache
Returns the indexes of the oids in this cache.
Specified by:
containsAll in interface DataCache

get

public DataCachePCData get(Object key)
Description copied from interface: DataCache
Return the cached object for the given oid. Modifying the returned object may or may not change the cached value; the DataCache.update(kodo.datacache.DataCachePCData) method should be used to re-cache any changed objects.
Specified by:
get in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
the object matching the given oid, or null if none

put

public DataCachePCData put(DataCachePCData data)
Description copied from interface: DataCache
Set the cached value for the given instance. This does not result in an update of other caches. Rather, it should only be used for loading clean data into the cache. Meaningful changes to the state of the cache should be made via the DataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
Specified by:
put in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
The previously cached value, or null if the value was not previously cached. See Map.put(java.lang.Object, java.lang.Object) for more information.

update

public void update(DataCachePCData data)
Description copied from interface: DataCache

Update the cached value for the given instance. This does not result in an update of other caches. Rather, it should only be used for loading clean data into the cache. Meaningful changes to the state of the cache should be made via the DataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.

A cache implementation may or may not return a live object from DataCache.get(java.lang.Object) invocations. If an object retrieved from a DataCache.get(java.lang.Object) operation needs to be updated, this method can be invoked instead of invoking DataCache.put(kodo.datacache.DataCachePCData). The DataCache implementation can then make optimizations based on how its DataCache.get(java.lang.Object) method works.

Specified by:
update in interface DataCache

remove

public DataCachePCData remove(Object key)
Description copied from interface: DataCache
Remove the value stored under the given oid. This does not result in an update of other caches. Rather, it should only be used for removing data into the cache. Meaningful changes to the state of the cache should be made via the DataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
Specified by:
remove in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
The previously cached value, or null if the oid was not previously cached. See Map.remove(java.lang.Object) for more information.

removeAll

public BitSet removeAll(Collection keys)
Description copied from interface: DataCache
Remove the values stored under the given oids.
Specified by:
removeAll in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
the indexes of the removed oids
See Also:
DataCache.remove(java.lang.Object)

pin

public boolean pin(Object key)
Description copied from interface: DataCache
Pin the value stored under oid into the cache. This method guarantees that oid's value will not be dropped by the caching algorithm. This method does not affect the behavior of DataCache.remove(java.lang.Object).
Specified by:
pin in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was pinned into the cache; false if the oid is not in the cache.

pinAll

public BitSet pinAll(Collection keys)
Description copied from interface: DataCache
Pin all oids to the cache.
Specified by:
pinAll in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
the indexes of the pinned oids
See Also:
DataCache.pin(java.lang.Object)

unpin

public boolean unpin(Object key)
Description copied from interface: DataCache
Unpin the value stored under oid from the cache. This method reverses a previous invocation of DataCache.pin(java.lang.Object). This method does not remove anything from the cache; it merely makes oid's value a candidate for flushing from the cache.
Specified by:
unpin in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was unpinned from the cache; false if the oid is not in the cache.

unpinAll

public BitSet unpinAll(Collection keys)
Description copied from interface: DataCache
Unpin all oids from the cache.
Specified by:
unpinAll in interface DataCache
Following copied from interface: kodo.datacache.DataCache
Returns:
the indexes of the unpinned oids
See Also:
DataCache.unpin(java.lang.Object)

clear

public void clear()
Description copied from interface: DataCache
Remove all data from this cache. This does not result in an update of other caches. Rather, it should only be used for clearing the cache. Meaningful changes to the state of the cache should be made via the DataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
Specified by:
clear in interface DataCache

close

public void close()
Description copied from interface: DataCache
Free the resources used by this cache.
Specified by:
close in interface DataCache

isClosed

public boolean isClosed()

addExpirationListener

public void addExpirationListener(ExpirationListener listen)
Description copied from interface: DataCache
Add a new expiration event listener to this cache.
Specified by:
addExpirationListener in interface DataCache

removeExpirationListener

public boolean removeExpirationListener(ExpirationListener listen)
Description copied from interface: DataCache
Remove an expiration event listener from this cache.
Specified by:
removeExpirationListener in interface DataCache

toString

public String toString()
Overrides:
toString in class Object

afterCommit

public void afterCommit(RemoteCommitEvent event)
This method is part of the RemoteCommitListener interface. If your cache subclass relies on Kodo for clustering support, make it implement RemoteCommitListener. This method will take care of invalidating entries from remote commits.

keyRemoved

protected void keyRemoved(Object key,
                          boolean expired)
Invoke when a key is removed from this cache. Propagates the expiration event on to all expiration listeners registered with this class.

recacheUpdates

protected boolean recacheUpdates()
Return true if updates to data already in the cache (either in commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) or the update(kodo.datacache.DataCachePCData)) should be put back into the cache. Returns false by default.

getInternal

protected abstract DataCachePCData getInternal(Object oid)
Return the object for the given oid.

putInternal

protected abstract DataCachePCData putInternal(Object oid,
                                               DataCachePCData pc)
Add the given object to the cache, returning the old object under the given oid.

putAllInternal

protected void putAllInternal(Collection pcs)
All all of the given objects to the cache.

removeInternal

protected abstract DataCachePCData removeInternal(Object oid)
Remove the object under the given oid from the cache.

removeAllInternal

protected void removeAllInternal(Collection oids)
Remove all objects under the given oids from the cache.

clearInternal

protected abstract void clearInternal()
Clear the cache.

pinInternal

protected abstract boolean pinInternal(Object oid)
Pin an object to the cache.

unpinInternal

protected abstract boolean unpinInternal(Object oid)
Unpin an object from the cache.

getHits

public int getHits()
Returns the number of cache hits for invocations of the get(java.lang.Object) method.

getMisses

public int getMisses()
Returns the number of cache misses for invocations of the get(java.lang.Object) method.

getHitRate

public double getHitRate()
Returns the percentage of hits.

getStatisticsString

public String getStatisticsString()
Returns a localized string containing the number of hits, the number of misses, and the hit ratio (hits / (hits+misses)).

getStatistics

public Collection getStatistics()
Get statistics exported by this object.

resetStatistics

public void resetStatistics()
Reset the caching statistics.

setConfiguration

public void setConfiguration(Configuration conf)
Description copied from interface: Configurable
Invoked prior to setting bean properties.
Specified by:
setConfiguration in interface Configurable

startConfiguration

public void startConfiguration()
Description copied from interface: Configurable
Invoked before bean property configuration is begun on this object.
Specified by:
startConfiguration in interface Configurable

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of bean property configuration for this object.
Specified by:
endConfiguration in interface Configurable

fireEvent

protected void fireEvent(Object event,
                         Object listener)
Overrides:
fireEvent in class serp.util.AbstractEventManager

SolarMetric Kodo JDO 3.3.5 generated on August 31 2005

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.