Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net.partition
Class ObservableSplittingBackingCache

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractKeyBasedMap
          extended by com.tangosol.util.AbstractKeySetBasedMap
              extended by com.tangosol.util.WrapperObservableMap
                  extended by com.tangosol.net.partition.ObservableSplittingBackingMap
                      extended by com.tangosol.net.partition.ObservableSplittingBackingCache

All Implemented Interfaces:
CacheMap, ConfigurableCacheMap, PartitionAwareBackingMap, ObservableMap, java.util.Map

public class ObservableSplittingBackingCache
extends ObservableSplittingBackingMap
implements ConfigurableCacheMap

The ObservableSplittingBackingCache is an implementation of the ConfigurableCacheMap interface that works as an observable backing map in a partitioned system. In other words, it acts like a LocalCache, but it internally partitions its data across any number of caches that implement the ConfigurableCacheMap interface. Note that the underlying backing maps must implement the ConfigurableCacheMap interface or a runtime exception will occur.

Author:
cp 2009.01.16

Nested Class Summary
 class ObservableSplittingBackingCache.EntrySet
          A set of ConfigurableCacheMap entries backed by this map.

 

Nested classes/interfaces inherited from class com.tangosol.util.WrapperObservableMap
WrapperObservableMap.InternalListener

 

Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap
AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection

 

Nested classes/interfaces inherited from interface com.tangosol.net.cache.ConfigurableCacheMap
ConfigurableCacheMap.Entry, ConfigurableCacheMap.EvictionPolicy, ConfigurableCacheMap.UnitCalculator

 

Field Summary
protected  ConfigurableCacheMap[] m_acache
          A cached array of the backing ConfigurableCacheMap instances.
protected  ConfigurableCacheMap.UnitCalculator m_calculator
          The unit calculator.
protected  int m_cExpiryDelayMillis
          The expiry delay.
protected  int m_cFlushDelayMillis
          The flush delay.
protected  int m_cHighUnits
          High units is the number of units that triggers eviction.
protected  int m_cLowUnits
          Low units is the number of units to evict down to.
protected  int m_nUnitFactor
          The unit factor.
protected  ConfigurableCacheMap.EvictionPolicy m_policy
          The eviction policy.
protected static int PROP_HIGH_UNITS
          The "HighUnits" property.
protected static int PROP_LOW_UNITS
          The "LowUnits" property.
protected static int PROP_UNITS
          The "Units" property.

 

Fields inherited from class com.tangosol.util.WrapperObservableMap
m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_stats

 

Fields inherited from interface com.tangosol.net.cache.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER

 

Constructor Summary
ObservableSplittingBackingCache(BackingMapManager bmm, java.lang.String sName)
          Create a ObservableSplittingBackingCache that adds ConfigurableCacheMap functionality to an ObservableSplittingBackingMap.

 

Method Summary
protected  int calculateUnits(int nProp)
          Aggregate the number of units across all of the partition backing maps.
 void createPartition(int nPid)
          Add a partition to the PartitionAwareBackingMap.
 void destroyPartition(int nPid)
          Remove a partition from the PartitionAwareBackingMap.
 void evict()
          Evict all entries from the cache that are no longer valid, and potentially prune the cache size if the cache is size-limited and its size is above the caching low water mark.
 void evict(java.lang.Object oKey)
          Evict a specified key from the cache, as if it had expired from the cache.
 void evictAll(java.util.Collection colKeys)
          Evict the specified keys from the cache, as if they had each expired from the cache.
 ConfigurableCacheMap.Entry getCacheEntry(java.lang.Object oKey)
          Locate a cache Entry in the cache based on its key.
 ConfigurableCacheMap.EvictionPolicy getEvictionPolicy()
          Obtain the current EvictionPolicy used by the cache.
 int getExpiryDelay()
          Determine the default "time to live" for each individual cache entry.
protected  ConfigurableCacheMap getFirstPartitionCache()
          Obtain the first one of the backing caches.
 int getFlushDelay()
          Determine the delay between cache flushes.
 int getHighUnits()
          Determine the limit of the cache size in units.
 int getLowUnits()
          Determine the point to which the cache will shrink when it prunes.
protected  ConfigurableCacheMap getPartitionCache(java.lang.Object oKey)
          Obtain the backing cache for a particular key.
protected  ConfigurableCacheMap[] getPartitionCacheArray()
          Obtain the array of backing caches.
 ConfigurableCacheMap.UnitCalculator getUnitCalculator()
          Obtain the current UnitCalculator used by the cache.
 int getUnitFactor()
          Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted.
 int getUnits()
          Determine the number of units that the cache currently stores.
protected  java.util.Set instantiateEntrySet()
          Factory pattern: Create a Set that represents the entries in the Map.
protected  void partitionUnits(int nProp)
          Partition out the high or low units across all of the backing maps.
protected  void repartition()
          Repartition the units across the backing maps.
 void setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
          Set the EvictionPolicy for the cache to use.
 void setExpiryDelay(int cMillis)
          Specify the default "time to live" for cache entries.
 void setFlushDelay(int cMillis)
          Specify the delay between cache flushes.
 void setHighUnits(int cMax)
          Update the maximum size of the cache in units.
 void setLowUnits(int cUnits)
          Specify the point to which the cache will shrink when it prunes.
 void setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
          Set the UnitCalculator for the cache to use.
 void setUnitFactor(int nFactor)
          Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted.

 

Methods inherited from class com.tangosol.net.partition.ObservableSplittingBackingMap
addMapListener, addMapListener, getBackingMapManager, getCacheStatistics, getName, getPartitionMap, getPartitionMap, getPartitionSplittingBackingMap, isCollectStats, isEventFabricator, put, removeMapListener, removeMapListener, setTranslateEvents, toString

 

Methods inherited from class com.tangosol.util.WrapperObservableMap
addMapListener, clear, containsValue, dispatchEvent, dispatchPendingEvent, ensureInternalListener, ensureMapListenerSupport, get, getDescription, getInternalKeySet, getMap, getMapListenerSupport, hasListeners, instantiateInternalListener, isInternalKeySetIteratorMutable, isSynthetic, isTranslateEvents, put, putAll, remove, removeBlind, removeMapListener, setCollectStats

 

Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap
containsKey, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size

 

Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clone, entrySet, equals, getAll, hashCode, keySet, values

 

Methods inherited from interface com.tangosol.net.cache.CacheMap
getAll, put, put

 

Methods inherited from interface com.tangosol.util.ObservableMap
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener

 

Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values

 

Field Detail

PROP_UNITS

protected static final int PROP_UNITS
The "Units" property.
See Also:
Constant Field Values

PROP_HIGH_UNITS

protected static final int PROP_HIGH_UNITS
The "HighUnits" property.
See Also:
Constant Field Values

PROP_LOW_UNITS

protected static final int PROP_LOW_UNITS
The "LowUnits" property.
See Also:
Constant Field Values

m_cHighUnits

protected int m_cHighUnits
High units is the number of units that triggers eviction. The value -1 indicates that this cache has not been instructed to override the high units of the underlying caches.

m_cLowUnits

protected int m_cLowUnits
Low units is the number of units to evict down to. The value -1 indicates that this cache has not been instructed to override the low units of the underlying caches.

m_nUnitFactor

protected int m_nUnitFactor
The unit factor. The value -1 indicates that this cache has not been instructed to override the unit factor of the underlying caches.

m_cExpiryDelayMillis

protected int m_cExpiryDelayMillis
The expiry delay. The value -1 indicates that this cache has not been instructed to override the expiry delay of the underlying caches.

m_cFlushDelayMillis

protected int m_cFlushDelayMillis
The flush delay. The value -1 indicates that this cache has not been instructed to override the flush delay of the underlying caches.

m_policy

protected ConfigurableCacheMap.EvictionPolicy m_policy
The eviction policy. The value of null indicates that this cache has not been instructed to override the eviction policy of the underlying caches.

m_calculator

protected ConfigurableCacheMap.UnitCalculator m_calculator
The unit calculator. The value of null indicates that this cache has not been instructed to override the unit calculator of the underlying caches.

m_acache

protected ConfigurableCacheMap[] m_acache
A cached array of the backing ConfigurableCacheMap instances.

Constructor Detail

ObservableSplittingBackingCache

public ObservableSplittingBackingCache(BackingMapManager bmm,
                                       java.lang.String sName)
Create a ObservableSplittingBackingCache that adds ConfigurableCacheMap functionality to an ObservableSplittingBackingMap.
Parameters:
bmm - a callback that knows how to create and release the backing maps that this ObservableSplittingBackingCache is responsible for
sName - the cache name for which this backing map exists

Method Detail

createPartition

public void createPartition(int nPid)
Add a partition to the PartitionAwareBackingMap.
Specified by:
createPartition in interface PartitionAwareBackingMap
Overrides:
createPartition in class ObservableSplittingBackingMap
Parameters:
nPid - the partition id that the PartitionAwareBackingMap will be responsible for, starting at this instant

destroyPartition

public void destroyPartition(int nPid)
Remove a partition from the PartitionAwareBackingMap.
Specified by:
destroyPartition in interface PartitionAwareBackingMap
Overrides:
destroyPartition in class ObservableSplittingBackingMap
Parameters:
nPid - the partition id that the PartitionAwareBackingMap will no longer be responsible for, starting at this instant

getUnits

public int getUnits()
Determine the number of units that the cache currently stores.

Note: It is expected that the return type will be widened to a long in Coherence 4.

Specified by:
getUnits in interface ConfigurableCacheMap
Returns:
the current size of the cache in units

getHighUnits

public int getHighUnits()
Determine the limit of the cache size in units. The cache will prune itself automatically once it reaches its maximum unit level. This is often referred to as the "high water mark" of the cache.

Note: It is expected that the return type will be widened to a long in Coherence 4.

Specified by:
getHighUnits in interface ConfigurableCacheMap
Returns:
the limit of the cache size in units

setHighUnits

public void setHighUnits(int cMax)
Update the maximum size of the cache in units. This is often referred to as the "high water mark" of the cache.

Note: It is expected that the parameter will be widened to a long in Coherence 4.

Specified by:
setHighUnits in interface ConfigurableCacheMap
Parameters:
cMax - the new maximum size of the cache, in units

getLowUnits

public int getLowUnits()
Determine the point to which the cache will shrink when it prunes. This is often referred to as a "low water mark" of the cache. If the cache incrementally prunes, then this setting will have no effect.

Note: It is expected that the parameter will be widened to a long in Coherence 4.

Specified by:
getLowUnits in interface ConfigurableCacheMap
Returns:
the number of units that the cache prunes to

setLowUnits

public void setLowUnits(int cUnits)
Specify the point to which the cache will shrink when it prunes. This is often referred to as a "low water mark" of the cache.

Note: It is expected that the parameter will be widened to a long in Coherence 4.

Specified by:
setLowUnits in interface ConfigurableCacheMap
Parameters:
cUnits - the number of units that the cache prunes to

getUnitFactor

public int getUnitFactor()
Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. Using a binary unit calculator, for example, the factor 1048576 could be used to count megabytes instead of bytes.

Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.

Specified by:
getUnitFactor in interface ConfigurableCacheMap
Returns:
the units factor; the default is 1

setUnitFactor

public void setUnitFactor(int nFactor)
Determine the factor by which the Units, LowUnits and HighUnits properties are adjusted. Using a binary unit calculator, for example, the factor 1048576 could be used to count megabytes instead of bytes.

Note: This property exists only to avoid changing the type of the units, low units and high units properties from 32-bit values to 64-bit values. It is expected that the parameter will be dropped in Coherence 4.

Specified by:
setUnitFactor in interface ConfigurableCacheMap
Parameters:
nFactor - the units factor; the default is 1

getEvictionPolicy

public ConfigurableCacheMap.EvictionPolicy getEvictionPolicy()
Obtain the current EvictionPolicy used by the cache.
Specified by:
getEvictionPolicy in interface ConfigurableCacheMap
Returns:
the EvictionPolicy used by the cache

setEvictionPolicy

public void setEvictionPolicy(ConfigurableCacheMap.EvictionPolicy policy)
Set the EvictionPolicy for the cache to use.
Specified by:
setEvictionPolicy in interface ConfigurableCacheMap
Parameters:
policy - an EvictionPolicy

evict

public void evict(java.lang.Object oKey)
Evict a specified key from the cache, as if it had expired from the cache. If the key is not in the cache, then the method has no effect.
Specified by:
evict in interface ConfigurableCacheMap
Parameters:
oKey - the key to evict from the cache

evictAll

public void evictAll(java.util.Collection colKeys)
Evict the specified keys from the cache, as if they had each expired from the cache.

The result of this method is defined to be semantically the same as the following implementation:


 for (Iterator iter = colKeys.iterator(); iter.hasNext(); )
     {
     Object oKey = iter.next();
     evict(oKey);
     }
 
Specified by:
evictAll in interface ConfigurableCacheMap
Parameters:
colKeys - a collection of keys to evict from the cache

evict

public void evict()
Evict all entries from the cache that are no longer valid, and potentially prune the cache size if the cache is size-limited and its size is above the caching low water mark.
Specified by:
evict in interface ConfigurableCacheMap

getExpiryDelay

public int getExpiryDelay()
Determine the default "time to live" for each individual cache entry.
Specified by:
getExpiryDelay in interface ConfigurableCacheMap
Returns:
the number of milliseconds that a cache entry value will live, or zero if cache entries are never automatically expired

setExpiryDelay

public void setExpiryDelay(int cMillis)
Specify the default "time to live" for cache entries. This does not affect the already-scheduled expiry of existing entries.
Specified by:
setExpiryDelay in interface ConfigurableCacheMap
Parameters:
cMillis - the number of milliseconds that cache entries will live, or zero to disable automatic expiry

getFlushDelay

public int getFlushDelay()
Determine the delay between cache flushes. A cache flush evicts entries that have expired.

This value is used by cache implementations that periodically evict entries that have expired; this value has no meaning for cache implementations that aggressively evict entries as they expire.

Specified by:
getFlushDelay in interface ConfigurableCacheMap
Returns:
the number of milliseconds between cache flushes, or zero which signifies that the cache never flushes

setFlushDelay

public void setFlushDelay(int cMillis)
Specify the delay between cache flushes. A cache flush evicts entries that have expired.

This value is used by cache implementations that periodically evict entries that have expired; this value has no meaning for cache implementations that aggressively evict entries as they expire.

Specified by:
setFlushDelay in interface ConfigurableCacheMap
Parameters:
cMillis - the number of milliseconds between cache flushes, or zero to never flush

getCacheEntry

public ConfigurableCacheMap.Entry getCacheEntry(java.lang.Object oKey)
Locate a cache Entry in the cache based on its key.
Specified by:
getCacheEntry in interface ConfigurableCacheMap
Parameters:
oKey - the key object to search for
Returns:
the Entry or null

getUnitCalculator

public ConfigurableCacheMap.UnitCalculator getUnitCalculator()
Obtain the current UnitCalculator used by the cache.
Specified by:
getUnitCalculator in interface ConfigurableCacheMap
Returns:
the UnitCalculator used by the cache

setUnitCalculator

public void setUnitCalculator(ConfigurableCacheMap.UnitCalculator calculator)
Set the UnitCalculator for the cache to use.
Specified by:
setUnitCalculator in interface ConfigurableCacheMap
Parameters:
calculator - a UnitCalculator

getPartitionCache

protected ConfigurableCacheMap getPartitionCache(java.lang.Object oKey)
Obtain the backing cache for a particular key. If the key is not owned by a partition represented by this ObservableSplittingBackingCache, then a runtime exception is thrown.
Parameters:
oKey - the key of the desired entry
Returns:
the backing cache

getFirstPartitionCache

protected ConfigurableCacheMap getFirstPartitionCache()
Obtain the first one of the backing caches.
Returns:
a backing cache or null if no backing caches exist yet

getPartitionCacheArray

protected ConfigurableCacheMap[] getPartitionCacheArray()
Obtain the array of backing caches.
Returns:
an array of all the per-partition backing caches

repartition

protected void repartition()
Repartition the units across the backing maps. This method is called whenever a partition is created or destroyed.

calculateUnits

protected int calculateUnits(int nProp)
Aggregate the number of units across all of the partition backing maps.
Parameters:
nProp - one of the PROP_* values that specifies whether to aggregate the Units, HighUnits or LowUnits property
Returns:
the aggregate number of units

partitionUnits

protected void partitionUnits(int nProp)
Partition out the high or low units across all of the backing maps.
Parameters:
nProp - either PROP_HIGH_UNITS or PROP_LOW_UNITS which specifies whether this is going to partition out the high or the low units

instantiateEntrySet

protected java.util.Set instantiateEntrySet()
Factory pattern: Create a Set that represents the entries in the Map.
Overrides:
instantiateEntrySet in class AbstractKeySetBasedMap
Returns:
a new instance of Set that represents the entries in the Map

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.