Class CompositeCacheManager
- All Implemented Interfaces:
IRemoteCacheConstants
,ICompositeCacheManager
,IProvideScheduler
,IShutdownObservable
The composite cache manager is responsible for creating / configuring cache regions. It serves as a factory for the ComositeCache class. The CompositeCache is the core of JCS, the hub for various auxiliaries.
-
Field Summary
FieldsFields inherited from interface org.apache.commons.jcs3.auxiliary.remote.behavior.IRemoteCacheConstants
CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX, CACHE_SERVER_PREFIX, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, PROPERTY_PREFIX, REMOTE_ALLOW_CLUSTER_GET, REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_PORT, REMOTE_CACHE_SERVICE_VAL, REMOTE_LOCAL_CLUSTER_CONSISTENCY, SOCKET_TIMEOUT_MILLIS, TOMCAT_ON, TOMCAT_XML
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAuxiliaryCache
(String auxName, String cacheName, AuxiliaryCache<?, ?> cache) Add a cache to the map of registered auxiliary cachesvoid
Add a cache to the map of registered cachesvoid
Configure with default properties filevoid
Configure from specific properties file.void
configure
(Properties props) Configure from properties object.void
configure
(Properties props, boolean useSystemProperties) Configure from properties object, overriding with values from the system properties if instructed.void
configure
(Properties props, boolean useSystemProperties, boolean forceReconfiguration) Configure from properties object, overriding with values from the system properties if instructed.protected static CompositeCacheManager
Simple factory method, must override in subclasses so getInstance creates / returns the correct object.void
deregisterShutdownObserver
(IShutdownObserver observer) Deregister the observer with the observable.void
freeAuxiliaryCache
(String key) Dispose a cache and remove it from the map of registered auxiliary cachesvoid
freeAuxiliaryCache
(String auxName, String cacheName) Dispose a cache and remove it from the map of registered auxiliary cachesvoid
void
<K,
V> AuxiliaryCache<K, V> getAuxiliaryCache
(String auxName, String cacheName) Get a cache from the map of registered auxiliary caches<K,
V> CompositeCache<K, V> Gets the cache attribute of the CacheHub object<K,
V> CompositeCache<K, V> getCache
(String cacheName, ICompositeCacheAttributes cattr) Gets the cache attribute of the CacheHub object<K,
V> CompositeCache<K, V> getCache
(String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr) Gets the cache attribute of the CacheHub object<K,
V> CompositeCache<K, V> Gets the cache attribute of the CacheHub object<K,
V> CompositeCache<K, V> getCache
(ICompositeCacheAttributes cattr, IElementAttributes attr) If the cache has already been created, then the CacheAttributes and the element Attributes will be ignored.Returns a list of the current cache names.This is exposed so other manager can get access to the props.Gets the defaultCacheAttributes attribute of the CacheHub objectGets the defaultElementAttributes attribute of the CacheHub objectGet the element event queuestatic CompositeCacheManager
Gets the CacheHub instance.static CompositeCacheManager
getInstance
(String propsFilename) Initializes the cache manager using the props file for the given name.Get the scheduler serviceThis returns data gathered for all regions and all the auxiliaries they currently uses.getStats()
Gets stats for debugging.static CompositeCacheManager
Get a CacheHub instance which is not configured.protected void
Creates a shutdown hook and starts the scheduler serviceboolean
boolean
protected CompositeCacheConfigurator
void
registerShutdownObserver
(IShutdownObserver observer) Perhaps the composite cache itself should be the observable object.registryAttrGet
(String name) void
registryAttrPut
(AuxiliaryCacheAttributes auxAttr) registryFacGet
(String name) void
registryFacPut
(AuxiliaryCacheFactory auxFac) void
release()
void
setJmxName
(String name) void
shutDown()
Calls freeCache on all regions
-
Field Details
-
JMX_OBJECT_NAME
JMX object name- See Also:
-
-
Constructor Details
-
CompositeCacheManager
protected CompositeCacheManager()Default constructor
-
-
Method Details
-
getInstance
Gets the CacheHub instance. For backward compatibility, if this creates the instance it will attempt to configure it with the default configuration. If you want to configure from your own source, usegetUnconfiguredInstance()
and then callconfigure()
- Returns:
- CompositeCacheManager
- Throws:
CacheException
- if the configuration cannot be loaded
-
getInstance
Initializes the cache manager using the props file for the given name.- Parameters:
propsFilename
-- Returns:
- CompositeCacheManager configured from the give propsFileName
- Throws:
CacheException
- if the configuration cannot be loaded
-
getUnconfiguredInstance
Get a CacheHub instance which is not configured. If an instance already exists, it will be returned.- Returns:
- CompositeCacheManager
-
createInstance
Simple factory method, must override in subclasses so getInstance creates / returns the correct object.- Returns:
- CompositeCacheManager
-
initialize
Creates a shutdown hook and starts the scheduler service -
getElementEventQueue
Get the element event queue- Returns:
- the elementEventQueue
-
getScheduledExecutorService
Get the scheduler service- Specified by:
getScheduledExecutorService
in interfaceIProvideScheduler
- Returns:
- the scheduledExecutor
-
configure
Configure with default properties file- Throws:
CacheException
- if the configuration cannot be loaded
-
configure
Configure from specific properties file.- Parameters:
propFile
- Path within classpath to load configuration from- Throws:
CacheException
- if the configuration cannot be loaded
-
configure
Configure from properties object.This method will call configure, instructing it to use system properties as a default.
- Parameters:
props
-
-
configure
Configure from properties object, overriding with values from the system properties if instructed.You can override a specific value by passing in a system property:
For example, you could override this value in the cache.ccf file by starting up your program with the argument: -Djcs.auxiliary.LTCP.attributes.TcpListenerPort=1111
- Parameters:
props
-useSystemProperties
- -- if true, values starting with jcs will be put into the props file prior to configuring the cache.
-
configure
Configure from properties object, overriding with values from the system properties if instructed.You can override a specific value by passing in a system property:
For example, you could override this value in the cache.ccf file by starting up your program with the argument: -Djcs.auxiliary.LTCP.attributes.TcpListenerPort=1111
- Parameters:
props
-useSystemProperties
- -- if true, values starting with jcs will be put into the props file prior to configuring the cache.forceReconfiguration
- - if the manager is already configured, we will try again. This may not work properly.
-
getDefaultCacheAttributes
Gets the defaultCacheAttributes attribute of the CacheHub object- Returns:
- The defaultCacheAttributes value
-
getDefaultElementAttributes
Gets the defaultElementAttributes attribute of the CacheHub object- Returns:
- The defaultElementAttributes value
-
getCache
Gets the cache attribute of the CacheHub object- Specified by:
getCache
in interfaceICompositeCacheManager
- Parameters:
cacheName
-- Returns:
- CompositeCache -- the cache region controller
-
getCache
Gets the cache attribute of the CacheHub object- Parameters:
cacheName
-cattr
-- Returns:
- CompositeCache
-
getCache
public <K,V> CompositeCache<K,V> getCache(String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr) Gets the cache attribute of the CacheHub object- Parameters:
cacheName
-cattr
-attr
-- Returns:
- CompositeCache
-
getCache
Gets the cache attribute of the CacheHub object- Parameters:
cattr
-- Returns:
- CompositeCache
-
getCache
public <K,V> CompositeCache<K,V> getCache(ICompositeCacheAttributes cattr, IElementAttributes attr) If the cache has already been created, then the CacheAttributes and the element Attributes will be ignored. Currently there is no overriding the CacheAttributes once it is set up. You can change the default ElementAttributes for a region later.Overriding the default elemental attributes will require changing the way the attributes are assigned to elements. Get cache creates a cache with defaults if none are specified. We might want to create separate method for creating/getting. . .
- Parameters:
cattr
-attr
-- Returns:
- CompositeCache
-
newConfigurator
-
freeCache
- Parameters:
name
-
-
freeCache
- Parameters:
name
-fromRemote
-
-
shutDown
Calls freeCache on all regions -
release
-
getCacheNames
Returns a list of the current cache names.- Returns:
- Set
-
getCacheType
- Returns:
- ICacheType.CACHE_HUB
-
registryFacPut
- Parameters:
auxFac
-
-
registryFacGet
- Parameters:
name
-- Returns:
- AuxiliaryCacheFactory
-
registryAttrPut
- Parameters:
auxAttr
-
-
registryAttrGet
- Parameters:
name
-- Returns:
- AuxiliaryCacheAttributes
-
addCache
Add a cache to the map of registered caches- Parameters:
cacheName
- the region namecache
- the cache instance
-
addAuxiliaryCache
Add a cache to the map of registered auxiliary caches- Parameters:
auxName
- the auxiliary namecacheName
- the region namecache
- the cache instance
-
getAuxiliaryCache
Get a cache from the map of registered auxiliary caches- Specified by:
getAuxiliaryCache
in interfaceICompositeCacheManager
- Parameters:
auxName
- the auxiliary namecacheName
- the region name- Returns:
- the cache instance
-
freeAuxiliaryCache
Dispose a cache and remove it from the map of registered auxiliary caches- Parameters:
auxName
- the auxiliary namecacheName
- the region name- Throws:
IOException
- if disposing of the cache fails
-
freeAuxiliaryCache
Dispose a cache and remove it from the map of registered auxiliary caches- Parameters:
key
- the key into the map of auxiliaries- Throws:
IOException
- if disposing of the cache fails
-
getStats
Gets stats for debugging. This calls gets statistics and then puts all the results in a string. This returns data for all regions.- Specified by:
getStats
in interfaceICompositeCacheManager
- Returns:
- String
-
getStatistics
This returns data gathered for all regions and all the auxiliaries they currently uses.- Returns:
- ICacheStats[]
-
registerShutdownObserver
Perhaps the composite cache itself should be the observable object. It doesn't make much of a difference. There are some problems with region by region shutdown. Some auxiliaries are global. They will need to track when every region has shutdown before doing things like closing the socket with a lateral.- Specified by:
registerShutdownObserver
in interfaceIShutdownObservable
- Parameters:
observer
-
-
deregisterShutdownObserver
Description copied from interface:IShutdownObservable
Deregister the observer with the observable.- Specified by:
deregisterShutdownObserver
in interfaceIShutdownObservable
- Parameters:
observer
-
-
getConfigurationProperties
This is exposed so other manager can get access to the props.- Specified by:
getConfigurationProperties
in interfaceICompositeCacheManager
- Returns:
- the configurationProperties
-
isInitialized
- Returns:
- the isInitialized
-
isConfigured
- Returns:
- the isConfigured
-
setJmxName
-