Package org.infinispan.manager.impl
Class AbstractDelegatingEmbeddedCacheManager
java.lang.Object
org.infinispan.manager.impl.AbstractDelegatingEmbeddedCacheManager
- All Implemented Interfaces:
Closeable,AutoCloseable,BasicCacheContainer,Lifecycle,CacheContainer,EmbeddedCacheManager,Listenable
This is a convenient base class for implementing a cache manager delegate.
The only constructor takes a
EmbeddedCacheManager
argument, to which each method call is delegated. One can extend this class and only override the method sub-set
it is interested in.- Author:
- Dan Berindei <dan@infinispan.org>
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheDependency(String from, String to) Add a dependency between two caches.voidaddListener(Object listener) Adds a listener to the component.addListenerAsync(Object listener) Asynchronous version ofListenable.addListener(Object)Provides anEmbeddedCacheManagerAdminwhose methods affect the entire cluster as opposed to a single node.booleancacheExists(String cacheName) A cache is considered to exist if it has been created and started via one of theEmbeddedCacheManager.getCache()methods and has not yet been removed viaEmbeddedCacheManager.removeCache(String).voidclose()<K,V> Cache<K, V> createCache(String name, Configuration configuration) Creates a cache on the local node using the supplied configuration.defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride) Defines a cache configuration by first reading the template configuration and then applying the override.defineConfiguration(String cacheName, Configuration configuration) Register a cache configuration in the cache manager.executor()Providess the cache manager based executor.Similar toBasicCacheContainer.getCacheNames()but filters out caches that are not accessible by the current userWarning: the address may benullbefore 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> Retrieves a cache by name.<K,V> Cache<K, V> Similar toEmbeddedCacheManager.getCache(String), except if has the option to not create the cache if it is not already running.getCacheConfiguration(String name) Returns the configuration for the given cache.This method returns a collection of all cache configuration names.Returns global configuration for this CacheManagerThis method returns a collection of all cache names.Returns an entry point for a Health Check API.Deprecated, for removal: This API element is subject to removal in a future version.getStats()Returns statistics for this cache managerbooleanbooleanTests whether the default cache is running.booleanTests whether a cache is running.voidremoveCache(String cacheName) Removes a cache with the given name from the system.voidremoveListener(Object listener) Removes a listener from the component.removeListenerAsync(Object listener) Asynchronous version ofListenable.removeListener(Object)voidstart()Invoked on component startstartCaches(String... cacheNames) Starts a set of caches in parallel.voidstop()Invoked on component stopvoidundefineConfiguration(String configurationName) Removes a configuration from the set of defined configurations.withSubject(Subject subject)
-
Field Details
-
cm
-
-
Constructor Details
-
AbstractDelegatingEmbeddedCacheManager
-
-
Method Details
-
defineConfiguration
Description copied from interface:EmbeddedCacheManagerRegister a cache configuration in the cache manager. The configuration will be automatically used when creating a cache with the same name, unless it is a template. If it is a template and it contains wildcards (`*` or `?`), it will be automatically used when creating caches that match the template. In order to extend an existing configuration, useConfigurationBuilder.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.- Specified by:
defineConfigurationin interfaceEmbeddedCacheManager- Parameters:
cacheName- name of the cache configurationconfiguration- the cache configuration- Returns:
- the cache configuration
-
defineConfiguration
public Configuration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride) Description copied from interface:EmbeddedCacheManagerDefines a cache configuration by first reading the template configuration and then applying the override. The configuration will be automatically used when creating a cache with the same name, unless it is a template. If it is a template and it contains wildcards (`*` or `?`), it will be automatically used when creating caches that match the template. The other way to define a cache configuration is declaratively, in the XML file passed in to the cache manager. If templateName is null, this method works exactly likeEmbeddedCacheManager.defineConfiguration(String, Configuration).- Specified by:
defineConfigurationin interfaceEmbeddedCacheManager- Parameters:
cacheName- name of cache whose configuration is being definedtemplateCacheName- configuration to use as a templateconfigurationOverride- configuration overrides on top of the template- Returns:
- the configuration
-
undefineConfiguration
Description copied from interface:EmbeddedCacheManagerRemoves a configuration from the set of defined configurations. If the named configuration does not exist, nothing happens.- Specified by:
undefineConfigurationin interfaceEmbeddedCacheManager- Parameters:
configurationName- the named configuration
-
getClusterName
- Specified by:
getClusterNamein interfaceEmbeddedCacheManager- Returns:
- the name of the cluster. Null if running in local mode.
-
getMembers
- Specified by:
getMembersin interfaceEmbeddedCacheManager- Returns:
- the addresses of all the members in the cluster, or
nullif not connected
-
getAddress
Description copied from interface:EmbeddedCacheManagerWarning: the address may benullbefore the first clustered cache starts and after all the clustered caches have been stopped.- Specified by:
getAddressin interfaceEmbeddedCacheManager- Returns:
- the address of the local node, or
nullif not connected
-
getCoordinator
- Specified by:
getCoordinatorin interfaceEmbeddedCacheManager- Returns:
- the address of the cluster's coordinator, or
nullif not connected
-
isCoordinator
public boolean isCoordinator()- Specified by:
isCoordinatorin interfaceEmbeddedCacheManager- Returns:
- whether the local node is the cluster's coordinator, or
nullif not connected
-
getStatus
- Specified by:
getStatusin interfaceEmbeddedCacheManager- Returns:
- the status of the cache manager
-
getDefaultCacheConfiguration
- Specified by:
getDefaultCacheConfigurationin interfaceEmbeddedCacheManager- Returns:
- the default cache's configuration, or
nullif there is no default cache.
-
getCacheManagerConfiguration
Description copied from interface:EmbeddedCacheManagerReturns global configuration for this CacheManager- Specified by:
getCacheManagerConfigurationin interfaceEmbeddedCacheManager- Returns:
- the global configuration object associated to this CacheManager
-
getCacheConfiguration
Description copied from interface:EmbeddedCacheManagerReturns the configuration for the given cache.- Specified by:
getCacheConfigurationin interfaceEmbeddedCacheManager- Returns:
- the configuration for the given cache or null if no such cache is defined
-
getCacheNames
Description copied from interface:BasicCacheContainerThis method returns a collection of all cache names. The configurations may have been defined via XML, in the programmatic configuration, or at runtime. Internal-only caches are not included.- Specified by:
getCacheNamesin interfaceBasicCacheContainer- Returns:
- an immutable set of cache names registered in this cache manager.
-
getAccessibleCacheNames
Description copied from interface:EmbeddedCacheManagerSimilar toBasicCacheContainer.getCacheNames()but filters out caches that are not accessible by the current user- Specified by:
getAccessibleCacheNamesin interfaceEmbeddedCacheManager
-
getCacheConfigurationNames
Description copied from interface:EmbeddedCacheManagerThis method returns a collection of all cache configuration names. The configurations may have been defined via XML, programmatically viaConfigurationBuilderHolder, or at runtime viaEmbeddedCacheManager.defineConfiguration(String, Configuration). Internal caches defined viaInternalCacheRegistryare not included.- Specified by:
getCacheConfigurationNamesin interfaceEmbeddedCacheManager- Returns:
- an immutable set of configuration names registered in this cache manager.
-
executor
Description copied from interface:EmbeddedCacheManagerProvidess the cache manager based executor. This can be used to execute a given operation upon the cluster or a single node if desired. If this manager is not clustered this will execute locally only.Note that not all
EmbeddedCacheManagerimplementations may implement this. Those that don't will throw aUnsupportedOperationExceptionupon invocation.- Specified by:
executorin interfaceEmbeddedCacheManager- Returns:
-
getHealth
Description copied from interface:EmbeddedCacheManagerReturns an entry point for a Health Check API.- Specified by:
getHealthin interfaceEmbeddedCacheManager- Returns:
- Health API for this
EmbeddedCacheManager.
-
getCacheManagerInfo
- Specified by:
getCacheManagerInfoin interfaceEmbeddedCacheManager- Returns:
- an instance of
CacheManagerInfoused to get basic info about the cache manager.
-
isRunning
Description copied from interface:EmbeddedCacheManagerTests whether a cache is running.- Specified by:
isRunningin interfaceEmbeddedCacheManager- Parameters:
cacheName- name of cache to test.- Returns:
- true if the cache exists and is running; false otherwise.
-
isDefaultRunning
public boolean isDefaultRunning()Description copied from interface:EmbeddedCacheManagerTests whether the default cache is running.- Specified by:
isDefaultRunningin interfaceEmbeddedCacheManager- Returns:
- true if the default cache is running; false otherwise.
-
cacheExists
Description copied from interface:EmbeddedCacheManagerA cache is considered to exist if it has been created and started via one of theEmbeddedCacheManager.getCache()methods and has not yet been removed viaEmbeddedCacheManager.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.- Specified by:
cacheExistsin interfaceEmbeddedCacheManager- Parameters:
cacheName- cache to check- Returns:
- true if the cache with the given name has not yet been started, or if it was started, whether it's been removed or not.
-
administration
Description copied from interface:EmbeddedCacheManagerProvides anEmbeddedCacheManagerAdminwhose methods affect the entire cluster as opposed to a single node.- Specified by:
administrationin interfaceCacheContainer- Specified by:
administrationin interfaceEmbeddedCacheManager- Returns:
- a cluster-aware
EmbeddedCacheManagerAdmin
-
getClassWhiteList
- Specified by:
getClassWhiteListin interfaceEmbeddedCacheManager
-
getClassAllowList
- Specified by:
getClassAllowListin interfaceEmbeddedCacheManager
-
createCache
Description copied from interface:EmbeddedCacheManagerCreates a cache on the local node using the supplied configuration. The cache may be clustered, but this method (or the equivalent combination ofEmbeddedCacheManager.defineConfiguration(String, Configuration)andEmbeddedCacheManager.getCache(String, boolean)) needs to be invoked on all nodes.- Specified by:
createCachein interfaceEmbeddedCacheManager- Type Parameters:
K- the generic type of the keyV- the generic type of the value- Parameters:
name- the name of the cacheconfiguration- the configuration to use.- Returns:
- the cache
-
getCache
Description copied from interface:EmbeddedCacheManagerSimilar toEmbeddedCacheManager.getCache(String), except if has the option to not create the cache if it is not already running.- Specified by:
getCachein interfaceEmbeddedCacheManager- Parameters:
cacheName- name of cache to retrievecreateIfAbsent- If true, this methods works just likeEmbeddedCacheManager.getCache(String). If false, return the already running cache or null.- Returns:
- null if the cache does not exist and createIfAbsent == false, otherwise a cache instance identified by cacheName
-
startCaches
Description copied from interface:EmbeddedCacheManagerStarts a set of caches in parallel. Infinispan supports both symmetric and asymmetric clusters; that is, multiple nodes having the same or different sets of caches running, respectively. Calling this method on application/application server startup with all your cache names will ensure that the cluster is symmetric.- Specified by:
startCachesin interfaceEmbeddedCacheManager- Parameters:
cacheNames- the names of the caches to start
-
removeCache
Description copied from interface:EmbeddedCacheManagerRemoves a cache with the given name from the system. This is a cluster wide operation that results not only in stopping the cache with the given name in all nodes in the cluster, but also deletes its contents both in memory and in any backing cache store.- Specified by:
removeCachein interfaceEmbeddedCacheManager- Parameters:
cacheName- name of cache to remove
-
getTransport
- Specified by:
getTransportin interfaceEmbeddedCacheManager
-
getCache
Description copied from interface:EmbeddedCacheManagerRetrieves the default cache associated with this cache container.- Specified by:
getCachein interfaceBasicCacheContainer- Specified by:
getCachein interfaceCacheContainer- Specified by:
getCachein interfaceEmbeddedCacheManager- Returns:
- the default cache.
-
getCache
Description copied from interface:EmbeddedCacheManagerRetrieves a cache by name. If the cache has been previously created with the same name, the running cache instance is returned. Otherwise, this method attempts to create the cache first. When creating a new cache, this method requires a defined configuration that either has exactly the same name, or is a template with wildcards and matches the cache name.- Specified by:
getCachein interfaceBasicCacheContainer- Specified by:
getCachein interfaceCacheContainer- Specified by:
getCachein interfaceEmbeddedCacheManager- Parameters:
cacheName- name of cache to retrieve- Returns:
- a cache instance identified by cacheName
-
start
public void start()Description copied from interface:LifecycleInvoked on component start -
stop
public void stop()Description copied from interface:LifecycleInvoked on component stop -
getGlobalComponentRegistry
- Specified by:
getGlobalComponentRegistryin interfaceEmbeddedCacheManager
-
addCacheDependency
Description copied from interface:EmbeddedCacheManagerAdd a dependency between two caches. The cache manager will make sure that a cache is stopped before any of its dependencies- Specified by:
addCacheDependencyin interfaceEmbeddedCacheManager- Parameters:
from- cache nameto- cache name
-
addListener
Description copied from interface:ListenableAdds a listener to the component. Typically, listeners would need to be annotated withListenerand further to that, contain methods annotated appropriately, otherwise the listener will not be registered. See theListenerannotation for more information.- Specified by:
addListenerin interfaceListenable- Parameters:
listener- listener to add, must not be null
-
addListenerAsync
Description copied from interface:ListenableAsynchronous version ofListenable.addListener(Object)- Specified by:
addListenerAsyncin interfaceListenable- Parameters:
listener- listener to add, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
removeListener
Description copied from interface:ListenableRemoves a listener from the component.- Specified by:
removeListenerin interfaceListenable- Parameters:
listener- listener to remove. Must not be null.
-
removeListenerAsync
Description copied from interface:ListenableAsynchronous version ofListenable.removeListener(Object)- Specified by:
removeListenerAsyncin interfaceListenable- Parameters:
listener- listener to remove, must not be null- Returns:
- CompletionStage that when complete the listener is fully removed
-
getListeners
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getListenersin interfaceListenable- Returns:
- a set of all listeners registered on this component.
-
getStats
Description copied from interface:EmbeddedCacheManagerReturns statistics for this cache manager- Specified by:
getStatsin interfaceEmbeddedCacheManager- Returns:
- statistics for this cache manager
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
withSubject
- Specified by:
withSubjectin interfaceEmbeddedCacheManager
-
getSubject
- Specified by:
getSubjectin interfaceEmbeddedCacheManager
-