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 classBackupJournalRM.FlashConsumerThe FlashConsumer is a "dummy" consumer used to obtain a flash journal instance.protected classBackupJournalRM.JournalImplA Journal implementation managed by this Journal Resource Manager.protected classBackupJournalRM.RamConsumerThe 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 voidclose()Deprecated.use the Disposable interfaceJournalBinaryStorecreateBinaryStore()Create a new BinaryStore that will journal its information using this Journal Resource Manager.JournalcreateJournal(Journal.JournalConsumer consumer)Create a new Journal that exposes the storage capabilities of this Journal Resource Manager.voiddestroyBinaryStore(BinaryStore store)Lifecycle method: Destroy a BinaryStore previously created by this manager.voiddispose()Invoked when all resources owned by the implementer can safely be released.protected voidevacuateRam()Move all data that is owned by the consumers of this BackupJournalRM from the RAM journal to the flash journal.FlashJournalRMgetFlashJournalRM()Obtain the underlying FlashJournalRM.doublegetLoadFactorLimit()Determine the high-water mark load factor for the RAM journal above which all writes are delegated to the flash journal.RamJournalRMgetRamJournalRM()Obtain the underlying RamJournalRM.protected BackupJournalRM.FlashConsumerinstantiateFlashConsumer()Factory: Instantiate a FlashConsumer object.protected BackupJournalRM.JournalImplinstantiateJournal()Instantiate a JournalImpl object.protected BackupJournalRM.JournalImplinstantiateJournal(Journal jrnlRam, Journal jrnlFlash)Factory: Instantiate a JournalImpl object.protected BackupJournalRM.RamConsumerinstantiateRamConsumer()Factory: Instantiate a RamConsumer object.booleanisLimitExceeded()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 voidregisterJournal(BackupJournalRM.JournalImpl journal)Register a Journal that uses this Journal Resource Manager.protected voidunregisterJournal(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:
createBinaryStorein 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:
destroyBinaryStorein 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:
disposein 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:
closein interfaceAutoCloseable- Specified by:
closein 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.
-
-