|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.utils.props.AbstractPropertyContainer
org.apache.jcs.access.PartitionedCacheAccess<K,V>
public class PartitionedCacheAccess<K extends Serializable,V extends Serializable>
TODO: Add new methods that will allow you to provide a partition indicator for all major calls. Add an interface as well.
This handles dividing puts and gets.
There are two required properties.
We use a JCS region name for each partition that looks like this: partitionRegionNamePrefix + "_" + patitionNuber. The number is ) indexed based.
| Constructor Summary | |
|---|---|
PartitionedCacheAccess()
Sets default properties heading and group. |
|
| Method Summary | |
|---|---|
protected void |
ensureInit()
Initialize if we haven't already. |
int |
freeMemoryElements(int numberToFree)
Calls free on each partition. |
V |
get(K key)
Gets the object for the key from the desired partition. |
ICompositeCacheAttributes |
getCacheAttributes()
Gets the ICompositeCacheAttributes of the cache region |
ICacheElement<K,V> |
getCacheElement(K key)
Gets the ICacheElement |
Map<K,ICacheElement<K,V>> |
getCacheElements(Set<K> names)
This is a getMultiple. |
IElementAttributes |
getElementAttributes()
GetElementAttributes will return an attribute object describing the current attributes associated with the object name. |
IElementAttributes |
getElementAttributes(K key)
This is no more efficient than simply getting the cache element. |
Map<K,V> |
getMatching(String pattern)
This is tricky. |
Map<K,ICacheElement<K,V>> |
getMatchingCacheElements(String pattern)
This is tricky. |
protected int |
getNumberOfPartitions()
|
long |
getNumericValueForKey(K key)
This can be overridden for special purposes. |
protected int |
getPartitionNumberForKey(K key)
This expects a numeric key. |
protected String |
getPartitionRegionNamePrefix()
|
protected ICacheAccess<K,V>[] |
getPartitions()
|
protected String |
getPropertyForName(String propertyName,
boolean required)
Checks the system properties before the properties. |
protected void |
handleProperties()
Loads in the needed configuration settings. |
protected void |
initialize()
Use the partition prefix and the number of partitions to get JCS regions. |
void |
put(K key,
V object)
Puts the value into the appropriate cache partition. |
void |
put(K key,
V object,
IElementAttributes attr)
Puts the value into the appropriate cache partition. |
void |
putSafe(K key,
V object)
Puts in cache if an item does not exist with the name in that region. |
void |
remove()
Calls remove on all partitions. |
void |
remove(K key)
Removes the item from the appropriate partition. |
void |
resetElementAttributes(IElementAttributes attributes)
Resets the default element attributes on all partitions. |
void |
resetElementAttributes(K key,
IElementAttributes attributes)
Resets the attributes for this item. |
void |
setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the attributes on all the partitions. |
protected void |
setNumberOfPartitions(int numberOfPartitions)
|
protected void |
setPartitionRegionNamePrefix(String partitionRegionNamePrefix)
|
protected void |
setPartitions(ICacheAccess<K,V>[] partitions)
|
| Methods inherited from class org.apache.jcs.utils.props.AbstractPropertyContainer |
|---|
ensureProperties, getProperties, getPropertiesFactory, getPropertiesGroup, getPropertiesHeading, initializeProperties, setProperties, setPropertiesFactory, setPropertiesGroup, setPropertiesHeading |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PartitionedCacheAccess()
| Method Detail |
|---|
public void put(K key,
V object)
throws CacheException
put in interface ICacheAccess<K extends Serializable,V extends Serializable>key - keyobject - object
CacheException - on configuration problem
public void putSafe(K key,
V object)
throws CacheException
putSafe in interface ICacheAccess<K extends Serializable,V extends Serializable>key - object -
CacheException
public void put(K key,
V object,
IElementAttributes attr)
throws CacheException
put in interface ICacheAccess<K extends Serializable,V extends Serializable>key - keyobject - objectattr -
CacheException - on configuration problempublic V get(K key)
get in interface ICacheAccess<K extends Serializable,V extends Serializable>key - key
public ICacheElement<K,V> getCacheElement(K key)
getCacheElement in interface ICacheAccess<K extends Serializable,V extends Serializable>key - key
public Map<K,ICacheElement<K,V>> getCacheElements(Set<K> names)
getCacheElements in interface ICacheAccess<K extends Serializable,V extends Serializable>names -
public Map<K,V> getMatching(String pattern)
If this interface took an object, we could use the hashcode to determine the partition. Then we could use the toString for the pattern.
getMatching in interface ICacheAccess<K extends Serializable,V extends Serializable>pattern -
public Map<K,ICacheElement<K,V>> getMatchingCacheElements(String pattern)
getMatchingCacheElements in interface ICacheAccess<K extends Serializable,V extends Serializable>pattern -
public void remove()
throws CacheException
remove in interface ICacheAccess<K extends Serializable,V extends Serializable>CacheException
public void remove(K key)
throws CacheException
remove in interface ICacheAccess<K extends Serializable,V extends Serializable>key -
CacheException
public int freeMemoryElements(int numberToFree)
throws CacheException
freeMemoryElements in interface ICacheAccess<K extends Serializable,V extends Serializable>numberToFree -
CacheExceptionpublic ICompositeCacheAttributes getCacheAttributes()
ICacheAccess
getCacheAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>
public IElementAttributes getElementAttributes()
throws CacheException
ICacheAccess
getElementAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>CacheException
public IElementAttributes getElementAttributes(K key)
throws CacheException
getElementAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>key -
CacheException
public void resetElementAttributes(IElementAttributes attributes)
throws CacheException
resetElementAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>attributes -
CacheException
public void resetElementAttributes(K key,
IElementAttributes attributes)
throws CacheException
resetElementAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>key - attributes -
CacheExceptionpublic void setCacheAttributes(ICompositeCacheAttributes cattr)
setCacheAttributes in interface ICacheAccess<K extends Serializable,V extends Serializable>cattr - protected int getPartitionNumberForKey(K key)
We determine the partition by taking the mod of the number of partitions.
key - key
public long getNumericValueForKey(K key)
key - key
protected void ensureInit()
throws ConfigurationException
ConfigurationException - on configuration problem
protected void initialize()
throws ConfigurationException
ConfigurationException - on configuration problem
protected void handleProperties()
throws ConfigurationException
Loads the following JCS Cache specific properties:
handleProperties in class AbstractPropertyContainerConfigurationException - on configuration problem
protected String getPropertyForName(String propertyName,
boolean required)
throws ConfigurationException
propertyName - namerequired - is it required?
ConfigurationException - thrown if it is required and not found.protected void setNumberOfPartitions(int numberOfPartitions)
numberOfPartitions - The numberOfPartitions to set.protected int getNumberOfPartitions()
protected void setPartitionRegionNamePrefix(String partitionRegionNamePrefix)
partitionRegionNamePrefix - The partitionRegionNamePrefix to set.protected String getPartitionRegionNamePrefix()
protected void setPartitions(ICacheAccess<K,V>[] partitions)
partitions - The partitions to set.protected ICacheAccess<K,V>[] getPartitions()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||