Package net.sf.ehcache.distribution
Class TransactionalRMICachePeer
- java.lang.Object
-
- java.rmi.server.RemoteObject
-
- java.rmi.server.RemoteServer
-
- java.rmi.server.UnicastRemoteObject
-
- net.sf.ehcache.distribution.RMICachePeer
-
- net.sf.ehcache.distribution.TransactionalRMICachePeer
-
- All Implemented Interfaces:
java.io.Serializable,java.rmi.Remote,CachePeer
public class TransactionalRMICachePeer extends RMICachePeer
An RMI based implementation ofCachePeersupporting transactions.- Author:
- Ludovic Orban
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TransactionalRMICachePeer(Ehcache cache, java.lang.String hostName, java.lang.Integer rmiRegistryPort, java.lang.Integer remoteObjectPort, java.lang.Integer socketTimeoutMillis)Construct a new remote peer supporting transactions
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ListgetElements(java.util.List keys)Gets a list of elements from the cache, for a list of keys, without updating Element statistics.java.util.ListgetKeys()Returns a list of all elements in the cache, whether or not they are expired.ElementgetQuiet(java.io.Serializable key)Gets an element from the cache, without updating Element statistics.voidput(Element element)Puts an Element into the underlying cache without notifying listeners or updating statistics.booleanremove(java.io.Serializable key)Removes an Element from the underlying cache without notifying listeners or updating statistics.voidremoveAll()Removes all cached items.voidsend(java.util.List eventMessages)Send the cache peer with an ordered list ofEventMessages-
Methods inherited from class net.sf.ehcache.distribution.RMICachePeer
getGuid, getName, getUrl, getUrlBase, toString
-
-
-
-
Constructor Detail
-
TransactionalRMICachePeer
public TransactionalRMICachePeer(Ehcache cache, java.lang.String hostName, java.lang.Integer rmiRegistryPort, java.lang.Integer remoteObjectPort, java.lang.Integer socketTimeoutMillis) throws java.rmi.RemoteException
Construct a new remote peer supporting transactions- Parameters:
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-- Throws:
java.rmi.RemoteException
-
-
Method Detail
-
getKeys
public java.util.List getKeys() throws java.rmi.RemoteExceptionDescription copied from class:RMICachePeerReturns a list of all elements in the cache, whether or not they are expired.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.
- Specified by:
getKeysin interfaceCachePeer- Overrides:
getKeysin classRMICachePeer- Returns:
- a list of
Objectkeys - Throws:
java.rmi.RemoteException
-
getQuiet
public Element getQuiet(java.io.Serializable key) throws java.rmi.RemoteException
Description copied from class:RMICachePeerGets an element from the cache, without updating Element statistics. Cache statistics are still updated.- Specified by:
getQuietin interfaceCachePeer- Overrides:
getQuietin classRMICachePeer- Parameters:
key- a serializable value- Returns:
- the element, or null, if it does not exist.
- Throws:
java.rmi.RemoteException
-
getElements
public java.util.List getElements(java.util.List keys) throws java.rmi.RemoteExceptionDescription copied from class:RMICachePeerGets a list of elements from the cache, for a list of keys, without updating Element statistics. Time to idle lifetimes are therefore not affected.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.
- Specified by:
getElementsin interfaceCachePeer- Overrides:
getElementsin classRMICachePeer- Parameters:
keys- a list of serializable values which represent keys- Returns:
- a list of Elements. If an element was not found or null, it will not be in the list.
- Throws:
java.rmi.RemoteException
-
put
public void put(Element element) throws java.rmi.RemoteException, java.lang.IllegalArgumentException, java.lang.IllegalStateException
Description copied from class:RMICachePeerPuts an Element into the underlying cache without notifying listeners or updating statistics.- Specified by:
putin interfaceCachePeer- Overrides:
putin classRMICachePeer- Throws:
java.lang.IllegalArgumentException- if the element is nulljava.lang.IllegalStateException- if the cache is notStatus.STATUS_ALIVEjava.rmi.RemoteException
-
remove
public boolean remove(java.io.Serializable key) throws java.rmi.RemoteException, java.lang.IllegalStateExceptionDescription copied from class:RMICachePeerRemoves an Element from the underlying cache without notifying listeners or updating statistics.- Specified by:
removein interfaceCachePeer- Overrides:
removein classRMICachePeer- Returns:
- true if the element was removed, false if it was not found in the cache
- Throws:
java.lang.IllegalStateException- if the cache is notStatus.STATUS_ALIVEjava.rmi.RemoteException
-
removeAll
public void removeAll() throws java.rmi.RemoteException, java.lang.IllegalStateExceptionDescription copied from class:RMICachePeerRemoves all cached items.- Specified by:
removeAllin interfaceCachePeer- Overrides:
removeAllin classRMICachePeer- Throws:
java.lang.IllegalStateException- if the cache is notStatus.STATUS_ALIVEjava.rmi.RemoteException
-
send
public void send(java.util.List eventMessages) throws java.rmi.RemoteExceptionDescription copied from class:RMICachePeerSend the cache peer with an ordered list ofEventMessagesThis enables multiple messages to be delivered in one network invocation.
- Specified by:
sendin interfaceCachePeer- Overrides:
sendin classRMICachePeer- Parameters:
eventMessages- a list of typeEventMessage- Throws:
java.rmi.RemoteException
-
-