Class TransactionalRMICachePeer

  • All Implemented Interfaces:
    java.io.Serializable, java.rmi.Remote, CachePeer

    public class TransactionalRMICachePeer
    extends RMICachePeer
    An RMI based implementation of CachePeer supporting transactions.
    Author:
    Ludovic Orban
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.rmi.server.RemoteObject

        ref
    • 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.List getElements​(java.util.List keys)
      Gets a list of elements from the cache, for a list of keys, without updating Element statistics.
      java.util.List getKeys()
      Returns a list of all elements in the cache, whether or not they are expired.
      Element getQuiet​(java.io.Serializable key)
      Gets an element from the cache, without updating Element statistics.
      void put​(Element element)
      Puts an Element into the underlying cache without notifying listeners or updating statistics.
      boolean remove​(java.io.Serializable key)
      Removes an Element from the underlying cache without notifying listeners or updating statistics.
      void removeAll()
      Removes all cached items.
      void send​(java.util.List eventMessages)
      Send the cache peer with an ordered list of EventMessages
      • Methods inherited from class java.rmi.server.UnicastRemoteObject

        clone, exportObject, exportObject, 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, toStub
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 peer
        hostName - 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 - 65536
        remoteObjectPort - 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
        socketTimeoutMillis -
        Throws:
        java.rmi.RemoteException
    • Method Detail

      • getKeys

        public java.util.List getKeys()
                               throws java.rmi.RemoteException
        Description copied from class: RMICachePeer
        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.

        Specified by:
        getKeys in interface CachePeer
        Overrides:
        getKeys in class RMICachePeer
        Returns:
        a list of Object keys
        Throws:
        java.rmi.RemoteException
      • getQuiet

        public Element getQuiet​(java.io.Serializable key)
                         throws java.rmi.RemoteException
        Description copied from class: RMICachePeer
        Gets an element from the cache, without updating Element statistics. Cache statistics are still updated.
        Specified by:
        getQuiet in interface CachePeer
        Overrides:
        getQuiet in class RMICachePeer
        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.RemoteException
        Description copied from class: RMICachePeer
        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.

        Specified by:
        getElements in interface CachePeer
        Overrides:
        getElements in class RMICachePeer
        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: RMICachePeer
        Puts an Element into the underlying cache without notifying listeners or updating statistics.
        Specified by:
        put in interface CachePeer
        Overrides:
        put in class RMICachePeer
        Throws:
        java.lang.IllegalArgumentException - if the element is null
        java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
        java.rmi.RemoteException
      • remove

        public boolean remove​(java.io.Serializable key)
                       throws java.rmi.RemoteException,
                              java.lang.IllegalStateException
        Description copied from class: RMICachePeer
        Removes an Element from the underlying cache without notifying listeners or updating statistics.
        Specified by:
        remove in interface CachePeer
        Overrides:
        remove in class RMICachePeer
        Returns:
        true if the element was removed, false if it was not found in the cache
        Throws:
        java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
        java.rmi.RemoteException
      • removeAll

        public void removeAll()
                       throws java.rmi.RemoteException,
                              java.lang.IllegalStateException
        Description copied from class: RMICachePeer
        Removes all cached items.
        Specified by:
        removeAll in interface CachePeer
        Overrides:
        removeAll in class RMICachePeer
        Throws:
        java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
        java.rmi.RemoteException
      • send

        public void send​(java.util.List eventMessages)
                  throws java.rmi.RemoteException
        Description copied from class: RMICachePeer
        Send the cache peer with an ordered list of EventMessages

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

        Specified by:
        send in interface CachePeer
        Overrides:
        send in class RMICachePeer
        Parameters:
        eventMessages - a list of type EventMessage
        Throws:
        java.rmi.RemoteException