|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
org.apache.jcs.auxiliary.remote.server.RemoteCacheServer
This class provides remote cache services. The remote cache server propagates events from local caches to other local caches. It can also store cached data, making it available to new clients. Remote cache servers can be clustered. If the cache used by this remote cache is configured to use a remote cache of type cluster, the two remote caches will communicate with each other. Remote and put requests can be sent from one remote to another. If they are configured to broadcast such event to their client, then remove an puts can be sent to all locals in the cluster. However, get requests are not made between clustered servers. You can setup several clients to use one remote server and several to use another. The get locad will be distributed between the two servers. Since caches are usually high get and low put, this should allow you to scale.
Field Summary | |
protected IRemoteCacheServerAttributes |
rcsa
Description of the Field |
protected static boolean |
timing
timing -- if we should record operation times. |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Constructor Summary | |
protected |
RemoteCacheServer(IRemoteCacheServerAttributes rcsa)
Constructor for the RemoteCacheServer object |
Method Summary | |
void |
addCacheListener(ICacheListener listener)
Subscribes to all remote caches. |
void |
addCacheListener(java.lang.String cacheName,
ICacheListener listener)
Subscribes to the specified remote cache. |
protected CompositeCacheManager |
createCacheManager(java.lang.String prop)
Subclass can overrdie this method to create the specific cache manager. |
void |
dispose(java.lang.String cacheName)
Frees the specified remote cache. |
void |
dispose(java.lang.String cacheName,
long requesterId)
Frees the specified remote cache. |
ICacheElement |
get(java.lang.String cacheName,
java.io.Serializable key)
Returns a cache value from the specified remote cache; or null if the cache or key does not exist. |
java.util.Set |
getGroupKeys(java.lang.String cacheName,
java.lang.String group)
Gets the set of keys of objects currently in the group. |
java.lang.String |
getStats()
Gets the stats attribute of the RemoteCacheServer object |
protected void |
init(java.lang.String prop)
Initialize the RMI Cache Server from a proeprties file. |
void |
put(ICacheElement item)
Puts a cache bean to the remote cache and notifies all listeners which have a different listener id than the originating host; are currently subscribed to the related cache. |
void |
release()
Frees all remote caches. |
void |
remove(java.lang.String cacheName,
java.io.Serializable key)
Removes the given key from the specified remote cache. |
void |
remove(java.lang.String cacheName,
java.io.Serializable key,
long requesterId)
Remove the key from the cache region and don't tell the source listener about it. |
void |
removeAll(java.lang.String cacheName)
Remove all keys from the sepcified remote cache. |
void |
removeAll(java.lang.String cacheName,
long requesterId)
Remove all keys from the sepcified remote cache. |
void |
removeCacheListener(ICacheListener listener)
Unsubscribes from all remote caches. |
void |
removeCacheListener(java.lang.String cacheName,
ICacheListener listener)
Unsubscribes from the specified cache. |
void |
removeCacheListener(java.lang.String cacheName,
long listenerId)
Unsibscribe this region. |
void |
shutdown()
Shuts down the remote server. |
void |
shutdown(java.lang.String host,
int port)
Shuts down a server at a particular host and port. |
void |
unreferenced()
Called by the RMI runtime sometime after the runtime determines that the reference list, the list of clients referencing the remote object, becomes empty. |
void |
update(ICacheElement item)
Puts a cache item to the cache. |
void |
update(ICacheElement item,
long requesterId)
An update can come from either a local cache's remote auxiliary, or it can come from a remote server. |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final boolean timing
protected IRemoteCacheServerAttributes rcsa
Constructor Detail |
protected RemoteCacheServer(IRemoteCacheServerAttributes rcsa) throws java.io.IOException, java.rmi.NotBoundException
rcsa
-
java.io.IOException
java.rmi.NotBoundException
Method Detail |
protected void init(java.lang.String prop) throws java.io.IOException, java.rmi.NotBoundException
prop
-
java.io.IOException
java.rmi.NotBoundException
protected CompositeCacheManager createCacheManager(java.lang.String prop)
prop
- The anem of the configuration file.
public void put(ICacheElement item) throws java.io.IOException
item
-
java.io.IOException
public void update(ICacheElement item) throws java.io.IOException
ICacheService
update
in interface ICacheService
item
-
java.io.IOException
public void update(ICacheElement item, long requesterId) throws java.io.IOException
If the update came from a cluster, then we should tell the cache manager that this was a remote put. This way, any lateral and remote auxiliaries configured for the region will not be updated. This is basically how a remote listener works when plugged into a local cache.
If the cluster is configured to keep local cluster consistency, then all listeners will be updated. This allows cluster server A to update cluster server B and then B to update its clients if it is told to keep local cluster consistency. Otherwise, server A will update server B and B will not tell its clients. If you cluster using lateral caches for instance, this is how it will work. Updates to a cluster node, will never get to the leavess. The remote cluster, with local cluster consistency, allows you to update leaves. This basically allows you to have a failover remote server.
Since currently a cluster will not try to get from other cluster servers, you can scale a bit with a cluster configuration. Puts and removes will be broadcasted to all clients, but the get load on a remote server can be reduced.
update
in interface IRemoteCacheService
item
- requesterId
-
java.io.IOException
public ICacheElement get(java.lang.String cacheName, java.io.Serializable key) throws java.io.IOException
get
in interface ICacheService
cacheName
- key
-
java.io.IOException
public java.util.Set getGroupKeys(java.lang.String cacheName, java.lang.String group)
getGroupKeys
in interface IRemoteCacheService
cacheName
- group
-
public void remove(java.lang.String cacheName, java.io.Serializable key) throws java.io.IOException
remove
in interface ICacheService
cacheName
- key
-
java.io.IOException
public void remove(java.lang.String cacheName, java.io.Serializable key, long requesterId) throws java.io.IOException
remove
in interface IRemoteCacheService
cacheName
- key
- requesterId
-
java.io.IOException
public void removeAll(java.lang.String cacheName) throws java.io.IOException
removeAll
in interface ICacheService
cacheName
-
java.io.IOException
public void removeAll(java.lang.String cacheName, long requesterId) throws java.io.IOException
removeAll
in interface IRemoteCacheService
cacheName
- requesterId
-
java.io.IOException
public void dispose(java.lang.String cacheName) throws java.io.IOException
dispose
in interface ICacheService
cacheName
-
java.io.IOException
public void dispose(java.lang.String cacheName, long requesterId) throws java.io.IOException
cacheName
- requesterId
-
java.io.IOException
public void release() throws java.io.IOException
release
in interface ICacheService
java.io.IOException
public void addCacheListener(java.lang.String cacheName, ICacheListener listener) throws java.io.IOException
addCacheListener
in interface ICacheObserver
cacheName
- the specified remote cache.listener
- object to notify for cache changes. must be synchronized since
there are remote calls involved.
java.io.IOException
public void addCacheListener(ICacheListener listener) throws java.io.IOException
addCacheListener
in interface ICacheObserver
listener
- The feature to be added to the CacheListener attribute
java.io.IOException
public void removeCacheListener(java.lang.String cacheName, ICacheListener listener) throws java.io.IOException
ICacheObserver
removeCacheListener
in interface ICacheObserver
cacheName
- listener
- existing subscriber.
java.io.IOException
public void removeCacheListener(java.lang.String cacheName, long listenerId) throws java.io.IOException
cacheName
- listenerId
-
java.io.IOException
public void removeCacheListener(ICacheListener listener) throws java.io.IOException
removeCacheListener
in interface ICacheObserver
listener
-
java.io.IOException
public void shutdown() throws java.io.IOException
shutdown
in interface ICacheServiceAdmin
java.io.IOException
public void shutdown(java.lang.String host, int port) throws java.io.IOException
shutdown
in interface ICacheServiceAdmin
host
- port
-
java.io.IOException
public void unreferenced()
unreferenced
in interface java.rmi.server.Unreferenced
public java.lang.String getStats() throws java.io.IOException
getStats
in interface ICacheServiceAdmin
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |