ehcache

net.sf.ehcache.distribution
Class RMIBootstrapCacheLoader

java.lang.Object
  extended by net.sf.ehcache.distribution.RMIBootstrapCacheLoader
All Implemented Interfaces:
BootstrapCacheLoader

public class RMIBootstrapCacheLoader
extends java.lang.Object
implements BootstrapCacheLoader

Loads Elements from a random Cache Peer

Version:
$Id: RMIBootstrapCacheLoader.java 568 2007-12-18 10:39:07Z gregluck $
Author:
Greg Luck

Field Summary
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
RMIBootstrapCacheLoader(boolean asynchronous, int maximumChunkSize)
          Creates a boostrap cache loader that will work with RMI based distribution
 
Method Summary
protected  java.util.List acquireCachePeers(Ehcache cache)
          Acquires the cache peers for this cache.
 java.lang.Object clone()
          Clones this loader
 void doLoad(Ehcache cache)
          Bootstraps the cache from a random CachePeer.
protected  void fetchAndPutElements(Ehcache cache, java.util.List requestChunk, CachePeer cachePeer)
          Fetches a chunk of elements from a remote cache peer
 int getMaximumChunkSizeBytes()
          Gets the maximum chunk size
 boolean isAsynchronous()
           
protected  java.util.List listRemoteCachePeers(Ehcache cache)
          Package protected List of cache peers
 void load(Ehcache cache)
          Bootstraps the cache from a random CachePeer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
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
Throws:
java.lang.CloneNotSupportedException

ehcache