Class RemoteCacheManager

java.lang.Object
org.apache.commons.jcs3.auxiliary.remote.RemoteCacheManager

public class RemoteCacheManager extends Object
An instance of RemoteCacheManager corresponds to one remote connection of a specific host and port. All RemoteCacheManager instances are monitored by the singleton RemoteCacheMonitor monitoring daemon for error detection and recovery.

Getting an instance of the remote cache has the effect of getting a handle on the remote server. Listeners are not registered with the server until a cache is requested from the manager.

  • Constructor Details

    • RemoteCacheManager

      protected RemoteCacheManager(IRemoteCacheAttributes cattr, ICompositeCacheManager cacheMgr, RemoteCacheMonitor monitor, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer)
      Constructs an instance to with the given remote connection parameters. If the connection cannot be made, "zombie" services will be temporarily used until a successful re-connection is made by the monitoring daemon.

      Parameters:
      cattr - cache attributes
      cacheMgr - the cache hub
      monitor - the cache monitor thread for error notifications
      cacheEventLogger -
      elementSerializer -
  • Method Details

    • lookupRemoteService

      protected void lookupRemoteService() throws IOException
      Lookup remote service from registry
      Throws:
      IOException - if the remote service could not be found
    • addRemoteCacheListener

      public <K, V> void addRemoteCacheListener(IRemoteCacheAttributes cattr, IRemoteCacheListener<K,V> listener) throws IOException
      Adds the remote cache listener to the underlying cache-watch service.

      Parameters:
      cattr - The feature to be added to the RemoteCacheListener attribute
      listener - The feature to be added to the RemoteCacheListener attribute
      Throws:
      IOException
    • removeRemoteCacheListener

      Removes a listener. When the primary recovers the failover must deregister itself for a region. The failover runner will call this method to de-register. We do not want to deregister all listeners to a remote server, in case a failover is a primary of another region. Having one regions failover act as another servers primary is not currently supported.

      Parameters:
      cattr -
      Throws:
      IOException
    • getCache

      public <K, V> RemoteCacheNoWait<K,V> getCache(IRemoteCacheAttributes cattr)
      Gets a RemoteCacheNoWait from the RemoteCacheManager. The RemoteCacheNoWait objects are identified by the cache name value of the RemoteCacheAttributes object.

      If the client is configured to register a listener, this call results on a listener being created if one isn't already registered with the remote cache for this region.

      Parameters:
      cattr -
      Returns:
      The cache value
    • newRemoteCacheNoWait

      Create new RemoteCacheNoWait instance
      Parameters:
      cattr - the cache configuration
      Returns:
      the instance
    • release

      public void release()
      Shutdown all.
    • fixCaches

      public void fixCaches()
      Fixes up all the caches managed by this cache manager.
    • canFixCaches

      public boolean canFixCaches()
      Returns true if the connection to the remote host can be successfully re-established.

      Returns:
      true if we found a failover server