Class AbstractJournalRM.JournalFile

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected AtomicLong m_cbReleased
      Amount of data that has been released.
      protected AtomicLong m_cbWritten
      Amount of data that has been written.
      protected boolean m_fNotifiedFull
      Set to true when the JournalFile is notified that it is full and its contents have been fully written.
      protected AbstractJournalRM.JournalFile m_jrnlfileNext
      The JournalFile that "comes after" this JournalFile in the journal.
      protected AtomicLong m_lStateOffset
      Current state of the JournalFile and the appending offset within the file.
      protected int m_nFile
      The file index.
      static long STATE_APPENDING
      State: File is being appended to.
      static long STATE_CONGESTION
      State: File is appending, but there is congestion forcing a wait by all appending threads.
      static long STATE_DISCARDED
      State: File has been discarded.
      static long STATE_EVACUATING
      State: Remaining entries in the file are being evacuated.
      static long STATE_FULL
      State: File is full and appends are no longer occurring.
      static long STATE_GARBAGE
      State: File is garbage and can safely be discarded.
      static long STATE_MASK
      The bits of the m_lStateOffset that are used for the current state of the file (one of the STATE_* constants).
      static long STATE_RESERVED
      State: File is reserved by the CollectorDaemon.
    • Constructor Summary

      Constructors 
      Constructor Description
      JournalFile​(int nFile)
      Construct a Journal File.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean compareAndSetOffset​(long lPrevValue, long lOffset)
      Specify the new offset value of this JournalFile.
      protected boolean compareAndSetState​(long lPrevValue, long lState)
      Specify the current state of this JournalFile unless the state is STATE_RESERVED as it is a special case and should be set via setReserved(boolean).
      abstract void dispose()
      Invoked when all resources owned by the implementer can safely be released.
      abstract long enqueue​(Binary bin)
      Enqueue a Binary value to be written to this file, returning a ticket, or return 0L if this file is full and the append has to occur to a new file.
      void evacuate()
      Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.
      long getBytesWritten()
      Determine the number of bytes written.
      protected String getDescription()
      Format the object attributes into a String for inclusion in the String returned from the toString() method.
      int getFileId()
      Determine the file id (0-511) for this JournalFile.
      AbstractJournalRM.JournalFile getNextJournalFile()
      Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.
      long getOffset()
      Determine the current append offset (or length) of this JournalFile.
      protected long getOffset​(long lStateOffset)
      Determine the current append offset (or length) from the provided long.
      long getReleased()
      Determine the number of bytes that have been released from this JournalFile.
      long getState()
      Determine the current state of this JournalFile.
      protected long getState​(long lState)
      Determine the state of the provided (potentially) unmasked lState.
      boolean isAppending()
      Return whether the JournalFile can be appended to.
      boolean isReserved()
      Return whether the JournalFile has been reserved thus can not be used by clients.
      void notifyWriteCompleted()
      Called by the CollectorDaemon the first time that the JournalFile is encountered in its FULL state and its data has all been written.
      abstract Binary read​(long lTicket)
      Read the Binary associated with the specified ticket from the journal file.
      void release​(int cbValue)
      Release the specified number of bytes from this journal file.
      void setNextJournalFile​(AbstractJournalRM.JournalFile jrnlfileNext)
      Once this file has been filled, it gets a reference to the file that follows it.
      protected void setReserved​(boolean fReserved)
      Specify whether the current JournalFile is reserved.
      protected void setState​(long lState)
      Specify the current state of this JournalFile.
      String toString()
      void touch()
      This method is called periodically by the collector daemon to indicate that the file is still being used.
      • Methods inherited from interface com.oracle.coherence.common.base.Disposable

        close
    • Field Detail

      • STATE_APPENDING

        public static final long STATE_APPENDING
        State: File is being appended to.
        See Also:
        Constant Field Values
      • STATE_CONGESTION

        public static final long STATE_CONGESTION
        State: File is appending, but there is congestion forcing a wait by all appending threads.
        See Also:
        Constant Field Values
      • STATE_FULL

        public static final long STATE_FULL
        State: File is full and appends are no longer occurring.
        See Also:
        Constant Field Values
      • STATE_EVACUATING

        public static final long STATE_EVACUATING
        State: Remaining entries in the file are being evacuated.
        See Also:
        Constant Field Values
      • STATE_GARBAGE

        public static final long STATE_GARBAGE
        State: File is garbage and can safely be discarded.
        See Also:
        Constant Field Values
      • STATE_DISCARDED

        public static final long STATE_DISCARDED
        State: File has been discarded.
        See Also:
        Constant Field Values
      • STATE_RESERVED

        public static final long STATE_RESERVED
        State: File is reserved by the CollectorDaemon. This state differs from the others as it may exist in combination with the other states thus is a marker.
        See Also:
        Constant Field Values
      • STATE_MASK

        public static final long STATE_MASK
        The bits of the m_lStateOffset that are used for the current state of the file (one of the STATE_* constants).
        See Also:
        Constant Field Values
      • m_nFile

        protected final int m_nFile
        The file index. Immutable field.
      • m_lStateOffset

        protected final AtomicLong m_lStateOffset
        Current state of the JournalFile and the appending offset within the file. These two values are maintained in a single "long" value so that the file can be appended to and transitioned from state to state in an atomic manner, i.e. when the file gets close to being full, it can be transitioned from the "appending" state in the same manner as an append itself is done (which simply updates the offset).
      • m_cbWritten

        protected final AtomicLong m_cbWritten
        Amount of data that has been written.
      • m_cbReleased

        protected final AtomicLong m_cbReleased
        Amount of data that has been released.
      • m_jrnlfileNext

        protected volatile AbstractJournalRM.JournalFile m_jrnlfileNext
        The JournalFile that "comes after" this JournalFile in the journal.
      • m_fNotifiedFull

        protected boolean m_fNotifiedFull
        Set to true when the JournalFile is notified that it is full and its contents have been fully written.
    • Constructor Detail

      • JournalFile

        public JournalFile​(int nFile)
        Construct a Journal File.
        Parameters:
        nFile - the file number in the range 0-511 (inclusive)
    • Method Detail

      • enqueue

        public abstract long enqueue​(Binary bin)
        Enqueue a Binary value to be written to this file, returning a ticket, or return 0L if this file is full and the append has to occur to a new file.
        Parameters:
        bin - the value to append to the journal file
        Returns:
        a ticket if the Binary has successfully been enqueued, or 0L if the file is full
      • read

        public abstract Binary read​(long lTicket)
        Read the Binary associated with the specified ticket from the journal file.
        Parameters:
        lTicket - a ticket previously returned from enqueue(com.tangosol.util.Binary)
        Returns:
        the Binary value that is associated with the ticket
      • release

        public void release​(int cbValue)
        Release the specified number of bytes from this journal file.
        Parameters:
        cbValue - the number of bytes that are being released
      • getFileId

        public int getFileId()
        Determine the file id (0-511) for this JournalFile.
        Returns:
        the file id for this JournalFile
      • getState

        public long getState()
        Determine the current state of this JournalFile.
        Returns:
        the one of the STATE_* constants
      • getOffset

        public long getOffset()
        Determine the current append offset (or length) of this JournalFile.
        Returns:
        the current append offset
      • getBytesWritten

        public long getBytesWritten()
        Determine the number of bytes written.
        Returns:
        the number of bytes that have been reported to have been written
      • getReleased

        public long getReleased()
        Determine the number of bytes that have been released from this JournalFile.
        Returns:
        the number of bytes that have been released from this file
      • isAppending

        public boolean isAppending()
        Return whether the JournalFile can be appended to.
        Returns:
        whether the JournalFile can be appended to
      • isReserved

        public boolean isReserved()
        Return whether the JournalFile has been reserved thus can not be used by clients.
        Returns:
        whether the JournalFile has been reserved
      • touch

        public void touch()
        This method is called periodically by the collector daemon to indicate that the file is still being used.
      • getNextJournalFile

        public AbstractJournalRM.JournalFile getNextJournalFile()
        Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.
        Returns:
        the next file in the journal, or null if it has not yet been set
      • setNextJournalFile

        public void setNextJournalFile​(AbstractJournalRM.JournalFile jrnlfileNext)
        Once this file has been filled, it gets a reference to the file that follows it.
        Parameters:
        jrnlfileNext - the next file in the journal
      • getDescription

        protected String getDescription()
        Format the object attributes into a String for inclusion in the String returned from the toString() method.
        Returns:
        a comma-delimited String listing the attributes of this object in the form "attribute=value"
      • notifyWriteCompleted

        public void notifyWriteCompleted()
        Called by the CollectorDaemon the first time that the JournalFile is encountered in its FULL state and its data has all been written.
      • evacuate

        public void evacuate()
        Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.
      • setReserved

        protected void setReserved​(boolean fReserved)
        Specify whether the current JournalFile is reserved.
        Parameters:
        fReserved - whether the JournalFile is reserved
      • dispose

        public abstract 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
      • getState

        protected long getState​(long lState)
        Determine the state of the provided (potentially) unmasked lState.
        Parameters:
        lState - the journal file state
        Returns:
        the state only value
      • setState

        protected void setState​(long lState)
        Specify the current state of this JournalFile.
        Parameters:
        lState - one of the STATE_* constants
      • compareAndSetState

        protected boolean compareAndSetState​(long lPrevValue,
                                             long lState)
        Specify the current state of this JournalFile unless the state is STATE_RESERVED as it is a special case and should be set via setReserved(boolean).
        Parameters:
        lPrevValue - the expected state value
        lState - one of the STATE_* constants, except STATE_RESERVED
        Returns:
        true if the value was successfully cas'd
      • compareAndSetOffset

        protected boolean compareAndSetOffset​(long lPrevValue,
                                              long lOffset)
        Specify the new offset value of this JournalFile.
        Parameters:
        lPrevValue - the expected state value
        lOffset - the new offset value
        Returns:
        true if the value was successfully cas'd
      • getOffset

        protected long getOffset​(long lStateOffset)
        Determine the current append offset (or length) from the provided long.
        Parameters:
        lStateOffset - the long value holding both the state and offset
        Returns:
        the current append offset