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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Set to false to start a replicated cache built from a template without waiting for its peers' entries.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExoCacheFactoryImpl(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 Type
    Method
    Description
    void
    Add a list of custom configuration to register
    void
    Add a list of creators to register
    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.
    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 ExoCacheCreator
    getExoCacheCreator(org.exoplatform.services.cache.ExoCacheConfig config)
    Returns the most relevant ExoCacheCreator according to the give configuration
    protected void
    resetConfiguration(org.infinispan.configuration.cache.ConfigurationBuilder confBuilder)
    Clean the configuration template to prevent conflicts
    void
    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.
    void
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • REPLICATED_STATE_TRANSFER

      public static final String REPLICATED_STATE_TRANSFER
      Set to false to 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:
      createCache in interface org.exoplatform.services.cache.ExoCacheFactory
      Throws:
      org.exoplatform.services.cache.ExoCacheInitException
    • addCreator

      public void addCreator(ExoCacheCreatorPlugin plugin)
      Add a list of creators to register
      Parameters:
      plugin - the plugin that contains the creators
    • addConfig

      public void addConfig(ExoCacheFactoryConfigPlugin plugin)
      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:
      start in interface org.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:
      stop in interface org.picocontainer.Startable
    • getExoCacheCreator

      protected ExoCacheCreator getExoCacheCreator(org.exoplatform.services.cache.ExoCacheConfig config)
      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_TRANSFER set to false keeps 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