org.apache.jcs.auxiliary.remote
Class RemoteCacheNoWait

java.lang.Object
  extended by org.apache.jcs.auxiliary.remote.RemoteCacheNoWait
All Implemented Interfaces:
java.io.Serializable, AuxiliaryCache, ICache, ICacheType

public class RemoteCacheNoWait
extends java.lang.Object
implements AuxiliaryCache

Used to queue up update requests to the underlying cache. These requests will be processed in their order of arrival via the cache event queue processor.

Typically errors will be handled down stream. We only need to kill the queue if an error makes it to this level from the queue. That can only happen if the queue is damaged, since the events are procesed asynchronously.

There is no reason to create a queue on startup if the remote is not healthy.

If the remote cache encounters an error it will zombie--create a blaking facade for the service. The Zombie will queue up items until the conenction is restored. An alternative way to accomplish the same thing would be to stop, not destroy the queue at this level. That way items would be added to the queue and then when the connection is restored, we could start the worker threads again. This is a better long term solution, but it requires some significnat changes to the complicated worker queues.

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
RemoteCacheNoWait(IRemoteCacheClient cache)
          Constructs with the given remote cache, and fires up an event queue for aysnchronous processing.
 
Method Summary
 void dispose()
          Adds a dispose request to the remote cache.
 void fixCache(IRemoteCacheService remote)
          Replaces the remote cache service handle with the given handle and reset the event queue by starting up a new instance.
 ICacheElement get(java.io.Serializable key)
          Synchronously reads from the remote cache.
 AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
          This returns the generic attributes for an auxiliary cache.
protected  ICacheEventQueue getCacheEventQueue()
          This is for testing only.
 java.lang.String getCacheName()
          Gets the cacheName attribute of the RemoteCacheNoWait object
 int getCacheType()
          No remote invokation.
 java.util.Set getGroupKeys(java.lang.String groupName)
          Gets the set of keys of objects currently in the group
protected  IRemoteCacheClient getRemoteCache()
          This is temporary.
 int getSize()
          No remote invocation.
 IStats getStatistics()
          Returns the historical and statistical data for a region's auxiliary cache.
 java.lang.String getStats()
          Returns the statistics in String form.
 int getStatus()
          Returns the asyn cache status.
 boolean remove(java.io.Serializable key)
          Adds a remove request to the remote cache.
 void removeAll()
          Adds a removeAll request to the remote cache.
 void resetEventQ()
          Resets the event q by first destroying the existing one and starting up new one.
 java.lang.String toString()
          Returns the stats and the cache.toString().
 void update(ICacheElement ce)
          Adds a put event to the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteCacheNoWait

public RemoteCacheNoWait(IRemoteCacheClient cache)
Constructs with the given remote cache, and fires up an event queue for aysnchronous processing.

Parameters:
cache -
Method Detail

update

public void update(ICacheElement ce)
            throws java.io.IOException
Adds a put event to the queue.

(non-Javadoc)

Specified by:
update in interface AuxiliaryCache
Specified by:
update in interface ICache
Throws:
java.io.IOException
See Also:
ICache.update(org.apache.jcs.engine.behavior.ICacheElement)

get

public ICacheElement get(java.io.Serializable key)
                  throws java.io.IOException
Synchronously reads from the remote cache.

Specified by:
get in interface AuxiliaryCache
Specified by:
get in interface ICache
Parameters:
key -
Returns:
Throws:
java.io.IOException

getGroupKeys

public java.util.Set getGroupKeys(java.lang.String groupName)
                           throws java.io.IOException
Description copied from interface: AuxiliaryCache
Gets the set of keys of objects currently in the group

Specified by:
getGroupKeys in interface AuxiliaryCache
Returns:
a set of group keys
Throws:
java.io.IOException

remove

public boolean remove(java.io.Serializable key)
               throws java.io.IOException
Adds a remove request to the remote cache.

Specified by:
remove in interface AuxiliaryCache
Specified by:
remove in interface ICache
Parameters:
key -
Returns:
Throws:
java.io.IOException

removeAll

public void removeAll()
               throws java.io.IOException
Adds a removeAll request to the remote cache.

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

dispose

public void dispose()
Adds a dispose request to the remote cache.

Specified by:
dispose in interface AuxiliaryCache
Specified by:
dispose in interface ICache

getSize

public int getSize()
No remote invocation.

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

getCacheType

public int getCacheType()
No remote invokation.

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

getStatus

public int getStatus()
Returns the asyn cache status. An error status indicates either the remote connection is not available, or the asyn queue has been unexpectedly destroyed. No remote invocation.

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

getCacheName

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

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

fixCache

public void fixCache(IRemoteCacheService remote)
Replaces the remote cache service handle with the given handle and reset the event queue by starting up a new instance.

Parameters:
remote -

resetEventQ

public void resetEventQ()
Resets the event q by first destroying the existing one and starting up new one.

There may be no good reason to kill the existing queue. We will sometimes need to set a new listener id, so we should create a new queue. We should let the old queue drain. If we were conencted to the failover, it would be best to finish sending items.


getRemoteCache

protected IRemoteCacheClient getRemoteCache()
This is temporary. It allows the manager to get the lister.

Returns:

getAuxiliaryCacheAttributes

public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
Description copied from interface: AuxiliaryCache
This returns the generic attributes for an auxiliary cache. Most implementations will cast this to a more specific type.

Specified by:
getAuxiliaryCacheAttributes in interface AuxiliaryCache
Returns:
Returns the AuxiliaryCacheAttributes.

getCacheEventQueue

protected ICacheEventQueue getCacheEventQueue()
This is for testing only. It allows you to take a look at the event queue.

Returns:
ICacheEventQueue

toString

public java.lang.String toString()
Returns the stats and the cache.toString().

(non-Javadoc)

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getStats

public java.lang.String getStats()
Returns the statistics in String form.

Specified by:
getStats in interface ICache
Returns:
String

getStatistics

public IStats getStatistics()
Description copied from interface: AuxiliaryCache
Returns the historical and statistical data for a region's auxiliary cache.

Specified by:
getStatistics in interface AuxiliaryCache
Returns:


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