Class 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
    • 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 it
        dflLoadFactorLimit - 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 interface BinaryStoreManager
        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 interface BinaryStoreManager
        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 interface Disposable
      • close

        public void close()
        Deprecated.
        use the Disposable interface
        Previous to the Disposable interface, clean-up was performed by invoking a close method via reflection.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Disposable
      • 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 use
        jrnlFlash - 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.