Top Description Fields Constructors Methods
net.sf.ehcache.distribution

public Class TransactionalRMICachePeer

extends RMICachePeer
Class Inheritance
Imports
net.sf.ehcache.Ehcache, .Element, net.sf.ehcache.util.CacheTransactionHelper, java.io.Serializable, java.rmi.RemoteException, java.util.List

An RMI based implementation of CachePeer supporting transactions.
Author
Ludovic Orban

Field Summary

Modifier and TypeField and Description
private final Ehcache

Constructor Summary

AccessConstructor and Description
public
TransactionalRMICachePeer(Ehcache
The cache attached to the peer
cache
,
String
The host name the peer is running on.
hostName
,
Integer
The port number on which the RMI Registry listens. Should be an unused port in the range 1025 - 65536
rmiRegistryPort
,
Integer
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 - 65536
remoteObjectPort
,
Integer socketTimeoutMillis)

Construct a new remote peer supporting transactions

Method Summary

Modifier and TypeMethod and Description
public List<E>
getElements(List<E>
a list of serializable values which represent keys
keys
)

Overrides net.sf.ehcache.distribution.RMICachePeer.getElements.

Implements net.sf.ehcache.distribution.CachePeer.getElements.

Gets a list of elements from the cache, for a list of keys, without updating Element statistics.
public List<E>
getKeys()

Overrides net.sf.ehcache.distribution.RMICachePeer.getKeys.

Implements net.sf.ehcache.distribution.CachePeer.getKeys.

Returns a list of all elements in the cache, whether or not they are expired.
public Element
getQuiet(Serializable
a serializable value
key
)

Overrides net.sf.ehcache.distribution.RMICachePeer.getQuiet.

Implements net.sf.ehcache.distribution.CachePeer.getQuiet.

Gets an element from the cache, without updating Element statistics.
public void
put(Element element)

Overrides net.sf.ehcache.distribution.RMICachePeer.put.

Implements net.sf.ehcache.distribution.CachePeer.put.

Puts an Element into the underlying cache without notifying listeners or updating statistics.
public boolean
remove(Serializable key)

Overrides net.sf.ehcache.distribution.RMICachePeer.remove.

Implements net.sf.ehcache.distribution.CachePeer.remove.

Removes an Element from the underlying cache without notifying listeners or updating statistics.
public void
public void
send(List<E>
a list of type EventMessage
eventMessages
)

Overrides net.sf.ehcache.distribution.RMICachePeer.send.

Implements net.sf.ehcache.distribution.CachePeer.send.

Send the cache peer with an ordered list of EventMessages

This enables multiple messages to be delivered in one network invocation.

Inherited from net.sf.ehcache.distribution.RMICachePeer:
getBoundCacheInstancegetGuidgetNamegetUrlgetUrlBasetoString

Field Detail

cacheback to summary
private final Ehcache cache

Hides net.sf.ehcache.distribution.RMICachePeer.cache.

Constructor Detail

TransactionalRMICachePeerback to summary
public TransactionalRMICachePeer(Ehcache cache, String hostName, Integer rmiRegistryPort, Integer remoteObjectPort, Integer socketTimeoutMillis) throws RemoteException

Construct a new remote peer supporting transactions

Parameters
cache:Ehcache

The cache attached to the peer

hostName:String

The host name the peer is running on.

rmiRegistryPort:Integer

The port number on which the RMI Registry listens. Should be an unused port in the range 1025 - 65536

remoteObjectPort:Integer

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 - 65536

Method Detail

getElementsback to summary
public List<E> getElements(List<E> keys) throws RemoteException

Overrides net.sf.ehcache.distribution.RMICachePeer.getElements.

Implements net.sf.ehcache.distribution.CachePeer.getElements.

Doc from net.sf.ehcache.distribution.RMICachePeer.getElements.

Gets 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.

Parameters
keys:List<E>

a list of serializable values which represent keys

Returns:List<E>

a list of Elements. If an element was not found or null, it will not be in the list.

Annotations
@Override
getKeysback to summary
public List<E> getKeys() throws RemoteException

Overrides net.sf.ehcache.distribution.RMICachePeer.getKeys.

Implements net.sf.ehcache.distribution.CachePeer.getKeys.

Doc from net.sf.ehcache.distribution.RMICachePeer.getKeys.

Returns 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.

Returns:List<E>

a list of Object keys

Annotations
@Override
getQuietback to summary
public Element getQuiet(Serializable key) throws RemoteException

Overrides net.sf.ehcache.distribution.RMICachePeer.getQuiet.

Implements net.sf.ehcache.distribution.CachePeer.getQuiet.

Doc from net.sf.ehcache.distribution.RMICachePeer.getQuiet.

Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.

Parameters
key:Serializable

a serializable value

Returns:Element

the element, or null, if it does not exist.

Annotations
@Override
putback to summary
public void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException

Overrides net.sf.ehcache.distribution.RMICachePeer.put.

Implements net.sf.ehcache.distribution.CachePeer.put.

Doc from net.sf.ehcache.distribution.RMICachePeer.put.

Puts an Element into the underlying cache without notifying listeners or updating statistics.

Annotations
@Override
Exceptions
IllegalArgumentException:

Doc from net.sf.ehcache.distribution.CachePeer.put.

if the element is null

IllegalStateException:

Doc from net.sf.ehcache.distribution.CachePeer.put.

if the cache is not net.sf.ehcache.Status#STATUS_ALIVE

removeback to summary
public boolean remove(Serializable key) throws RemoteException, IllegalStateException

Overrides net.sf.ehcache.distribution.RMICachePeer.remove.

Implements net.sf.ehcache.distribution.CachePeer.remove.

Doc from net.sf.ehcache.distribution.RMICachePeer.remove.

Removes an Element from the underlying cache without notifying listeners or updating statistics.

Returns:boolean

true if the element was removed, false if it was not found in the cache

Annotations
@Override
Exceptions
IllegalStateException:

Doc from net.sf.ehcache.distribution.CachePeer.remove.

if the cache is not net.sf.ehcache.Status#STATUS_ALIVE

removeAllback to summary
public void removeAll() throws RemoteException, IllegalStateException

Overrides net.sf.ehcache.distribution.RMICachePeer.removeAll.

Implements net.sf.ehcache.distribution.CachePeer.removeAll.

Doc from net.sf.ehcache.distribution.RMICachePeer.removeAll.

Removes all cached items.

Annotations
@Override
Exceptions
IllegalStateException:
if the cache is not net.sf.ehcache.Status#STATUS_ALIVE
sendback to summary
public void send(List<E> eventMessages) throws RemoteException

Overrides net.sf.ehcache.distribution.RMICachePeer.send.

Implements net.sf.ehcache.distribution.CachePeer.send.

Doc from net.sf.ehcache.distribution.RMICachePeer.send.

Send the cache peer with an ordered list of EventMessages

This enables multiple messages to be delivered in one network invocation.

Parameters
eventMessages:List<E>

Doc from net.sf.ehcache.distribution.CachePeer.send.

a list of type EventMessage

Annotations
@Override