Package net.sf.ehcache.terracotta
Class TerracottaBootstrapCacheLoader
- java.lang.Object
-
- net.sf.ehcache.store.MemoryLimitedCacheLoader
-
- net.sf.ehcache.terracotta.TerracottaBootstrapCacheLoader
-
- All Implemented Interfaces:
java.lang.Cloneable,BootstrapCacheLoader,Disposable
public class TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable
ABootstrapCacheLoaderthat will load Elements into a Terracotta clustered cache, based on a previously snapshotted key set. It is also responsible to create snapshot files to disk- Author:
- Alex Snaps
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_DEDICATED_THREADThe default on whether to do the snapshot on a dedicated thread or using the CacheManager'sScheduledExecutorServicestatic longDEFAULT_INTERVALThe default interval in seconds, between each snapshot
-
Constructor Summary
Constructors Constructor Description TerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, boolean doKeySnapshots)ConstructorTerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, long interval)ConstructorTerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, long interval, boolean onDedicatedThread)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Clones the loadervoiddispose()Will shut the keysnapshot thread and other resources down.voiddoLocalKeySnapshot()Calling this method will result in a snapshot being taken or wait for the one in progress to finishbooleanisAsynchronous()booleanisImmediateShutdown()Whether the on going keysnapshot will finish before the instance is disposedvoidload(Ehcache cache)Instructs the loader to load the given cachevoidsetImmediateShutdown(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 immediatevoidsetSnapshotOnDispose(boolean doKeySnapshotOnDispose)Configures the Loader to take a snapshot when it is being disposed-
Methods inherited from class net.sf.ehcache.store.MemoryLimitedCacheLoader
isInMemoryLimitReached
-
-
-
-
Field Detail
-
DEFAULT_INTERVAL
public static final long DEFAULT_INTERVAL
The default interval in seconds, between each snapshot- See Also:
- Constant Field Values
-
DEFAULT_DEDICATED_THREAD
public static final boolean DEFAULT_DEDICATED_THREAD
The default on whether to do the snapshot on a dedicated thread or using the CacheManager'sScheduledExecutorService- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TerracottaBootstrapCacheLoader
public TerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, boolean doKeySnapshots)Constructor- Parameters:
asynchronous- do the loading asynchronously, or synchronouslydirectory- the directory to read snapshot files from, and write them todoKeySnapshots- Whether to do keysnapshotting
-
TerracottaBootstrapCacheLoader
public TerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, long interval)Constructor- Parameters:
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 occur
-
TerracottaBootstrapCacheLoader
public TerracottaBootstrapCacheLoader(boolean asynchronous, java.lang.String directory, long interval, boolean onDedicatedThread)Constructor- Parameters:
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'sScheduledExecutorService
-
-
Method Detail
-
isImmediateShutdown
public boolean isImmediateShutdown()
Whether the on going keysnapshot will finish before the instance is disposed- Returns:
- true if disposable is immediate
- See Also:
Disposable
-
setImmediateShutdown
public 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- Parameters:
immediateShutdown- true if immediate, false to let the snapshot finish
-
load
public void load(Ehcache cache) throws CacheException
Instructs the loader to load the given cache- Specified by:
loadin interfaceBootstrapCacheLoader- Parameters:
cache- cache to load- Throws:
CacheException
-
isAsynchronous
public boolean isAsynchronous()
- Specified by:
isAsynchronousin interfaceBootstrapCacheLoader- Returns:
- true if this bootstrap loader is asynchronous
-
dispose
public void dispose()
Will shut the keysnapshot thread and other resources down. If a snapshot is currently in progress, the method will either shutdown immediately or let the snapshot finish based on the configuredsetImmediateShutdown(boolean)value- Specified by:
disposein interfaceDisposable
-
doLocalKeySnapshot
public void doLocalKeySnapshot() throws java.io.IOExceptionCalling this method will result in a snapshot being taken or wait for the one in progress to finish- Throws:
java.io.IOException- On exception being thrown while doing the snapshot
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionClones the loader- Specified by:
clonein interfaceBootstrapCacheLoader- Overrides:
clonein classMemoryLimitedCacheLoader- Returns:
- clone of this instance
- Throws:
java.lang.CloneNotSupportedException- if the object's class does not support theCloneableinterface.
-
setSnapshotOnDispose
public void setSnapshotOnDispose(boolean doKeySnapshotOnDispose)
Configures the Loader to take a snapshot when it is being disposed- Parameters:
doKeySnapshotOnDispose- whether to snapshot on loader disposal
-
-