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

public Class TerracottaBootstrapCacheLoader

extends MemoryLimitedCacheLoader
implements Disposable
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.Disposable
Imports
java.io.IOException, java.util.Set, net.sf.ehcache.CacheException, .CacheManager, .DiskStorePathManager, .Disposable, .Ehcache, .Status, net.sf.ehcache.distribution.RemoteCacheException, net.sf.ehcache.store.MemoryLimitedCacheLoader, org.slf4j.Logger, .LoggerFactory

A net.sf.ehcache.bootstrap.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 disk
Author
Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
TerracottaBootstrapCacheLoader.BootstrapThread

A background daemon thread that asynchronously calls doLoad

Field Summary

Modifier and TypeField and Description
private final boolean
public static final boolean
DEFAULT_DEDICATED_THREAD

The default on whether to do the snapshot on a dedicated thread or using the CacheManager's java.util.concurrent.ScheduledExecutorService

public static final long
DEFAULT_INTERVAL

The default interval in seconds, between each snapshot

private final DiskStorePathManager
private final boolean
private final boolean
private volatile boolean
private volatile boolean
private final long
private volatile KeySnapshotter
private static final Logger

Constructor Summary

AccessConstructor and Description
private
TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous, final String directory, final long interval, final boolean doKeySnapshotOnDedicatedThread)

public
TerracottaBootstrapCacheLoader(final boolean
do the loading asynchronously, or synchronously
asynchronous
,
String
the directory to read snapshot files from, and write them to
directory
,
boolean
Whether to do keysnapshotting
doKeySnapshots
)

Constructor

public
TerracottaBootstrapCacheLoader(final boolean
do the loading asynchronously, or synchronously
asynchronous
,
String
the directory to read snapshot files from, and write them to
directory
,
long
the interval in seconds at which the snapshots of the local key set has to occur
interval
)

Constructor

public
TerracottaBootstrapCacheLoader(final boolean
do the loading asynchronously, or synchronously
asynchronous
,
String
the directory to read snapshot files from, and write them to
directory
,
long
the interval in seconds at which the snapshots of the local key set has to occur
interval
,
boolean
whether to do the snapshot on a dedicated thread or using the CacheManager's ScheduledExecutorService
onDedicatedThread
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public Object
public void
dispose()

Implements net.sf.ehcache.Disposable.dispose.

Will shut the keysnapshot thread and other resources down.
private void
doLoad(final Ehcache cache)

public void
doLocalKeySnapshot()

Calling this method will result in a snapshot being taken or wait for the one in progress to finish

pack-priv KeySnapshotter

Returns:

the KeySnapshotter used by this loader instance
getKeySnapshotter
()

Accessor to the associated KeySnapshotter

public boolean
public boolean

Returns:

true if disposable is immediate
isImmediateShutdown
()

Whether the on going keysnapshot will finish before the instance is disposed

public void
load(final Ehcache
cache to load
cache
)

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

Instructs the loader to load the given cache
public void
setImmediateShutdown(final boolean
true if immediate, false to let the snapshot finish
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

public void
setSnapshotOnDispose(final boolean
whether to snapshot on loader disposal
doKeySnapshotOnDispose
)

Configures the Loader to take a snapshot when it is being disposed

Inherited from net.sf.ehcache.store.MemoryLimitedCacheLoader:
isInMemoryLimitReached

Field Detail

aSynchronousback to summary
private final boolean aSynchronous
DEFAULT_DEDICATED_THREADback to summary
public static final boolean DEFAULT_DEDICATED_THREAD

The default on whether to do the snapshot on a dedicated thread or using the CacheManager's java.util.concurrent.ScheduledExecutorService

DEFAULT_INTERVALback to summary
public static final long DEFAULT_INTERVAL

The default interval in seconds, between each snapshot

diskStorePathManagerback to summary
private final DiskStorePathManager diskStorePathManager
doKeySnapshotback to summary
private final boolean doKeySnapshot
doKeySnapshotOnDedicatedThreadback to summary
private final boolean doKeySnapshotOnDedicatedThread
doKeySnapshotOnDisposeback to summary
private volatile boolean doKeySnapshotOnDispose
immediateShutdownback to summary
private volatile boolean immediateShutdown
intervalback to summary
private final long interval
keySnapshotterback to summary
private volatile KeySnapshotter keySnapshotter
LOGback to summary
private static final Logger LOG

Constructor Detail

TerracottaBootstrapCacheLoaderback to summary
private TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous, final String directory, final long interval, final boolean doKeySnapshotOnDedicatedThread)
TerracottaBootstrapCacheLoaderback to summary
public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, boolean doKeySnapshots)

Constructor

Parameters
asynchronous:boolean

do the loading asynchronously, or synchronously

directory:String

the directory to read snapshot files from, and write them to

doKeySnapshots:boolean

Whether to do keysnapshotting

TerracottaBootstrapCacheLoaderback to summary
public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval)

Constructor

Parameters
asynchronous:boolean

do the loading asynchronously, or synchronously

directory:String

the directory to read snapshot files from, and write them to

interval:long

the interval in seconds at which the snapshots of the local key set has to occur

TerracottaBootstrapCacheLoaderback to summary
public TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval, boolean onDedicatedThread)

Constructor

Parameters
asynchronous:boolean

do the loading asynchronously, or synchronously

directory:String

the directory to read snapshot files from, and write them to

interval:long

the interval in seconds at which the snapshots of the local key set has to occur

onDedicatedThread:boolean

whether to do the snapshot on a dedicated thread or using the CacheManager's ScheduledExecutorService

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides net.sf.ehcache.store.MemoryLimitedCacheLoader.clone.

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

Doc from net.sf.ehcache.store.MemoryLimitedCacheLoader.clone.

Clones the 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.

disposeback to summary
public void dispose()

Implements net.sf.ehcache.Disposable.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 configured setImmediateShutdown(boolean) value

doLoadback to summary
private void doLoad(final Ehcache cache)
doLocalKeySnapshotback to summary
public void doLocalKeySnapshot() throws IOException

Calling this method will result in a snapshot being taken or wait for the one in progress to finish

Exceptions
IOException:
On exception being thrown while doing the snapshot
getKeySnapshotterback to summary
pack-priv KeySnapshotter getKeySnapshotter()

Accessor to the associated KeySnapshotter

Returns:KeySnapshotter

the KeySnapshotter used by this loader instance

isAsynchronousback to summary
public boolean isAsynchronous()

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

Returns:boolean

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

true if this bootstrap loader is asynchronous

isImmediateShutdownback to summary
public boolean isImmediateShutdown()

Whether the on going keysnapshot will finish before the instance is disposed

Returns:boolean

true if disposable is immediate

See Also
Disposable
loadback to summary
public void load(final Ehcache cache) throws CacheException

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

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

Instructs the loader to load the given cache

Parameters
cache:Ehcache

cache to load

setImmediateShutdownback to summary
public void setImmediateShutdown(final 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:boolean

true if immediate, false to let the snapshot finish

setSnapshotOnDisposeback to summary
public void setSnapshotOnDispose(final boolean doKeySnapshotOnDispose)

Configures the Loader to take a snapshot when it is being disposed

Parameters
doKeySnapshotOnDispose:boolean

whether to snapshot on loader disposal

net.sf.ehcache.terracotta back to summary

private final Class TerracottaBootstrapCacheLoader.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.

Annotations
@Override