public class CompositeCacheManager extends Object implements IRemoteCacheConstants, ICompositeCacheManager, IProvideScheduler
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.
Modifier and Type | Field and Description |
---|---|
static String |
JMX_OBJECT_NAME
JMX object name
|
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
Modifier | Constructor and Description |
---|---|
protected |
CompositeCacheManager()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addAuxiliaryCache(String auxName,
String cacheName,
AuxiliaryCache<?,?> cache)
Add a cache to the map of registered auxiliary caches
|
void |
addCache(String cacheName,
ICache<?,?> cache)
Add a cache to the map of registered caches
|
void |
configure()
Configure with default 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.
|
void |
configure(String propFile)
Configure from specific properties file.
|
protected static CompositeCacheManager |
createInstance()
Simple factory method, must override in subclasses so getInstance creates / returns the
correct object.
|
void |
deregisterShutdownObserver(IShutdownObserver observer)
Deregisters the observer with the observable.
|
void |
freeCache(String name) |
void |
freeCache(String name,
boolean fromRemote) |
<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> |
getCache(ICompositeCacheAttributes cattr)
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.
|
<K,V> CompositeCache<K,V> |
getCache(String cacheName)
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
|
String[] |
getCacheNames()
Returns a list of the current cache names.
|
ICacheType.CacheType |
getCacheType() |
Properties |
getConfigurationProperties()
This is exposed so other manager can get access to the props.
|
ICompositeCacheAttributes |
getDefaultCacheAttributes()
Gets the defaultCacheAttributes attribute of the CacheHub object
|
IElementAttributes |
getDefaultElementAttributes()
Gets the defaultElementAttributes attribute of the CacheHub object
|
IElementEventQueue |
getElementEventQueue()
Get the element event queue
|
static CompositeCacheManager |
getInstance()
Gets the CacheHub instance.
|
static CompositeCacheManager |
getInstance(String propsFilename)
Initializes the cache manager using the props file for the given name.
|
ScheduledExecutorService |
getScheduledExecutorService()
Get the scheduler service
|
ICacheStats[] |
getStatistics()
This returns data gathered for all regions and all the auxiliaries they currently uses.
|
String |
getStats()
Gets stats for debugging.
|
static CompositeCacheManager |
getUnconfiguredInstance()
Get a CacheHub instance which is not configured.
|
protected void |
initialize()
Creates a shutdown hook and starts the scheduler service
|
boolean |
isConfigured() |
boolean |
isInitialized() |
protected CompositeCacheConfigurator |
newConfigurator() |
void |
registerShutdownObserver(IShutdownObserver observer)
Perhaps the composite cache itself should be the observable object.
|
AuxiliaryCacheAttributes |
registryAttrGet(String name) |
void |
registryAttrPut(AuxiliaryCacheAttributes auxAttr) |
AuxiliaryCacheFactory |
registryFacGet(String name) |
void |
registryFacPut(AuxiliaryCacheFactory auxFac) |
void |
release() |
void |
setJmxName(String name) |
void |
shutDown()
Calls freeCache on all regions
|
public static final String JMX_OBJECT_NAME
protected CompositeCacheManager()
public static CompositeCacheManager getInstance() throws CacheException
getUnconfiguredInstance()
and then call configure()
CacheException
- if the configuration cannot be loadedpublic static CompositeCacheManager getInstance(String propsFilename) throws CacheException
propsFilename
- CacheException
- if the configuration cannot be loadedpublic static CompositeCacheManager getUnconfiguredInstance()
protected static CompositeCacheManager createInstance()
protected void initialize()
public IElementEventQueue getElementEventQueue()
public ScheduledExecutorService getScheduledExecutorService()
getScheduledExecutorService
in interface IProvideScheduler
public void configure() throws CacheException
CacheException
- if the configuration cannot be loadedpublic void configure(String propFile) throws CacheException
propFile
- Path within classpath to load configuration fromCacheException
- if the configuration cannot be loadedpublic void configure(Properties props)
This method will call configure, instructing it to use system properties as a default.
props
- public void configure(Properties props, boolean useSystemProperties)
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
props
- useSystemProperties
- -- if true, values starting with jcs will be put into the props
file prior to configuring the cache.public void configure(Properties props, boolean useSystemProperties, boolean forceReconfiguration)
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
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.public ICompositeCacheAttributes getDefaultCacheAttributes()
public IElementAttributes getDefaultElementAttributes()
public <K,V> CompositeCache<K,V> getCache(String cacheName)
getCache
in interface ICompositeCacheManager
cacheName
- public <K,V> CompositeCache<K,V> getCache(String cacheName, ICompositeCacheAttributes cattr)
cacheName
- cattr
- public <K,V> CompositeCache<K,V> getCache(String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr)
cacheName
- cattr
- attr
- public <K,V> CompositeCache<K,V> getCache(ICompositeCacheAttributes cattr)
cattr
- public <K,V> CompositeCache<K,V> getCache(ICompositeCacheAttributes cattr, IElementAttributes attr)
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. . .
cattr
- attr
- protected CompositeCacheConfigurator newConfigurator()
public void shutDown()
public void release()
public String[] getCacheNames()
public ICacheType.CacheType getCacheType()
public void registryFacPut(AuxiliaryCacheFactory auxFac)
auxFac
- public AuxiliaryCacheFactory registryFacGet(String name)
name
- public void registryAttrPut(AuxiliaryCacheAttributes auxAttr)
auxAttr
- public AuxiliaryCacheAttributes registryAttrGet(String name)
name
- public void addCache(String cacheName, ICache<?,?> cache)
cacheName
- the region namecache
- the cache instancepublic void addAuxiliaryCache(String auxName, String cacheName, AuxiliaryCache<?,?> cache)
auxName
- the auxiliary namecacheName
- the region namecache
- the cache instancepublic <K,V> AuxiliaryCache<K,V> getAuxiliaryCache(String auxName, String cacheName)
getAuxiliaryCache
in interface ICompositeCacheManager
auxName
- the auxiliary namecacheName
- the region namepublic String getStats()
getStats
in interface ICompositeCacheManager
public ICacheStats[] getStatistics()
public void registerShutdownObserver(IShutdownObserver observer)
registerShutdownObserver
in interface IShutdownObservable
observer
- public void deregisterShutdownObserver(IShutdownObserver observer)
IShutdownObservable
deregisterShutdownObserver
in interface IShutdownObservable
observer
- public Properties getConfigurationProperties()
getConfigurationProperties
in interface ICompositeCacheManager
public boolean isInitialized()
public boolean isConfigured()
public void setJmxName(String name)
Copyright © 2002–2018 The Apache Software Foundation. All rights reserved.