Class ExoCacheFactoryImpl
java.lang.Object
org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl
- All Implemented Interfaces:
org.exoplatform.services.cache.ExoCacheFactory, org.picocontainer.Startable
public class ExoCacheFactoryImpl
extends Object
implements org.exoplatform.services.cache.ExoCacheFactory, org.picocontainer.Startable
This class is the Infinispan implementation of the
ExoCacheFactory- Version:
- $Id$
- Author:
- Nicolas Filotto
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSet tofalseto start a replicated cache built from a template without waiting for its peers' entries. -
Constructor Summary
ConstructorsConstructorDescriptionExoCacheFactoryImpl(org.exoplatform.container.ExoContainerContext ctx, String cacheConfigTemplate, String cacheAsyncConfigTemplate, org.exoplatform.container.configuration.ConfigurationManager configManager) ExoCacheFactoryImpl(org.exoplatform.container.ExoContainerContext ctx, org.exoplatform.container.xml.InitParams params, org.exoplatform.container.configuration.ConfigurationManager configManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfig(ExoCacheFactoryConfigPlugin plugin) Add a list of custom configuration to registervoidaddCreator(ExoCacheCreatorPlugin plugin) Add a list of creators to registerprotected voidconfigureStateTransfer(org.infinispan.configuration.cache.ConfigurationBuilder confBuilder) A replicated cache holds state that no store holds: a node that creates it, at its first use or when it rejoins the cluster, receives the entries the other nodes hold and waits for them before it serves its first read.org.exoplatform.services.cache.ExoCache<Serializable, Object> createCache(org.exoplatform.services.cache.ExoCacheConfig config) To create a new cache instance according to the given configuration, we follow the steps below: We first try to find if a specific location of the cache configuration has been defined thanks to an external component plugin of type ExoCacheFactoryConfigPlugin.protected ExoCacheCreatorgetExoCacheCreator(org.exoplatform.services.cache.ExoCacheConfig config) Returns the most relevant ExoCacheCreator according to the give configurationprotected voidresetConfiguration(org.infinispan.configuration.cache.ConfigurationBuilder confBuilder) Clean the configuration template to prevent conflictsvoidstart()Starts the cache managers of the custom configurations, as the asynchronous one starts with the factory: in cluster mode, the channel of such a manager is a fork of the channel the node shares, whose oldest member coordinates the fork and must therefore have it.voidstop()Stops every cache manager of the factory, the main one first, the asynchronous and custom ones being mapped to their cluster names, so that each releases its channel, a fork of the channel the node shares in cluster mode.
-
Field Details
-
REPLICATED_STATE_TRANSFER
Set tofalseto start a replicated cache built from a template without waiting for its peers' entries.- See Also:
-
-
Constructor Details
-
ExoCacheFactoryImpl
public ExoCacheFactoryImpl(org.exoplatform.container.ExoContainerContext ctx, org.exoplatform.container.xml.InitParams params, org.exoplatform.container.configuration.ConfigurationManager configManager) throws org.exoplatform.services.cache.ExoCacheInitException - Throws:
org.exoplatform.services.cache.ExoCacheInitException
-
ExoCacheFactoryImpl
public ExoCacheFactoryImpl(org.exoplatform.container.ExoContainerContext ctx, String cacheConfigTemplate, String cacheAsyncConfigTemplate, org.exoplatform.container.configuration.ConfigurationManager configManager) throws org.exoplatform.services.cache.ExoCacheInitException - Throws:
org.exoplatform.services.cache.ExoCacheInitException
-
-
Method Details
-
createCache
public org.exoplatform.services.cache.ExoCache<Serializable, Object> createCache(org.exoplatform.services.cache.ExoCacheConfig config) throws org.exoplatform.services.cache.ExoCacheInitException To create a new cache instance according to the given configuration, we follow the steps below: We first try to find if a specific location of the cache configuration has been defined thanks to an external component plugin of type ExoCacheFactoryConfigPlugin. If so we use the default cache configuration defined in this file otherwise we use the default cache configuration defined in "${CACHE_CONFIG_TEMPLATE_KEY}"- Specified by:
createCachein interfaceorg.exoplatform.services.cache.ExoCacheFactory- Throws:
org.exoplatform.services.cache.ExoCacheInitException
-
addCreator
Add a list of creators to register- Parameters:
plugin- the plugin that contains the creators
-
addConfig
Add a list of custom configuration to register- Parameters:
plugin- the plugin that contains the configs
-
start
public void start()Starts the cache managers of the custom configurations, as the asynchronous one starts with the factory: in cluster mode, the channel of such a manager is a fork of the channel the node shares, whose oldest member coordinates the fork and must therefore have it. A configuration that fails here fails again when one of its caches is created.- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()Stops every cache manager of the factory, the main one first, the asynchronous and custom ones being mapped to their cluster names, so that each releases its channel, a fork of the channel the node shares in cluster mode. A manager that fails to stop does not keep the others running; the shared channel closes with its last fork, so it stays open when the failing manager threw before it closed its own.- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getExoCacheCreator
Returns the most relevant ExoCacheCreator according to the give configuration -
configureStateTransfer
protected void configureStateTransfer(org.infinispan.configuration.cache.ConfigurationBuilder confBuilder) A replicated cache holds state that no store holds: a node that creates it, at its first use or when it rejoins the cluster, receives the entries the other nodes hold and waits for them before it serves its first read. The cluster templates do not transfer it by default, and a cache invalidated rather than replicated holds data that each node loads from its store, which a transfer would only copy for nothing.The node waits for the transfer up to the template's state-transfer timeout, beyond which the cache starts again without the transferred entries, with a warning, and a new transfer fills it in the background. This holds for a cache mapped to a custom configuration too.
REPLICATED_STATE_TRANSFERset tofalsekeeps the template instead: the cache starts at once, empty.- Parameters:
confBuilder- the configuration of a replicated cache
-
resetConfiguration
protected void resetConfiguration(org.infinispan.configuration.cache.ConfigurationBuilder confBuilder) Clean the configuration template to prevent conflicts
-