Package net.sf.ehcache.distribution
Class RMIBootstrapCacheLoader
- java.lang.Object
-
- net.sf.ehcache.distribution.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 booleanasynchronousWhether to load asynchronouslyprotected intmaximumChunkSizeBytesThe 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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.ListacquireCachePeers(Ehcache cache)Acquires the cache peers for this cache.java.lang.Objectclone()Clones this loadervoiddoLoad(Ehcache cache)Bootstraps the cache from a random CachePeer.protected voidfetchAndPutElements(Ehcache cache, java.util.List requestChunk, CachePeer cachePeer)Fetches a chunk of elements from a remote cache peerintgetMaximumChunkSizeBytes()Gets the maximum chunk sizebooleanisAsynchronous()protected java.util.ListlistRemoteCachePeers(Ehcache cache)Package protected List of cache peersvoidload(Ehcache cache)Bootstraps the cache from a random CachePeer.
-
-
-
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:
loadin interfaceBootstrapCacheLoader- Parameters:
cache- cache to load- Throws:
RemoteCacheException- if anything goes wrong with the remote call
-
isAsynchronous
public boolean isAsynchronous()
- Specified by:
isAsynchronousin interfaceBootstrapCacheLoader- 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 inrequestChunk- the chunk of keys to requestcachePeer- 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.CloneNotSupportedExceptionClones this loader- Specified by:
clonein interfaceBootstrapCacheLoader- Overrides:
clonein classjava.lang.Object- Returns:
- clone of this instance
- Throws:
java.lang.CloneNotSupportedException- if the object's class does not support theCloneableinterface.
-
-