org.apache.jcs.auxiliary.remote
Class RemoteCacheManager

java.lang.Object
  extended byorg.apache.jcs.auxiliary.remote.RemoteCacheManager
All Implemented Interfaces:
AuxiliaryCacheManager, ICacheType, java.io.Serializable

public class RemoteCacheManager
extends java.lang.Object
implements AuxiliaryCacheManager

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.

Author:
asmuts
See Also:
Serialized Form

Nested Class Summary
private static class RemoteCacheManager.Location
          Location of the RMI registry.
 
Field Summary
(package private)  java.util.Map caches
           
private  int clients
           
(package private)  java.lang.String host
           
(package private) static java.util.Map instances
           
private  IRemoteCacheAttributes irca
           
private static org.apache.commons.logging.Log log
           
private static RemoteCacheMonitor monitor
           
(package private)  int port
           
private  IRemoteCacheService remoteService
          Handle to the remote cache service; or a zombie handle if failed to connect.
private  RemoteCacheWatchRepairable remoteWatch
          Wrapper of the remote cache watch service; or wrapper of a zombie service if failed to connect.
(package private)  java.lang.String service
           
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE
 
Constructor Summary
private RemoteCacheManager(java.lang.String host, int port, java.lang.String service)
          Constructs an instance to with the given remote connection parameters.
 
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(java.lang.String name)
          Description of the Method
 AuxiliaryCache getCache(IRemoteCacheAttributes cattr)
          Gets the cache attribute of the RemoteCacheManager object
 AuxiliaryCache getCache(java.lang.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)
          Returns an instance of RemoteCacheManager for the given connection parameters.
 java.lang.String getStats()
          Gets the stats attribute of the RemoteCacheManager object
 void release()
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

instances

static final java.util.Map instances

monitor

private static RemoteCacheMonitor monitor

clients

private int clients

caches

final java.util.Map caches

host

final java.lang.String host

port

final int port

service

final java.lang.String service

irca

private IRemoteCacheAttributes irca

remoteService

private IRemoteCacheService remoteService
Handle to the remote cache service; or a zombie handle if failed to connect.


remoteWatch

private RemoteCacheWatchRepairable remoteWatch
Wrapper of the remote cache watch service; or wrapper of a zombie service if failed to connect.

Constructor Detail

RemoteCacheManager

private RemoteCacheManager(java.lang.String host,
                           int port,
                           java.lang.String service)
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:
host -
port -
service -
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 java.io.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:
java.io.IOException

getInstance

public static RemoteCacheManager getInstance(IRemoteCacheAttributes cattr)
Returns an instance of RemoteCacheManager for the given connection parameters. 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.

Returns:
The instance value

getCache

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

Specified by:
getCache in interface AuxiliaryCacheManager
Returns:
The cache value

getCache

public AuxiliaryCache getCache(IRemoteCacheAttributes cattr)
Gets the cache attribute of the RemoteCacheManager object

Returns:
The cache value

freeCache

public void freeCache(java.lang.String name)
               throws java.io.IOException
Description of the Method

Throws:
java.io.IOException

getStats

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

Returns:
The stats value

release

public void release()
Description of the Method


fixCaches

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


getCacheType

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

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