org.apache.jcs.auxiliary.remote
Class RemoteCache

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

public class RemoteCache
extends java.lang.Object
implements ICache

Client proxy for an RMI remote cache.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE
 
Constructor Summary
RemoteCache(IRemoteCacheAttributes cattr, IRemoteCacheService remote, IRemoteCacheListener listener)
          Constructor for the RemoteCache object.
 
Method Summary
 void dispose()
          Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.
 void fixCache(IRemoteCacheService remote)
          Replaces the current remote cache service handle with the given handle.
 ICacheElement get(java.io.Serializable key)
          Synchronously get from the remote cache; if failed, replace the remote handle with a zombie.
 AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
           
 java.lang.String getCacheName()
          Gets the cacheName attribute of the RemoteCache object
 int getCacheType()
          Gets the cacheType attribute of the RemoteCache object
 IElementAttributes getElementAttributes()
          Gets the attributes attribute of the RemoteCache object
 IElementSerializer getElementSerializer()
           
 java.util.Set getGroupKeys(java.lang.String groupName)
          Returns all the keys for a group.
protected  IRemoteCacheListener getListener()
          Allows other member of this package to access the listerner.
 long getListenerId()
          Gets the listenerId attribute of the RemoteCacheListener object
 int getSize()
          Returns the current cache size.
 IStats getStatistics()
           
 java.lang.String getStats()
          Gets the stats attribute of the RemoteCache object
 int getStatus()
          Returns the cache status.
 ICacheElement getUsingPool(java.io.Serializable key)
          This allows gets to timeout in case of remote server machine shutdown.
 boolean remove(java.io.Serializable key)
          Synchronously remove from the remote cache; if failed, replace the remote handle with a zombie.
 void removeAll()
          Synchronously removeAll from the remote cache; if failed, replace the remote handle with a zombie.
 void setElementAttributes(IElementAttributes attr)
          Sets the attributes attribute of the RemoteCache object
 void setElementSerializer(IElementSerializer elementSerializer)
           
 void setListenerId(long id)
          let the remote cache set a listener_id.
 java.lang.String toString()
          Debugging info.
 void update(ICacheElement ce)
          Puts an item to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteCache

public RemoteCache(IRemoteCacheAttributes cattr,
                   IRemoteCacheService remote,
                   IRemoteCacheListener listener)
Constructor for the RemoteCache object. This object communicates with a remote cache server. One of these exists for each region. This also holds a reference to a listener. The same listener is used for all regions for one remote server. Holding a reference to the listener allows this object to know the listener id assigned by the remote cache.

Parameters:
cattr -
remote -
listener -
Method Detail

setElementAttributes

public void setElementAttributes(IElementAttributes attr)
Sets the attributes attribute of the RemoteCache object

Parameters:
attr - The new attributes value

getElementAttributes

public IElementAttributes getElementAttributes()
Gets the attributes attribute of the RemoteCache object

Returns:
The attributes value

update

public void update(ICacheElement ce)
            throws java.io.IOException
Description copied from interface: ICache
Puts an item to the cache.

Specified by:
update in interface ICache
Parameters:
ce -
Throws:
java.io.IOException

get

public ICacheElement get(java.io.Serializable key)
                  throws java.io.IOException
Synchronously get from the remote cache; if failed, replace the remote handle with a zombie. Use threadpool to timeout is a value is set for GetTimeoutMillis

Specified by:
get in interface ICache
Parameters:
key -
Returns:
ICacheElement, a wrapper around the key, value, and attributes
Throws:
java.io.IOException

getUsingPool

public ICacheElement getUsingPool(java.io.Serializable key)
                           throws java.io.IOException
This allows gets to timeout in case of remote server machine shutdown.

Parameters:
key -
Returns:
Throws:
java.io.IOException

getGroupKeys

public java.util.Set getGroupKeys(java.lang.String groupName)
                           throws java.rmi.RemoteException
Returns all the keys for a group.

Parameters:
groupName -
Returns:
Throws:
java.rmi.RemoteException

remove

public boolean remove(java.io.Serializable key)
               throws java.io.IOException
Synchronously remove from the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
remove in interface ICache
Parameters:
key -
Returns:
boolean, whether or not the item was removed
Throws:
java.io.IOException

removeAll

public void removeAll()
               throws java.io.IOException
Synchronously removeAll from the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
removeAll in interface ICache
Throws:
java.io.IOException

dispose

public void dispose()
             throws java.io.IOException
Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
dispose in interface ICache
Throws:
java.io.IOException

getStatus

public int getStatus()
Returns the cache status. An error status indicates the remote connection is not available.

Specified by:
getStatus in interface ICache
Returns:
The status value

getStats

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

Specified by:
getStats in interface ICache
Returns:
The stats value

getStatistics

public IStats getStatistics()
Returns:
IStats object

getSize

public int getSize()
Returns the current cache size.

Specified by:
getSize in interface ICache
Returns:
The size value

getCacheType

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

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

getCacheName

public java.lang.String getCacheName()
Gets the cacheName attribute of the RemoteCache object

Specified by:
getCacheName in interface ICache
Returns:
The cacheName value

fixCache

public void fixCache(IRemoteCacheService remote)
Replaces the current remote cache service handle with the given handle.

Parameters:
remote - IRemoteCacheService -- the remote server or proxy to the remote server

getAuxiliaryCacheAttributes

public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
Returns:
Returns the AuxiliaryCacheAttributes.

setListenerId

public void setListenerId(long id)
let the remote cache set a listener_id. Since there is only one listerenr for all the regions and every region gets registered? the id shouldn't be set if it isn't zero. If it is we assume that it is a reconnect.

Parameters:
id - The new listenerId value

getListenerId

public long getListenerId()
Gets the listenerId attribute of the RemoteCacheListener object

Returns:
The listenerId value

getListener

protected IRemoteCacheListener getListener()
Allows other member of this package to access the listerner. This is mainly needed for deregistering alistener.

Returns:
IRemoteCacheListener, the listener for this remote server

setElementSerializer

public void setElementSerializer(IElementSerializer elementSerializer)
Parameters:
elementSerializer - The elementSerializer to set.

getElementSerializer

public IElementSerializer getElementSerializer()
Returns:
Returns the elementSerializer.

toString

public java.lang.String toString()
Debugging info.

Returns:
basic info about the RemoteCache


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