Package com.tangosol.io.journal
Class BackupJournalRM
- java.lang.Object
-
- com.tangosol.io.journal.BackupJournalRM
-
- All Implemented Interfaces:
Disposable
,BinaryStoreManager
,AutoCloseable
public class BackupJournalRM extends Object implements Disposable, BinaryStoreManager
The BackupJournalRM is a "meta" journal resource manager that is intended to be used for storage of "backup" data. This resource manager passes all writes to a RAM journal until the RAM journal hits a certain load factor, after which it passes all writes to the flash journal that the RAM journal overflows to, and also it evacuates the items stored in RAM to flash.- Since:
- Coherence 3.7.1
- Author:
- cp 2011-03-25
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BackupJournalRM.FlashConsumer
The FlashConsumer is a "dummy" consumer used to obtain a flash journal instance.protected class
BackupJournalRM.JournalImpl
A Journal implementation managed by this Journal Resource Manager.protected class
BackupJournalRM.RamConsumer
The RamConsumer is a pass-through consumer used to obtain a ram journal instance.
-
Constructor Summary
Constructors Constructor Description BackupJournalRM(RamJournalRM jrnlrmRam, double dflLoadFactorLimit)
Construct a BackupJournalRM based on a RamJournalRM.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Deprecated.use the Disposable interfaceJournalBinaryStore
createBinaryStore()
Create a new BinaryStore that will journal its information using this Journal Resource Manager.Journal
createJournal(Journal.JournalConsumer consumer)
Create a new Journal that exposes the storage capabilities of this Journal Resource Manager.void
destroyBinaryStore(BinaryStore store)
Lifecycle method: Destroy a BinaryStore previously created by this manager.void
dispose()
Invoked when all resources owned by the implementer can safely be released.protected void
evacuateRam()
Move all data that is owned by the consumers of this BackupJournalRM from the RAM journal to the flash journal.FlashJournalRM
getFlashJournalRM()
Obtain the underlying FlashJournalRM.double
getLoadFactorLimit()
Determine the high-water mark load factor for the RAM journal above which all writes are delegated to the flash journal.RamJournalRM
getRamJournalRM()
Obtain the underlying RamJournalRM.protected BackupJournalRM.FlashConsumer
instantiateFlashConsumer()
Factory: Instantiate a FlashConsumer object.protected BackupJournalRM.JournalImpl
instantiateJournal()
Instantiate a JournalImpl object.protected BackupJournalRM.JournalImpl
instantiateJournal(Journal jrnlRam, Journal jrnlFlash)
Factory: Instantiate a JournalImpl object.protected BackupJournalRM.RamConsumer
instantiateRamConsumer()
Factory: Instantiate a RamConsumer object.boolean
isLimitExceeded()
Determine if the RAM journal load factor has been exceeded.protected Iterator<BackupJournalRM.JournalImpl>
iterateJournals()
Iterate through the Journal instances that have been created by this Journal Resource Manager but have not been disposed of yet.protected void
registerJournal(BackupJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.protected void
unregisterJournal(BackupJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.
-
-
-
Constructor Detail
-
BackupJournalRM
public BackupJournalRM(RamJournalRM jrnlrmRam, double dflLoadFactorLimit)
Construct a BackupJournalRM based on a RamJournalRM.- Parameters:
jrnlrmRam
- the RamJournalRM to delegate to; note that the RamJournalRM must have a FlashJournalRM behind itdflLoadFactorLimit
- the load factor of the RamJournalRM that will cause the BackupJournalRM to switch to storing data directly in the FlashJournalRM
-
-
Method Detail
-
getRamJournalRM
public RamJournalRM getRamJournalRM()
Obtain the underlying RamJournalRM.- Returns:
- the RamJournalRM used by this BackupJournalRM
-
getFlashJournalRM
public FlashJournalRM getFlashJournalRM()
Obtain the underlying FlashJournalRM.- Returns:
- the FlashJournalRM used by this BackupJournalRM
-
getLoadFactorLimit
public double getLoadFactorLimit()
Determine the high-water mark load factor for the RAM journal above which all writes are delegated to the flash journal.- Returns:
- the RAM journal load factor limit
-
isLimitExceeded
public boolean isLimitExceeded()
Determine if the RAM journal load factor has been exceeded.This method also has the side-effect of evacuating the RAM journal to the flash journal once the limit has been exceeded.
- Returns:
- true iff the RAM journal load factor has been exceeded
-
createBinaryStore
public JournalBinaryStore createBinaryStore()
Create a new BinaryStore that will journal its information using this Journal Resource Manager.- Specified by:
createBinaryStore
in interfaceBinaryStoreManager
- Returns:
- a new instance of JournalBinaryStore that uses this Journal Resource Manager for storage
-
destroyBinaryStore
public void destroyBinaryStore(BinaryStore store)
Lifecycle method: Destroy a BinaryStore previously created by this manager.- Specified by:
destroyBinaryStore
in interfaceBinaryStoreManager
- Parameters:
store
- a BinaryStore object previously created by this manager
-
createJournal
public Journal createJournal(Journal.JournalConsumer consumer)
Create a new Journal that exposes the storage capabilities of this Journal Resource Manager.- Parameters:
consumer
- the JournalConsumer that will be using the Journal- Returns:
- a new instance of Journal that uses this Journal Resource Manager for storage
-
dispose
public void dispose()
Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
dispose
in interfaceDisposable
-
close
public void close()
Deprecated.use the Disposable interfacePrevious to the Disposable interface, clean-up was performed by invoking a close method via reflection.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDisposable
-
evacuateRam
protected void evacuateRam()
Move all data that is owned by the consumers of this BackupJournalRM from the RAM journal to the flash journal.
-
instantiateJournal
protected BackupJournalRM.JournalImpl instantiateJournal()
Instantiate a JournalImpl object.- Returns:
- a JournalImpl instance or subclass thereof
-
instantiateJournal
protected BackupJournalRM.JournalImpl instantiateJournal(Journal jrnlRam, Journal jrnlFlash)
Factory: Instantiate a JournalImpl object.- Parameters:
jrnlRam
- the RAM journal to usejrnlFlash
- the flash journal to use- Returns:
- a JournalImpl instance or subclass thereof
-
registerJournal
protected void registerJournal(BackupJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.- Parameters:
journal
- an instance of JournalImpl created by this Journal Resource Manager
-
unregisterJournal
protected void unregisterJournal(BackupJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.- Parameters:
journal
- an instance of JournalImpl created by this Journal Resource Manager
-
iterateJournals
protected Iterator<BackupJournalRM.JournalImpl> iterateJournals()
Iterate through the Journal instances that have been created by this Journal Resource Manager but have not been disposed of yet.- Returns:
- an Iterator of the current JournalImpl instances
-
instantiateRamConsumer
protected BackupJournalRM.RamConsumer instantiateRamConsumer()
Factory: Instantiate a RamConsumer object.- Returns:
- an instance of RamConsumer or a subclass thereof.
-
instantiateFlashConsumer
protected BackupJournalRM.FlashConsumer instantiateFlashConsumer()
Factory: Instantiate a FlashConsumer object.- Returns:
- an instance of FlashConsumer or a subclass thereof.
-
-