Top Description Inners Fields Constructors Methods
net.sf.ehcache.distribution

public Class RMIBootstrapCacheLoader

extends Object
implements BootstrapCacheLoader, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, net.sf.ehcache.bootstrap.BootstrapCacheLoader
Imports
net.sf.ehcache.Ehcache, .Element, net.sf.ehcache.bootstrap.BootstrapCacheLoader, java.io.Serializable, java.rmi.RemoteException, java.util.ArrayList, .List, .Random, org.slf4j.Logger, .LoggerFactory

Loads Elements from a random Cache Peer
Author
Greg Luck
Version
$Id: RMIBootstrapCacheLoader.java 10789 2018-04-26 02:08:13Z adahanne $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
RMIBootstrapCacheLoader.BootstrapThread

A background daemon thread that asynchronously calls doLoad

Field Summary

Modifier and TypeField and Description
protected boolean
asynchronous

Whether to load asynchronously

private static final Logger
protected int
maximumChunkSizeBytes

The maximum serialized size of the elements to request from a remote cache peer during bootstrap.

private static final int

Constructor Summary

AccessConstructor and Description
public
RMIBootstrapCacheLoader(boolean
Whether to load asynchronously
asynchronous
,
int maximumChunkSize)

Creates a boostrap cache loader that will work with RMI based distribution

Method Summary

Modifier and TypeMethod and Description
protected List<E>
acquireCachePeers(Ehcache cache)

Acquires the cache peers for this cache.

public Object
public void
doLoad(Ehcache cache)

Bootstraps the cache from a random CachePeer.

protected void
fetchAndPutElements(Ehcache
the cache to put elements in
cache
,
List<E>
the chunk of keys to request
requestChunk
,
CachePeer
the peer to fetch from
cachePeer
)

Fetches a chunk of elements from a remote cache peer

public int
getMaximumChunkSizeBytes()

Gets the maximum chunk size

public boolean

Returns:

true if this bootstrap loader is asynchronous
isAsynchronous
()

Implements net.sf.ehcache.bootstrap.BootstrapCacheLoader.isAsynchronous.

protected List<E>
listRemoteCachePeers(Ehcache cache)

Package protected List of cache peers

public void
load(Ehcache
cache to load
cache
)

Implements net.sf.ehcache.bootstrap.BootstrapCacheLoader.load.

Bootstraps the cache from a random CachePeer.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asynchronousback to summary
protected boolean asynchronous

Whether to load asynchronously

LOGback to summary
private static final Logger LOG
maximumChunkSizeBytesback to summary
protected int maximumChunkSizeBytes

The maximum serialized size of the elements to request from a remote cache peer during bootstrap.

ONE_SECONDback to summary
private static final int ONE_SECOND

Constructor Detail

RMIBootstrapCacheLoaderback to summary
public RMIBootstrapCacheLoader(boolean asynchronous, int maximumChunkSize)

Creates a boostrap cache loader that will work with RMI based distribution

Parameters
asynchronous:boolean

Whether to load asynchronously

Method Detail

acquireCachePeersback to summary
protected List<E> acquireCachePeers(Ehcache cache)

Acquires the cache peers for this cache.

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Implements net.sf.ehcache.bootstrap.BootstrapCacheLoader.clone.

Clones this loader

Returns:Object

Doc from net.sf.ehcache.bootstrap.BootstrapCacheLoader.clone.

clone of this instance

Annotations
@Override
Exceptions
CloneNotSupportedException:

Doc from net.sf.ehcache.bootstrap.BootstrapCacheLoader.clone.

if the object's class does not support the Cloneable interface.

doLoadback to summary
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.

Exceptions
RemoteCacheException:
if anything goes wrong with the remote call
fetchAndPutElementsback to summary
protected void fetchAndPutElements(Ehcache cache, List<E> requestChunk, CachePeer cachePeer) throws RemoteException

Fetches a chunk of elements from a remote cache peer

Parameters
cache:Ehcache

the cache to put elements in

requestChunk:List<E>

the chunk of keys to request

cachePeer:CachePeer

the peer to fetch from

getMaximumChunkSizeBytesback to summary
public int getMaximumChunkSizeBytes()

Gets the maximum chunk size

isAsynchronousback to summary
public boolean isAsynchronous()

Implements net.sf.ehcache.bootstrap.BootstrapCacheLoader.isAsynchronous.

Returns:boolean

true if this bootstrap loader is asynchronous

listRemoteCachePeersback to summary
protected List<E> listRemoteCachePeers(Ehcache cache)

Package protected List of cache peers

loadback to summary
public void load(Ehcache cache) throws RemoteCacheException

Implements net.sf.ehcache.bootstrap.BootstrapCacheLoader.load.

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.

Parameters
cache:Ehcache

Doc from net.sf.ehcache.bootstrap.BootstrapCacheLoader.load.

cache to load

Exceptions
RemoteCacheException:
if anything goes wrong with the remote call
net.sf.ehcache.distribution back to summary

private final Class RMIBootstrapCacheLoader.BootstrapThread

extends Thread
Class Inheritance

A background daemon thread that asynchronously calls doLoad

Field Summary

Modifier and TypeField and Description
private Ehcache
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

RemoteDebugger thread method.
Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

cacheback to summary
private Ehcache cache

Constructor Detail

BootstrapThreadback to summary
public BootstrapThread(Ehcache cache)

Method Detail

runback to summary
public final void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

RemoteDebugger thread method.