|
||||||||||
| 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<K,V>
public class RemoteCacheServer<K extends Serializable,V extends Serializable>
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.
Get requests are made between clustered servers if AllowClusterGet is true. You can setup several clients to use one remote server and several to use another. The get local 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 |
remoteCacheServerAttributes
Configuration settings. |
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. |
protected |
RemoteCacheServer(IRemoteCacheServerAttributes rcsa,
RMISocketFactory customRMISocketFactory)
Constructor for the RemoteCacheServer object. |
| Method Summary | ||
|---|---|---|
|
addCacheListener(ICacheListener<KK,VV> listener)
Subscribes to all remote caches. |
|
|
addCacheListener(String cacheName,
ICacheListener<KK,VV> listener)
Subscribes to the specified remote cache. |
|
void |
dispose(String cacheName)
Frees the specified remote cache. |
|
void |
dispose(String cacheName,
long requesterId)
Frees the specified remote cache. |
|
ICacheElement<K,V> |
get(String cacheName,
K key)
Returns a cache value from the specified remote cache; or null if the cache or key does not exist. |
|
ICacheElement<K,V> |
get(String cacheName,
K key,
long requesterId)
Returns a cache bean from the specified cache; or null if the key does not exist. |
|
protected CacheListeners<K,V> |
getCacheListeners(String cacheName)
Returns the cache listener for the specified cache. |
|
protected CacheListeners<K,V> |
getClusterListeners(String cacheName)
Gets the clusterListeners attribute of the RemoteCacheServer object. |
|
protected String |
getExtraInfoForRequesterId(long requesterId)
Ip address for the client, if one is stored. |
|
Set<K> |
getGroupKeys(String cacheName,
String group)
Gets the set of keys of objects currently in the group. |
|
Set<String> |
getGroupNames(String cacheName)
Gets the set of group names currently in the cache. |
|
Map<K,ICacheElement<K,V>> |
getMatching(String cacheName,
String pattern)
Gets all matching items. |
|
Map<K,ICacheElement<K,V>> |
getMatching(String cacheName,
String pattern,
long requesterId)
Retrieves all matching keys. |
|
Map<K,ICacheElement<K,V>> |
getMultiple(String cacheName,
Set<K> keys)
Gets multiple items from the cache based on the given set of keys. |
|
Map<K,ICacheElement<K,V>> |
getMultiple(String cacheName,
Set<K> keys,
long requesterId)
Gets multiple items from the cache based on the given set of keys. |
|
protected int |
getPutCount()
How many put events have we received. |
|
String |
getStats()
Gets the stats attribute of the RemoteCacheServer object. |
|
protected void |
logApplicationEvent(String source,
String eventName,
String optionalDetails)
Logs an event if an event logger is configured. |
|
protected
|
logICacheEvent(ICacheEvent<T> cacheEvent)
Logs an event if an event logger is configured. |
|
protected Set<K> |
processGetGroupKeys(String cacheName,
String group)
Gets the set of keys of objects currently in the group. |
|
protected Set<String> |
processGetGroupNames(String cacheName)
Gets the set of group names currently in the cache. |
|
protected Map<K,ICacheElement<K,V>> |
processGetMatching(String cacheName,
String pattern,
long requesterId)
Retrieves all matching keys. |
|
void |
put(ICacheElement<K,V> 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(String cacheName,
K key)
Removes the given key from the specified remote cache. |
|
void |
remove(String cacheName,
K key,
long requesterId)
Remove the key from the cache region and don't tell the source listener about it. |
|
void |
removeAll(String cacheName)
Remove all keys from the specified remote cache. |
|
void |
removeAll(String cacheName,
long requesterId)
Remove all keys from the specified remote cache. |
|
|
removeCacheListener(ICacheListener<KK,VV> listener)
Unsubscribes from all remote caches. |
|
|
removeCacheListener(String cacheName,
ICacheListener<KK,VV> listener)
Unsubscribe this listener from this region. |
|
void |
removeCacheListener(String cacheName,
long listenerId)
Unsubscribe this listener from this region. |
|
void |
setCacheEventLogger(ICacheEventLogger cacheEventLogger)
Allows it to be injected. |
|
void |
shutdown()
Shuts down the remote server. |
|
void |
shutdown(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<K,V> item)
Puts a cache item to the cache. |
|
void |
update(ICacheElement<K,V> item,
long requesterId)
The internal processing is wrapped in event logging calls. |
|
| 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 remoteCacheServerAttributes
| Constructor Detail |
|---|
protected RemoteCacheServer(IRemoteCacheServerAttributes rcsa)
throws RemoteException
rcsa -
RemoteException
protected RemoteCacheServer(IRemoteCacheServerAttributes rcsa,
RMISocketFactory customRMISocketFactory)
throws RemoteException
rcsa - customRMISocketFactory -
RemoteException| Method Detail |
|---|
public void put(ICacheElement<K,V> item)
throws IOException
item -
IOException
public void update(ICacheElement<K,V> item)
throws IOException
ICacheService
update in interface ICacheService<K extends Serializable,V extends Serializable>item -
IOException
public void update(ICacheElement<K,V> item,
long requesterId)
throws IOException
update in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>item - requesterId -
IOException
public ICacheElement<K,V> get(String cacheName,
K key)
throws IOException
get in interface ICacheService<K extends Serializable,V extends Serializable>cacheName - key -
IOException
public ICacheElement<K,V> get(String cacheName,
K key,
long requesterId)
throws IOException
Adding the requestor id, allows the cache to determine the source of the get.
The internal processing is wrapped in event logging calls.
get in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - key - requesterId -
IOException
public Map<K,ICacheElement<K,V>> getMatching(String cacheName,
String pattern)
throws IOException
getMatching in interface ICacheService<K extends Serializable,V extends Serializable>cacheName - pattern -
IOException
public Map<K,ICacheElement<K,V>> getMatching(String cacheName,
String pattern,
long requesterId)
throws IOException
getMatching in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - pattern - requesterId -
IOException
protected Map<K,ICacheElement<K,V>> processGetMatching(String cacheName,
String pattern,
long requesterId)
cacheName - pattern - requesterId -
public Map<K,ICacheElement<K,V>> getMultiple(String cacheName,
Set<K> keys)
throws IOException
getMultiple in interface ICacheService<K extends Serializable,V extends Serializable>cacheName - keys -
IOException
public Map<K,ICacheElement<K,V>> getMultiple(String cacheName,
Set<K> keys,
long requesterId)
throws IOException
The internal processing is wrapped in event logging calls.
getMultiple in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - keys - requesterId -
IOException
public Set<K> getGroupKeys(String cacheName,
String group)
getGroupKeys in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - group -
protected Set<K> processGetGroupKeys(String cacheName,
String group)
cacheName - group -
public Set<String> getGroupNames(String cacheName)
getGroupNames in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - the name of the region
protected Set<String> processGetGroupNames(String cacheName)
cacheName - the name of the region
public void remove(String cacheName,
K key)
throws IOException
remove in interface ICacheService<K extends Serializable,V extends Serializable>cacheName - key -
IOException
public void remove(String cacheName,
K key,
long requesterId)
throws IOException
The internal processing is wrapped in event logging calls.
remove in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - key - requesterId -
IOException
public void removeAll(String cacheName)
throws IOException
removeAll in interface ICacheService<K extends Serializable,V extends Serializable>cacheName -
IOException
public void removeAll(String cacheName,
long requesterId)
throws IOException
The internal processing is wrapped in event logging calls.
removeAll in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>cacheName - requesterId -
IOExceptionprotected int getPutCount()
public void dispose(String cacheName)
throws IOException
dispose in interface ICacheService<K extends Serializable,V extends Serializable>cacheName -
IOException
public void dispose(String cacheName,
long requesterId)
throws IOException
cacheName - requesterId -
IOException
public void release()
throws IOException
release in interface ICacheService<K extends Serializable,V extends Serializable>IOExceptionprotected CacheListeners<K,V> getCacheListeners(String cacheName)
cacheName -
protected CacheListeners<K,V> getClusterListeners(String cacheName)
TODO may be able to remove this
cacheName -
public <KK extends Serializable,VV extends Serializable> void addCacheListener(String cacheName,
ICacheListener<KK,VV> listener)
throws IOException
If the client id is 0, then the remote cache server will increment it's local count and assign an id to the client.
addCacheListener in interface ICacheObservercacheName - the specified remote cache.listener - object to notify for cache changes. must be synchronized since there are
remote calls involved.
IOException
public <KK extends Serializable,VV extends Serializable> void addCacheListener(ICacheListener<KK,VV> listener)
throws IOException
addCacheListener in interface ICacheObserverlistener - The feature to be added to the CacheListener attribute
IOException
public <KK extends Serializable,VV extends Serializable> void removeCacheListener(String cacheName,
ICacheListener<KK,VV> listener)
throws IOException
removeCacheListener in interface ICacheObservercacheName - listener -
IOException
public void removeCacheListener(String cacheName,
long listenerId)
cacheName - listenerId -
public <KK extends Serializable,VV extends Serializable> void removeCacheListener(ICacheListener<KK,VV> listener)
throws IOException
removeCacheListener in interface ICacheObserverlistener -
IOException
public void shutdown()
throws IOException
shutdown in interface ICacheServiceAdminIOException
public void shutdown(String host,
int port)
throws IOException
shutdown in interface ICacheServiceAdminhost - port -
IOExceptionpublic void unreferenced()
unreferenced in interface Unreferenced
public String getStats()
throws IOException
getStats in interface ICacheServiceAdminIOException
protected void logApplicationEvent(String source,
String eventName,
String optionalDetails)
source - eventName - optionalDetails - protected <T extends Serializable> void logICacheEvent(ICacheEvent<T> cacheEvent)
cacheEvent - protected String getExtraInfoForRequesterId(long requesterId)
Protected for testing.
requesterId -
public void setCacheEventLogger(ICacheEventLogger cacheEventLogger)
cacheEventLogger -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||