Interface CachePeer
-
- All Superinterfaces:
java.rmi.Remote
- All Known Implementing Classes:
RMICachePeer,TransactionalRMICachePeer
public interface CachePeer extends java.rmi.RemoteAn interface for a cache peer to which updates are made remotely. The distribution mechanism is meant to be pluggable. The requirements of RMI force this interface to exten Remote and throw RemoteException.It is acknowledged that not all implementations will use Remote. Remote is just a marker interface like Serializable, so nothing specific is required.
Non-RMI implementations should be able to use this interface. Implementations not using RMI should
- Version:
- $Id$
- Author:
- Greg Luck
-
-
Method Summary
All Methods Instance Methods Abstract 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.lang.StringgetGuid()Gets the globally unique id for the underlyingCacheinstance.java.util.ListgetKeys()Returns a list of all elements in the cache, whether or not they are expired.java.lang.StringgetName()Gets the cache name.ElementgetQuiet(java.io.Serializable key)Gets an element from the cache, without updating Element statistics.java.lang.StringgetUrl()The URL for the remote replicator to connect.java.lang.StringgetUrlBase()The URL base for the remote replicator to connect.voidput(Element element)Put an element in the cache.booleanremove(java.io.Serializable key)Removes anElementfrom the Cache.voidremoveAll()Removes all cached items.voidsend(java.util.List eventMessages)Send the cache peer with an ordered list ofEventMessages.
-
-
-
Method Detail
-
put
void put(Element element) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.rmi.RemoteException
Put an element in the cache.Resets the access statistics on the element, which would be the case if it has previously been gotten from a cache, and is now being put back.
- Parameters:
element-- Throws:
java.lang.IllegalStateException- if the cache is notStatus.STATUS_ALIVEjava.lang.IllegalArgumentException- if the element is nulljava.rmi.RemoteException
-
remove
boolean remove(java.io.Serializable key) throws java.lang.IllegalStateException, java.rmi.RemoteExceptionRemoves anElementfrom the Cache. This also removes it from any stores it may be in.- Parameters:
key-- 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
void removeAll() throws java.rmi.RemoteException, java.lang.IllegalStateExceptionRemoves all cached items.- Throws:
java.lang.IllegalStateException- if the cache is notStatus.STATUS_ALIVEjava.rmi.RemoteException
-
send
void send(java.util.List eventMessages) throws java.rmi.RemoteException
Send the cache peer with an ordered list ofEventMessages.This enables multiple messages to be delivered in one network invocation.
- Parameters:
eventMessages- a list of typeEventMessage- Throws:
java.rmi.RemoteException
-
getName
java.lang.String getName() throws java.rmi.RemoteExceptionGets the cache name.- Throws:
java.rmi.RemoteException
-
getGuid
java.lang.String getGuid() throws java.rmi.RemoteExceptionGets the globally unique id for the underlyingCacheinstance.- Returns:
- a String representation of the GUID
- Throws:
java.rmi.RemoteException
-
getUrl
java.lang.String getUrl() throws java.rmi.RemoteExceptionThe URL for the remote replicator to connect. The value will only have meaning for a specific implementation of replicator and remote peer.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
- Returns:
- the URL as a string
- Throws:
java.rmi.RemoteException
-
getUrlBase
java.lang.String getUrlBase() throws java.rmi.RemoteExceptionThe URL base for the remote replicator to connect. The value will have meaning only to a specific implementation of replicator and remote peer.- Throws:
java.rmi.RemoteException
-
getKeys
java.util.List getKeys() throws java.rmi.RemoteExceptionReturns 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:
- a list of
Objectkeys - Throws:
java.rmi.RemoteException
-
getQuiet
Element getQuiet(java.io.Serializable key) throws java.rmi.RemoteException
Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.- Parameters:
key- a serializable value- Returns:
- the element, or null, if it does not exist.
- Throws:
java.rmi.RemoteException
-
getElements
java.util.List getElements(java.util.List keys) throws java.rmi.RemoteExceptionGets 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.
- 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
-
-