Class RMIBootstrapCacheLoader

  • All Implemented Interfaces:
    java.lang.Cloneable, BootstrapCacheLoader

    public class RMIBootstrapCacheLoader
    extends java.lang.Object
    implements BootstrapCacheLoader, java.lang.Cloneable
    Loads Elements from a random Cache Peer
    Version:
    $Id$
    Author:
    Greg Luck
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean asynchronous
      Whether to load asynchronously
      protected int maximumChunkSizeBytes
      The maximum serialized size of the elements to request from a remote cache peer during bootstrap.
    • Constructor Summary

      Constructors 
      Constructor Description
      RMIBootstrapCacheLoader​(boolean asynchronous, int maximumChunkSize)
      Creates a boostrap cache loader that will work with RMI based distribution
    • Field Detail

      • asynchronous

        protected boolean asynchronous
        Whether to load asynchronously
      • maximumChunkSizeBytes

        protected int maximumChunkSizeBytes
        The maximum serialized size of the elements to request from a remote cache peer during bootstrap.
    • Constructor Detail

      • RMIBootstrapCacheLoader

        public RMIBootstrapCacheLoader​(boolean asynchronous,
                                       int maximumChunkSize)
        Creates a boostrap cache loader that will work with RMI based distribution
        Parameters:
        asynchronous - Whether to load asynchronously
    • Method Detail

      • load

        public void load​(Ehcache cache)
                  throws RemoteCacheException
        Bootstraps the cache from a random CachePeer. Requests are done in chunks estimated at 5MB Serializable size. This balances memory use on each end and network performance.
        Specified by:
        load in interface BootstrapCacheLoader
        Parameters:
        cache - cache to load
        Throws:
        RemoteCacheException - if anything goes wrong with the remote call
      • isAsynchronous

        public boolean isAsynchronous()
        Specified by:
        isAsynchronous in interface BootstrapCacheLoader
        Returns:
        true if this bootstrap loader is asynchronous
      • doLoad

        public void doLoad​(Ehcache cache)
                    throws RemoteCacheException
        Bootstraps the cache from a random CachePeer. Requests are done in chunks estimated at 5MB Serializable size. This balances memory use on each end and network performance.

        Bootstrapping requires the establishment of a cluster. This can be instantaneous for manually configued clusters or may take a number of seconds for multicast ones. This method waits up to 11 seconds for a cluster to form.

        Throws:
        RemoteCacheException - if anything goes wrong with the remote call
      • acquireCachePeers

        protected java.util.List acquireCachePeers​(Ehcache cache)
        Acquires the cache peers for this cache.
        Parameters:
        cache -
      • fetchAndPutElements

        protected void fetchAndPutElements​(Ehcache cache,
                                           java.util.List requestChunk,
                                           CachePeer cachePeer)
                                    throws java.rmi.RemoteException
        Fetches a chunk of elements from a remote cache peer
        Parameters:
        cache - the cache to put elements in
        requestChunk - the chunk of keys to request
        cachePeer - the peer to fetch from
        Throws:
        java.rmi.RemoteException
      • listRemoteCachePeers

        protected java.util.List listRemoteCachePeers​(Ehcache cache)
        Package protected List of cache peers
        Parameters:
        cache -
      • getMaximumChunkSizeBytes

        public int getMaximumChunkSizeBytes()
        Gets the maximum chunk size
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clones this loader
        Specified by:
        clone in interface BootstrapCacheLoader
        Overrides:
        clone in class java.lang.Object
        Returns:
        clone of this instance
        Throws:
        java.lang.CloneNotSupportedException - if the object's class does not support the Cloneable interface.