public interface EmbeddedCacheManager extends CacheContainer, Listenable, Closeable
Configuration
or a path or URL to a configuration XML file: see DefaultCacheManager
.
Lifecycle - EmbeddedCacheManagers have a lifecycle (it implements Lifecycle
) and
the default constructors also call Lifecycle.start()
. Overloaded versions of the constructors are available, that do
not start the CacheManager, although it must be kept in mind that CacheManagers need to be started
before they can be used to readWriteMap Cache instances.
Once constructed, EmbeddedCacheManagers should be made available to any component that requires a Cache,
via JNDI or via some other mechanism
such as an dependency injection framework.
DefaultCacheManager
Modifier and Type | Method and Description |
---|---|
void |
addCacheDependency(String from,
String to)
Add a dependency between two caches.
|
default EmbeddedCacheManagerAdmin |
administration()
Provides an
EmbeddedCacheManagerAdmin whose methods affect the entire cluster as opposed to a single node. |
boolean |
cacheExists(String cacheName)
A cache is considered to exist if it has been created and started via
one of the
getCache() methods and has not yet been removed via
removeCache(String) . |
<K,V> Cache<K,V> |
createCache(String name,
Configuration configuration)
Creates a cache on the local node using the supplied configuration.
|
Configuration |
defineConfiguration(String cacheName,
Configuration configuration)
Register a cache configuration in the cache manager.
|
Configuration |
defineConfiguration(String cacheName,
String templateCacheName,
Configuration configurationOverride)
Defines a cache configuration by first reading the template configuration and then applying the override.
|
default ClusterExecutor |
executor()
Providess the cache manager based executor.
|
Address |
getAddress()
Warning: the address may be
null before the first clustered cache starts
and after all the clustered caches have been stopped. |
<K,V> Cache<K,V> |
getCache()
Retrieves the default cache associated with this cache container.
|
<K,V> Cache<K,V> |
getCache(String cacheName)
Retrieves a cache by name.
|
<K,V> Cache<K,V> |
getCache(String cacheName,
boolean createIfAbsent)
Similar to
getCache(String) , except if has the option
to not create the cache if it is not already running. |
Configuration |
getCacheConfiguration(String name)
Returns the configuration for the given cache.
|
default Set<String> |
getCacheConfigurationNames()
This method returns a collection of all cache configuration names.
|
GlobalConfiguration |
getCacheManagerConfiguration()
Returns global configuration for this CacheManager
|
CacheManagerInfo |
getCacheManagerInfo() |
ClassWhiteList |
getClassWhiteList() |
String |
getClusterName() |
Address |
getCoordinator() |
Configuration |
getDefaultCacheConfiguration() |
GlobalComponentRegistry |
getGlobalComponentRegistry()
Deprecated.
Since 10.0, with no public API replacement
|
Health |
getHealth()
Returns an entry point for a Health Check API.
|
List<Address> |
getMembers() |
CacheContainerStats |
getStats()
Deprecated.
Since 10.1.3. This mixes statistics across unrelated caches so the reported numbers don't have too much
relevance.
|
ComponentStatus |
getStatus() |
Subject |
getSubject() |
Transport |
getTransport()
Deprecated.
Since 10.0, please use
getAddress() , getMembers() , getCoordinator() |
boolean |
isCoordinator() |
boolean |
isDefaultRunning()
Tests whether the default cache is running.
|
boolean |
isRunning(String cacheName)
Tests whether a cache is running.
|
void |
removeCache(String cacheName)
Deprecated.
Since 9.2, obtain a
CacheContainerAdmin instance using administration() and invoke the CacheContainerAdmin.removeCache(String) method |
EmbeddedCacheManager |
startCaches(String... cacheNames)
Starts a set of caches in parallel.
|
void |
undefineConfiguration(String configurationName)
Removes a configuration from the set of defined configurations.
|
EmbeddedCacheManager |
withSubject(Subject subject) |
getCacheNames
addListener, addListenerAsync, getListeners, removeListener, removeListenerAsync
Configuration defineConfiguration(String cacheName, Configuration configuration)
ConfigurationBuilder.read(org.infinispan.configuration.cache.Configuration)
.
The other way to define a cache configuration is declaratively, in the XML file passed in to the cache
manager.cacheName
- name of the cache configurationconfiguration
- the cache configurationCacheConfigurationException
- if a configuration with the same name already exists.Configuration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride)
defineConfiguration(String, Configuration)
.cacheName
- name of cache whose configuration is being definedtemplateCacheName
- configuration to use as a templateconfigurationOverride
- configuration overrides on top of the templateCacheConfigurationException
- if a configuration with the same name already exists.void undefineConfiguration(String configurationName)
configurationName
- the named configurationIllegalStateException
- if the configuration is in useString getClusterName()
List<Address> getMembers()
null
if not connectedAddress getAddress()
null
before the first clustered cache starts
and after all the clustered caches have been stopped.null
if not connectedAddress getCoordinator()
null
if not connectedboolean isCoordinator()
null
if not connectedComponentStatus getStatus()
GlobalConfiguration getCacheManagerConfiguration()
Configuration getCacheConfiguration(String name)
Configuration getDefaultCacheConfiguration()
null
if there is no default cache.default Set<String> getCacheConfigurationNames()
ConfigurationBuilderHolder
,
or at runtime via defineConfiguration(String, Configuration)
.
Internal caches defined via InternalCacheRegistry
are not included.boolean isRunning(String cacheName)
cacheName
- name of cache to test.boolean isDefaultRunning()
boolean cacheExists(String cacheName)
getCache()
methods and has not yet been removed via
removeCache(String)
.
In environments when caches are continuously created and removed, this
method offers the possibility to find out whether a cache has either,
not been started, or if it was started, whether it's been removed already
or not.cacheName
- cache to check<K,V> Cache<K,V> getCache()
getCache
in interface BasicCacheContainer
getCache
in interface CacheContainer
CacheConfigurationException
- if a default cache does not exist.<K,V> Cache<K,V> getCache(String cacheName)
getCache
in interface BasicCacheContainer
getCache
in interface CacheContainer
cacheName
- name of cache to retrieve<K,V> Cache<K,V> createCache(String name, Configuration configuration)
defineConfiguration(String, Configuration)
and
getCache(String, boolean)
) needs to be invoked on all nodes.K
- the generic type of the keyV
- the generic type of the valuename
- the name of the cacheconfiguration
- the configuration to use.<K,V> Cache<K,V> getCache(String cacheName, boolean createIfAbsent)
getCache(String)
, except if has the option
to not create the cache if it is not already running.cacheName
- name of cache to retrievecreateIfAbsent
- If true, this methods works just like getCache(String)
.
If false, return the already running cache or null.EmbeddedCacheManager startCaches(String... cacheNames)
cacheNames
- the names of the caches to start@Deprecated void removeCache(String cacheName)
CacheContainerAdmin
instance using administration()
and invoke the CacheContainerAdmin.removeCache(String)
methodcacheName
- name of cache to removeTransport getTransport()
getAddress()
, getMembers()
, getCoordinator()
@Deprecated GlobalComponentRegistry getGlobalComponentRegistry()
void addCacheDependency(String from, String to)
from
- cache nameto
- cache name@Deprecated CacheContainerStats getStats()
default ClusterExecutor executor()
Note that not all EmbeddedCacheManager
implementations may implement this. Those that don't will throw
a UnsupportedOperationException
upon invocation.
Health getHealth()
EmbeddedCacheManager
.CacheManagerInfo getCacheManagerInfo()
CacheManagerInfo
used to get basic info about the cache manager.default EmbeddedCacheManagerAdmin administration()
EmbeddedCacheManagerAdmin
whose methods affect the entire cluster as opposed to a single node.administration
in interface CacheContainer
EmbeddedCacheManagerAdmin
ClassWhiteList getClassWhiteList()
Subject getSubject()
EmbeddedCacheManager withSubject(Subject subject)
Copyright © 2021 JBoss by Red Hat. All rights reserved.