public class TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable
BootstrapCacheLoader
that will load Elements into a Terracotta clustered cache, based on a previously
snapshotted key set. It is also responsible to create snapshot files to diskModifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_DEDICATED_THREAD
The default on whether to do the snapshot on a dedicated thread or using the CacheManager's
ScheduledExecutorService |
static long |
DEFAULT_INTERVAL
The default interval in seconds, between each snapshot
|
Constructor and Description |
---|
TerracottaBootstrapCacheLoader(boolean asynchronous,
String directory,
boolean doKeySnapshots)
Constructor
|
TerracottaBootstrapCacheLoader(boolean asynchronous,
String directory,
long interval)
Constructor
|
TerracottaBootstrapCacheLoader(boolean asynchronous,
String directory,
long interval,
boolean onDedicatedThread)
Constructor
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones the loader
|
void |
dispose()
Will shut the keysnapshot thread and other resources down.
|
void |
doLocalKeySnapshot()
Calling this method will result in a snapshot being taken or wait for the one in progress to finish
|
boolean |
isAsynchronous() |
boolean |
isImmediateShutdown()
Whether the on going keysnapshot will finish before the instance is disposed
|
void |
load(Ehcache cache)
Instructs the loader to load the given cache
|
void |
setImmediateShutdown(boolean immediateShutdown)
Sets whether the disposal of the instance will let the potential current key set being written to disk finish, or whether the
shutdown will be immediate
|
void |
setSnapshotOnDispose(boolean doKeySnapshotOnDispose)
Configures the Loader to take a snapshot when it is being disposed
|
isInMemoryLimitReached
public static final long DEFAULT_INTERVAL
public static final boolean DEFAULT_DEDICATED_THREAD
ScheduledExecutorService
public TerracottaBootstrapCacheLoader(boolean asynchronous, String directory, boolean doKeySnapshots)
asynchronous
- do the loading asynchronously, or synchronouslydirectory
- the directory to read snapshot files from, and write them todoKeySnapshots
- Whether to do keysnapshottingpublic TerracottaBootstrapCacheLoader(boolean asynchronous, String directory, long interval)
asynchronous
- do the loading asynchronously, or synchronouslydirectory
- the directory to read snapshot files from, and write them tointerval
- the interval in seconds at which the snapshots of the local key set has to occurpublic TerracottaBootstrapCacheLoader(boolean asynchronous, String directory, long interval, boolean onDedicatedThread)
asynchronous
- do the loading asynchronously, or synchronouslydirectory
- the directory to read snapshot files from, and write them tointerval
- the interval in seconds at which the snapshots of the local key set has to occuronDedicatedThread
- whether to do the snapshot on a dedicated thread or using the CacheManager's
ScheduledExecutorService
public boolean isImmediateShutdown()
Disposable
public void setImmediateShutdown(boolean immediateShutdown)
immediateShutdown
- true if immediate, false to let the snapshot finishpublic void load(Ehcache cache) throws CacheException
load
in interface BootstrapCacheLoader
cache
- cache to loadCacheException
public boolean isAsynchronous()
isAsynchronous
in interface BootstrapCacheLoader
public void dispose()
setImmediateShutdown(boolean)
valuedispose
in interface Disposable
public void doLocalKeySnapshot() throws IOException
IOException
- On exception being thrown while doing the snapshotpublic Object clone() throws CloneNotSupportedException
clone
in interface BootstrapCacheLoader
clone
in class MemoryLimitedCacheLoader
CloneNotSupportedException
- if the object's class does not support the Cloneable
interface.public void setSnapshotOnDispose(boolean doKeySnapshotOnDispose)
doKeySnapshotOnDispose
- whether to snapshot on loader disposalCopyright 2001-2018, Terracotta, Inc.