public class RMICachePeer extends UnicastRemoteObject implements CachePeer, Remote
CachePeer.
This class features a customised RMIClientSocketFactory which enables socket timeouts to be configured.
ref| Constructor and Description |
|---|
RMICachePeer(Ehcache cache,
String hostName,
Integer rmiRegistryPort,
Integer remoteObjectPort,
Integer socketTimeoutMillis)
Construct a new remote peer.
|
| Modifier and Type | Method and Description |
|---|---|
List |
getElements(List keys)
Gets a list of elements from the cache, for a list of keys, without updating Element statistics.
|
String |
getGuid()
Gets the globally unique id for the underlying
Cache instance. |
List |
getKeys()
Returns a list of all elements in the cache, whether or not they are expired.
|
String |
getName()
Gets the cache name
|
Element |
getQuiet(Serializable key)
Gets an element from the cache, without updating Element statistics.
|
String |
getUrl()
The URL for the remote replicator to connect.
|
String |
getUrlBase()
The URL base for the remote replicator to connect.
|
void |
put(Element element)
Puts an Element into the underlying cache without notifying listeners or updating statistics.
|
boolean |
remove(Serializable key)
Removes an Element from the underlying cache without notifying listeners or updating statistics.
|
void |
removeAll()
Removes all cached items.
|
void |
send(List eventMessages)
Send the cache peer with an ordered list of
EventMessages |
String |
toString()
Returns a String that represents the value of this object.
|
clone, exportObject, exportObject, exportObject, unexportObjectgetClientHost, getLog, setLogequals, getRef, hashCode, toStubpublic RMICachePeer(Ehcache cache, String hostName, Integer rmiRegistryPort, Integer remoteObjectPort, Integer socketTimeoutMillis) throws RemoteException
cache - The cache attached to the peerhostName - The host name the peer is running on.rmiRegistryPort - The port number on which the RMI Registry listens. Should be an unused port in
the range 1025 - 65536remoteObjectPort - the port number on which the remote objects bound in the registry receive calls.
This defaults to a free port if not specified.
Should be an unused port in the range 1025 - 65536socketTimeoutMillis - RemoteExceptionpublic final String getUrl()
This method is not meant to be used remotely. The replicator already needs to know this. It has to throw RemoteException to comply with RMI requirements
This implementation gives an URL which has meaning to the RMI remoting system.
public final String getUrlBase()
This implementation gives an URL which has meaning to the RMI remoting system.
getUrlBase in interface CachePeerpublic List getKeys() throws RemoteException
The returned keys are unique and can be considered a set.
The List returned is not live. It is a copy.
The time taken is O(n). On a single cpu 1.8Ghz P4, approximately 8ms is required for each 1000 entries.
getKeys in interface CachePeerObject keysRemoteExceptionpublic Element getQuiet(Serializable key) throws RemoteException
getQuiet in interface CachePeerkey - a serializable valueRemoteExceptionpublic List getElements(List keys) throws RemoteException
Cache statistics are still updated.
Callers should ideally first call this method with a small list of keys to gauge the size of a typical Element. Then a calculation can be made of the right number to request each time so as to optimise network performance and not cause an OutOfMemory error on this Cache.
getElements in interface CachePeerkeys - a list of serializable values which represent keysRemoteExceptionpublic void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException
put in interface CachePeerelement - RemoteExceptionIllegalArgumentExceptionIllegalStateExceptionpublic boolean remove(Serializable key) throws RemoteException, IllegalStateException
remove in interface CachePeerkey - RemoteExceptionIllegalStateExceptionpublic void removeAll()
throws RemoteException,
IllegalStateException
removeAll in interface CachePeerIllegalStateException - if the cache is not Status.STATUS_ALIVERemoteExceptionpublic void send(List eventMessages) throws RemoteException
EventMessages
This enables multiple messages to be delivered in one network invocation.
send in interface CachePeereventMessages - a list of type EventMessageRemoteExceptionpublic final String getName() throws RemoteException
getName in interface CachePeerRemoteExceptionpublic final String getGuid() throws RemoteException
Cache instance.getGuid in interface CachePeerRemoteExceptionpublic String toString()
toString in class RemoteObjectCopyright 2001-2021, Terracotta, Inc.