org.apache.jcs.auxiliary.remote
Class RemoteCacheManager

java.lang.Object
  extended by org.apache.jcs.auxiliary.remote.RemoteCacheManager
All Implemented Interfaces:
Serializable, AuxiliaryCacheManager, ICacheType, IShutdownObserver

public class RemoteCacheManager
extends Object
implements AuxiliaryCacheManager, IShutdownObserver

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE
 
Method Summary
 void addRemoteCacheListener(IRemoteCacheAttributes cattr, IRemoteCacheListener listener)
          Adds the remote cache listener to the underlying cache-watch service.
 void fixCaches(IRemoteCacheService remoteService, IRemoteCacheObserver remoteWatch)
          Fixes up all the caches managed by this cache manager.
 void freeCache(String name)
          Releases.
 AuxiliaryCache getCache(IRemoteCacheAttributes cattr)
          Gets a RemoteCacheNoWait from the RemoteCacheManager.
 AuxiliaryCache getCache(String cacheName)
          Returns a remote cache for the given cache name.
 int getCacheType()
          Gets the cacheType attribute of the RemoteCacheManager object
 IRemoteCacheAttributes getDefaultCattr()
          Gets the defaultCattr attribute of the RemoteCacheManager object.
static RemoteCacheManager getInstance(IRemoteCacheAttributes cattr, ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer)
          Returns an instance of RemoteCacheManager for the given connection parameters.
 String getStats()
          Gets the stats attribute of the RemoteCacheManager object
protected  void logApplicationEvent(String source, String eventName, String optionalDetails)
          Logs an event if an event logger is configured.
 void release()
          Shutdown all.
 void removeRemoteCacheListener(IRemoteCacheAttributes cattr)
          Stops a listener.
 void removeRemoteCacheListener(IRemoteCacheAttributes cattr, IRemoteCacheListener listener)
          Removes a listener.
 void removeRemoteCacheListener(String cacheName)
          Stops a listener.
 void shutdown()
          Shutdown callback from composite cache manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefaultCattr

public IRemoteCacheAttributes getDefaultCattr()
Gets the defaultCattr attribute of the RemoteCacheManager object.

Returns:
The defaultCattr value

addRemoteCacheListener

public void addRemoteCacheListener(IRemoteCacheAttributes cattr,
                                   IRemoteCacheListener 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

public void removeRemoteCacheListener(IRemoteCacheAttributes cattr,
                                      IRemoteCacheListener listener)
                               throws IOException
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 dergister 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 -
listener -
Throws:
IOException

removeRemoteCacheListener

public void removeRemoteCacheListener(IRemoteCacheAttributes cattr)
                               throws IOException
Stops a listener. This is used to deregister a failover after primary reconnection.

Parameters:
cattr -
Throws:
IOException

removeRemoteCacheListener

public void removeRemoteCacheListener(String cacheName)
                               throws IOException
Stops a listener. This is used to deregister a failover after primary reconnection.

Parameters:
cacheName -
Throws:
IOException

getInstance

public static RemoteCacheManager getInstance(IRemoteCacheAttributes cattr,
                                             ICompositeCacheManager cacheMgr,
                                             ICacheEventLogger cacheEventLogger,
                                             IElementSerializer elementSerializer)
Returns an instance of RemoteCacheManager for the given connection parameters.

Host and Port uniquely identify a manager instance.

Also starts up the monitoring daemon, if not already started.

If the connection cannot be established, zombie objects will be used for future recovery purposes.

Parameters:
cattr -
cacheMgr -
cacheEventLogger -
elementSerializer -
Returns:
The instance value

getCache

public AuxiliaryCache getCache(String cacheName)
Returns a remote cache for the given cache name.

Specified by:
getCache in interface AuxiliaryCacheManager
Parameters:
cacheName -
Returns:
The cache value

getCache

public AuxiliaryCache 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

freeCache

public void freeCache(String name)
               throws IOException
Releases.

Parameters:
name -
Throws:
IOException

getStats

public String getStats()
Gets the stats attribute of the RemoteCacheManager object

Returns:
The stats value

release

public void release()
Shutdown all.


fixCaches

public void fixCaches(IRemoteCacheService remoteService,
                      IRemoteCacheObserver remoteWatch)
Fixes up all the caches managed by this cache manager.

Parameters:
remoteService -
remoteWatch -

getCacheType

public int getCacheType()
Gets the cacheType attribute of the RemoteCacheManager object

Specified by:
getCacheType in interface ICacheType
Returns:
The cacheType value

shutdown

public void shutdown()
Shutdown callback from composite cache manager.

Specified by:
shutdown in interface IShutdownObserver
See Also:
IShutdownObserver.shutdown()

logApplicationEvent

protected void logApplicationEvent(String source,
                                   String eventName,
                                   String optionalDetails)
Logs an event if an event logger is configured.

Parameters:
source -
eventName -
optionalDetails -


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.