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

pack-priv Class KeySnapshotter

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
net.sf.ehcache.Cache, .CacheManager, .CacheStoreHelper, .Ehcache, net.sf.ehcache.store.Store, .TerracottaStore, net.sf.ehcache.util.WeakIdentityConcurrentMap, org.slf4j.Logger, .LoggerFactory, java.io.IOException, java.util.Collection, java.util.concurrent.ScheduledExecutorService, .ScheduledFuture, .ScheduledThreadPoolExecutor, .TimeUnit

A class that will snapshot the local keySet of a Terracotta clustered cache to disk
Author
Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
KeySnapshotter.SnapShottingThread

Thread doing background snapshots of the local key set

Field Summary

Modifier and TypeField and Description
private final String
private static final WeakIdentityConcurrentMap<CacheManager, ScheduledExecutorService>
private static final Logger
private volatile Runnable
private static final int
private final RotatingSnapshotFile
private final ScheduledFuture<?>
private volatile TerracottaStore
private final Thread

Constructor Summary

AccessConstructor and Description
pack-priv
KeySnapshotter(final Ehcache
the Terracotta clustered Cache to snapshot
cache
,
final long
the interval to do the snapshots on
interval
,
final boolean
whether the snapshots have to be done on a dedicated thread
doKeySnapshotOnDedicatedThread
,
final RotatingSnapshotFile
the RotatingSnapshotFile to write to
rotatingWriter
)

Default Constructor

Method Summary

Modifier and TypeMethod and Description
pack-priv void
dispose(boolean
whether to leave the writer finish or shut down immediately
immediately
)

Shuts down the writer thread and cleans up resources

pack-priv void
doSnapshot()

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

public String

Returns:

The name of the cache
getCacheName
()

Returns the name of the underlying cache for which this snapshots

pack-priv static Collection<CacheManager>

Returns:

the collection of known CacheManagers
getKnownCacheManagers
()

Accessor to all known cacheManagers (which are also bound to a ScheduledExecutorService)

private ScheduledExecutorService
private void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
pack-priv void
setOnSnapshot(final Runnable
the runnable
onSnapshot
)

Let register a Runnable that will be called on every snapshot happening

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheNameback to summary
private final String cacheName
INSTANCESback to summary
private static final WeakIdentityConcurrentMap<CacheManager, ScheduledExecutorService> INSTANCES
LOGback to summary
private static final Logger LOG
onSnapshotback to summary
private volatile Runnable onSnapshot
POOL_SIZEback to summary
private static final int POOL_SIZE
rotatingWriterback to summary
private final RotatingSnapshotFile rotatingWriter
scheduledFutureback to summary
private final ScheduledFuture<?> scheduledFuture
tcStoreback to summary
private volatile TerracottaStore tcStore
threadback to summary
private final Thread thread

Constructor Detail

KeySnapshotterback to summary
pack-priv KeySnapshotter(final Ehcache cache, final long interval, final boolean doKeySnapshotOnDedicatedThread, final RotatingSnapshotFile rotatingWriter) throws IllegalArgumentException

Default Constructor

Parameters
cache:Ehcache

the Terracotta clustered Cache to snapshot

interval:long

the interval to do the snapshots on

doKeySnapshotOnDedicatedThread:boolean

whether the snapshots have to be done on a dedicated thread

rotatingWriter:RotatingSnapshotFile

the RotatingSnapshotFile to write to

Exceptions
IllegalArgumentException:
if interval is less than or equal to zero

Method Detail

disposeback to summary
pack-priv void dispose(boolean immediately)

Shuts down the writer thread and cleans up resources

Parameters
immediately:boolean

whether to leave the writer finish or shut down immediately

doSnapshotback to summary
pack-priv void doSnapshot() 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
getCacheNameback to summary
public String getCacheName()

Returns the name of the underlying cache for which this snapshots

Returns:String

The name of the cache

getKnownCacheManagersback to summary
pack-priv static Collection<CacheManager> getKnownCacheManagers()

Accessor to all known cacheManagers (which are also bound to a ScheduledExecutorService)

Returns:Collection<CacheManager>

the collection of known CacheManagers

getScheduledExecutorServiceback to summary
private ScheduledExecutorService getScheduledExecutorService(final CacheManager cacheManager)
onSnapshotback to summary
private void onSnapshot()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

setOnSnapshotback to summary
pack-priv void setOnSnapshot(final Runnable onSnapshot)

Let register a Runnable that will be called on every snapshot happening

Parameters
onSnapshot:Runnable

the runnable

net.sf.ehcache.terracotta back to summary

private Class KeySnapshotter.SnapShottingThread

extends Thread
Class Inheritance

Thread doing background snapshots of the local key set

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
SnapShottingThread(final Runnable runnable, final long interval, final String threadName)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

intervalback to summary
private final long interval
lastRunback to summary
private long lastRun

Constructor Detail

SnapShottingThreadback to summary
public SnapShottingThread(final Runnable runnable, final long interval, final String threadName)

Method Detail

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override