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 SummaryFieldsFields inherited from interface org.apache.commons.jcs3.auxiliary.remote.behavior.IRemoteCacheConstantsCACHE_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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAuxiliaryCache(String auxName, String cacheName, AuxiliaryCache<?, ?> cache) Add a cache to the map of registered auxiliary cachesvoidAdd a cache to the map of registered cachesvoidConfigure with default properties filevoidConfigure from specific properties file.voidconfigure(Properties props) Configure from properties object.voidconfigure(Properties props, boolean useSystemProperties) Configure from properties object, overriding with values from the system properties if instructed.voidconfigure(Properties props, boolean useSystemProperties, boolean forceReconfiguration) Configure from properties object, overriding with values from the system properties if instructed.protected static CompositeCacheManagerSimple factory method, must override in subclasses so getInstance creates / returns the correct object.voidderegisterShutdownObserver(IShutdownObserver observer) Deregister the observer with the observable.voidfreeAuxiliaryCache(String key) Dispose a cache and remove it from the map of registered auxiliary cachesvoidfreeAuxiliaryCache(String auxName, String cacheName) Dispose a cache and remove it from the map of registered auxiliary cachesvoidvoid<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 CompositeCacheManagerGets the CacheHub instance.static CompositeCacheManagergetInstance(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 CompositeCacheManagerGet a CacheHub instance which is not configured.protected voidCreates a shutdown hook and starts the scheduler servicebooleanbooleanprotected CompositeCacheConfiguratorvoidregisterShutdownObserver(IShutdownObserver observer) Perhaps the composite cache itself should be the observable object.registryAttrGet(String name) voidregistryAttrPut(AuxiliaryCacheAttributes auxAttr) registryFacGet(String name) voidregistryFacPut(AuxiliaryCacheFactory auxFac) voidrelease()voidsetJmxName(String name) voidshutDown()Calls freeCache on all regions
- 
Field Details- 
JMX_OBJECT_NAMEJMX object name- See Also:
 
 
- 
- 
Constructor Details- 
CompositeCacheManagerprotected CompositeCacheManager()Default constructor
 
- 
- 
Method Details- 
getInstanceGets 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
 
- 
getInstanceInitializes 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
 
- 
getUnconfiguredInstanceGet a CacheHub instance which is not configured. If an instance already exists, it will be returned.- Returns:
- CompositeCacheManager
 
- 
createInstanceSimple factory method, must override in subclasses so getInstance creates / returns the correct object.- Returns:
- CompositeCacheManager
 
- 
initializeCreates a shutdown hook and starts the scheduler service
- 
getElementEventQueueGet the element event queue- Returns:
- the elementEventQueue
 
- 
getScheduledExecutorServiceGet the scheduler service- Specified by:
- getScheduledExecutorServicein interface- IProvideScheduler
- Returns:
- the scheduledExecutor
 
- 
configureConfigure with default properties file- Throws:
- CacheException- if the configuration cannot be loaded
 
- 
configureConfigure from specific properties file.- Parameters:
- propFile- Path within classpath to load configuration from
- Throws:
- CacheException- if the configuration cannot be loaded
 
- 
configureConfigure from properties object.This method will call configure, instructing it to use system properties as a default. - Parameters:
- props-
 
- 
configureConfigure 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.
 
- 
configureConfigure 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.
 
- 
getDefaultCacheAttributesGets the defaultCacheAttributes attribute of the CacheHub object- Returns:
- The defaultCacheAttributes value
 
- 
getDefaultElementAttributesGets the defaultElementAttributes attribute of the CacheHub object- Returns:
- The defaultElementAttributes value
 
- 
getCacheGets the cache attribute of the CacheHub object- Specified by:
- getCachein interface- ICompositeCacheManager
- Parameters:
- cacheName-
- Returns:
- CompositeCache -- the cache region controller
 
- 
getCacheGets the cache attribute of the CacheHub object- Parameters:
- cacheName-
- cattr-
- Returns:
- CompositeCache
 
- 
getCachepublic <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
 
- 
getCacheGets the cache attribute of the CacheHub object- Parameters:
- cattr-
- Returns:
- CompositeCache
 
- 
getCachepublic <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-
 
- 
shutDownCalls freeCache on all regions
- 
release
- 
getCacheNamesReturns 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
 
- 
addCacheAdd a cache to the map of registered caches- Parameters:
- cacheName- the region name
- cache- the cache instance
 
- 
addAuxiliaryCacheAdd a cache to the map of registered auxiliary caches- Parameters:
- auxName- the auxiliary name
- cacheName- the region name
- cache- the cache instance
 
- 
getAuxiliaryCacheGet a cache from the map of registered auxiliary caches- Specified by:
- getAuxiliaryCachein interface- ICompositeCacheManager
- Parameters:
- auxName- the auxiliary name
- cacheName- the region name
- Returns:
- the cache instance
 
- 
freeAuxiliaryCacheDispose a cache and remove it from the map of registered auxiliary caches- Parameters:
- auxName- the auxiliary name
- cacheName- the region name
- Throws:
- IOException- if disposing of the cache fails
 
- 
freeAuxiliaryCacheDispose 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
 
- 
getStatsGets stats for debugging. This calls gets statistics and then puts all the results in a string. This returns data for all regions.- Specified by:
- getStatsin interface- ICompositeCacheManager
- Returns:
- String
 
- 
getStatisticsThis returns data gathered for all regions and all the auxiliaries they currently uses.- Returns:
- ICacheStats[]
 
- 
registerShutdownObserverPerhaps 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:
- registerShutdownObserverin interface- IShutdownObservable
- Parameters:
- observer-
 
- 
deregisterShutdownObserverDescription copied from interface:IShutdownObservableDeregister the observer with the observable.- Specified by:
- deregisterShutdownObserverin interface- IShutdownObservable
- Parameters:
- observer-
 
- 
getConfigurationPropertiesThis is exposed so other manager can get access to the props.- Specified by:
- getConfigurationPropertiesin interface- ICompositeCacheManager
- Returns:
- the configurationProperties
 
- 
isInitialized- Returns:
- the isInitialized
 
- 
isConfigured- Returns:
- the isConfigured
 
- 
setJmxName
 
-