class KeySnapshotter
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Class and Description |
---|---|
private static class |
KeySnapshotter.SnapShottingThread
Thread doing background snapshots of the local key set
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
cacheName |
private static WeakIdentityConcurrentMap<CacheManager,java.util.concurrent.ScheduledExecutorService> |
INSTANCES |
private static org.slf4j.Logger |
LOG |
private java.lang.Runnable |
onSnapshot |
private static int |
POOL_SIZE |
private RotatingSnapshotFile |
rotatingWriter |
private TerracottaStore |
tcStore |
private java.lang.Thread |
thread |
Constructor and Description |
---|
KeySnapshotter(Ehcache cache,
long interval,
boolean doKeySnapshotOnDedicatedThread,
RotatingSnapshotFile rotatingWriter)
Default Constructor
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
dispose(boolean immediately)
Shuts down the writer thread and cleans up resources
|
(package private) void |
doSnapshot()
Calling this method will result in a snapshot being taken or wait for the one in progress to finish
|
java.lang.String |
getCacheName()
Returns the name of the underlying cache for which this snapshots
|
(package private) static java.util.Collection<CacheManager> |
getKnownCacheManagers()
Accessor to all known cacheManagers (which are also bound to a ScheduledExecutorService)
|
private void |
onSnapshot() |
void |
run() |
(package private) void |
setOnSnapshot(java.lang.Runnable onSnapshot)
Let register a Runnable that will be called on every snapshot happening
|
private static final org.slf4j.Logger LOG
private static final int POOL_SIZE
private static final WeakIdentityConcurrentMap<CacheManager,java.util.concurrent.ScheduledExecutorService> INSTANCES
private final java.lang.String cacheName
private final TerracottaStore tcStore
private final RotatingSnapshotFile rotatingWriter
private final java.lang.Thread thread
private volatile java.lang.Runnable onSnapshot
KeySnapshotter(Ehcache cache, long interval, boolean doKeySnapshotOnDedicatedThread, RotatingSnapshotFile rotatingWriter) throws java.lang.IllegalArgumentException
cache
- the Terracotta clustered Cache to snapshotinterval
- the interval to do the snapshots ondoKeySnapshotOnDedicatedThread
- whether the snapshots have to be done on a dedicated threadrotatingWriter
- the RotatingSnapshotFile to write tojava.lang.IllegalArgumentException
- if interval is less than or equal to zerovoid dispose(boolean immediately)
immediately
- whether to leave the writer finish or shut down immediatelypublic void run()
run
in interface java.lang.Runnable
private void onSnapshot()
static java.util.Collection<CacheManager> getKnownCacheManagers()
void doSnapshot() throws java.io.IOException
java.io.IOException
- On exception being thrown while doing the snapshotvoid setOnSnapshot(java.lang.Runnable onSnapshot)
onSnapshot
- the runnablepublic java.lang.String getCacheName()