Package org.apache.openjpa.datacache
Class PartitionedDataCache
java.lang.Object
org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
org.apache.openjpa.datacache.AbstractDataCache
org.apache.openjpa.datacache.ConcurrentDataCache
org.apache.openjpa.datacache.PartitionedDataCache
- All Implemented Interfaces:
Serializable,DataCache,RemoteCommitListener,Configurable,Clearable,Closeable,EventManager
A partitioned data cache maintains a set of partitions that are DataCache themselves.
Each of the partitioned DataCaches can be individually configured.
However, all partitions must be of the same type. By default, this cache uses
ConcurrentDataCache as its partitions.
This cache can be configured as a plug-in as follows:
Notice that the individual partition properties are enclosed parentheses, separated by comma and finally the whole property string is enclosed in single quote. Each partition must have a non-empty name that are unique among the partitions. The policy can return the name of a partition to distribute the managed instances to be cached in respective partition. The above configuration will configure a partitioned cache named
This cache can be configured as a plug-in as follows:
<property name='openjpa.DataCache"
value="partitioned(name=X, PartitionType=concurrent,Partitions='(name=a,cacheSize=100),
(name=b,cacheSize=200)')
Notice that the individual partition properties are enclosed parentheses, separated by comma and finally the whole property string is enclosed in single quote. Each partition must have a non-empty name that are unique among the partitions. The policy can return the name of a partition to distribute the managed instances to be cached in respective partition. The above configuration will configure a partitioned cache named
X with two partitions named
a and b with cache size 100 and 200 respectively.
Besides the two partitions, this cache instance itself can store data and referred by its own name
(X in the above example).
- Since:
- 2.0.0
- Author:
- Pinaki Poddar
- See Also:
-
Field Summary
Fields inherited from class org.apache.openjpa.datacache.ConcurrentDataCache
_lruFields inherited from class org.apache.openjpa.datacache.AbstractDataCache
_evictOnBulkUpdate, _excludedTypes, _includedTypes, _stats, conf, logFields inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
_listenersFields inherited from interface org.apache.openjpa.datacache.DataCache
NAME_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked upon completion of bean property configuration for this object.getPartition(String name, boolean create) Gets the named partition.Gets the name of the configured partitions.Returns the individual partition configuration properties.voidInitialize any resources associated with the givenDataCacheManager.final booleanAlways returns true.voidsetPartitions(String parts) Set partitions from a String configuration.voidsetPartitionType(String type) Sets the type of the partitions.Methods inherited from class org.apache.openjpa.datacache.ConcurrentDataCache
clearInternal, getCacheMap, getCacheSize, getInternal, getLru, getSoftReferenceSize, newCacheMap, pinInternal, putInternal, recacheUpdates, removeAllInternal, removeInternal, setCacheSize, setLru, setSoftReferenceSize, unpinAll, unpinInternal, writeLock, writeUnlockMethods inherited from class org.apache.openjpa.datacache.AbstractDataCache
addExpirationListener, afterCommit, clear, close, close, commit, contains, containsAll, fireEvent, get, getAll, getEnableStatistics, getEvictionSchedule, getEvictOnBulkUpdate, getExcludedTypes, getName, getStatistics, getTypes, isClosed, keyRemoved, pin, pinAll, pinAll, put, putAllInternal, remove, removeAll, removeAll, removeAllInternal, removeAllTypeNamesInternal, removeExpirationListener, selectCache, setConfiguration, setEnableStatistics, setEvictionSchedule, setEvictOnBulkUpdate, setExcludedTypes, setExcludedTypes, setName, setTypes, setTypes, startConfiguration, toString, unpin, unpinAll, updateMethods inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
addListener, fireEvent, getListeners, hasListener, hasListeners, isFailFast, newListenerCollection, removeListener, setFailFastMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.openjpa.event.RemoteCommitListener
afterCommit, close
-
Constructor Details
-
PartitionedDataCache
public PartitionedDataCache()
-
-
Method Details
-
initialize
Description copied from interface:DataCacheInitialize any resources associated with the givenDataCacheManager.- Specified by:
initializein interfaceDataCache- Overrides:
initializein classConcurrentDataCache
-
setPartitionType
Sets the type of the partitions. Each partition is a DataCache itself. -
setPartitions
Set partitions from a String configuration.- Parameters:
parts- a String of the form(p1, p2, p3)where p1, p2 etc. itself are plug-in strings for individual Data Cache configuration.
-
getPartitions
Returns the individual partition configuration properties. -
getPartition
Description copied from interface:DataCacheGets the named partition. Note that a partition itself is another cache.- Specified by:
getPartitionin interfaceDataCache- Overrides:
getPartitionin classAbstractDataCache- Parameters:
name- name of the given partition.create- if true optionally create a new partition.- Returns:
- a partition of the given name. Or null, if either no such partition exists or can not be created.
-
getPartitionNames
Gets the name of the configured partitions.- Specified by:
getPartitionNamesin interfaceDataCache- Overrides:
getPartitionNamesin classAbstractDataCache- Returns:
- empty set if no partition exists.
-
isPartitioned
public final boolean isPartitioned()Always returns true.- Specified by:
isPartitionedin interfaceDataCache- Overrides:
isPartitionedin classAbstractDataCache
-
endConfiguration
public void endConfiguration()Description copied from interface:ConfigurableInvoked upon completion of bean property configuration for this object.- Specified by:
endConfigurationin interfaceConfigurable- Overrides:
endConfigurationin classAbstractDataCache
-