net.sf.ehcache.distribution

Class RMIBootstrapCacheLoader

public class RMIBootstrapCacheLoader extends Object implements BootstrapCacheLoader

Loads Elements from a random Cache Peer

Version: $Id: RMIBootstrapCacheLoader.java 191 2006-09-03 22:41:48Z gregluck $

Author: Greg Luck

Field Summary
protected booleanasynchronous
Whether to load asynchronously
protected intmaximumChunkSizeBytes
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 ListacquireCachePeers(Ehcache cache)
Acquires the cache peers for this cache.
Objectclone()
Clones this loader
voiddoLoad(Ehcache cache)
Bootstraps the cache from a random CachePeer.
protected voidfetchAndPutElements(Ehcache cache, List requestChunk, CachePeer cachePeer)
Fetches a chunk of elements from a remote cache peer
intgetMaximumChunkSizeBytes()
Gets the maximum chunk size
booleanisAsynchronous()
protected ListlistRemoteCachePeers(Ehcache cache)
Package protected List of cache peers
voidload(Ehcache cache)
Bootstraps the cache from a random CachePeer.

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

acquireCachePeers

protected List acquireCachePeers(Ehcache cache)
Acquires the cache peers for this cache.

Parameters: cache

clone

public Object clone()
Clones this loader

doLoad

public void doLoad(Ehcache cache)
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

fetchAndPutElements

protected void fetchAndPutElements(Ehcache cache, List requestChunk, CachePeer cachePeer)
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

getMaximumChunkSizeBytes

public int getMaximumChunkSizeBytes()
Gets the maximum chunk size

isAsynchronous

public boolean isAsynchronous()

Returns: true if this bootstrap loader is asynchronous

listRemoteCachePeers

protected List listRemoteCachePeers(Ehcache cache)
Package protected List of cache peers

Parameters: cache

load

public void load(Ehcache cache)
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.

Throws: RemoteCacheException if anything goes wrong with the remote call