ehcache

net.sf.ehcache.distribution
Class RMIBootstrapCacheLoader

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

public class RMIBootstrapCacheLoader
extends Object
implements BootstrapCacheLoader, Cloneable

Loads Elements from a random Cache Peer

Version:
$Id: RMIBootstrapCacheLoader.java 5594 2012-05-07 16:04:31Z cdennis $
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  List acquireCachePeers(Ehcache cache)
          Acquires the cache peers for this cache.
 Object clone()
          Clones this loader
 void doLoad(Ehcache cache)
          Bootstraps the cache from a random CachePeer.
protected  void fetchAndPutElements(Ehcache cache, List requestChunk, CachePeer cachePeer)
          Fetches a chunk of elements from a remote cache peer
 int getMaximumChunkSizeBytes()
          Gets the maximum chunk size
 boolean isAsynchronous()
           
protected  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 List acquireCachePeers(Ehcache cache)
Acquires the cache peers for this cache.

Parameters:
cache -

fetchAndPutElements

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

listRemoteCachePeers

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

Parameters:
cache -

getMaximumChunkSizeBytes

public int getMaximumChunkSizeBytes()
Gets the maximum chunk size


clone

public Object clone()
             throws CloneNotSupportedException
Clones this loader

Specified by:
clone in interface BootstrapCacheLoader
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

ehcache

Copyright 2001-2015, Terracotta, Inc.