Package com.tangosol.io.journal
Class AbstractJournalRM.JournalFile
java.lang.Object
com.tangosol.io.journal.AbstractJournalRM.JournalFile
- All Implemented Interfaces:
- Disposable,- AutoCloseable
- Direct Known Subclasses:
- AbstractJournalRM.CollectorDaemon.InvokeGCJournalFile,- FlashJournalRM.JournalFile,- RamJournalRM.JournalFile
- Enclosing class:
- AbstractJournalRM
A JournalFile object is created for each file used to store the journal
 contents. It is created in an initial "append" mode -- which may be
 interrupted from time to time by a "congested" mode if writes are
 falling too far behind, it then transitions to a "full" mode, and
 once enough of its storage has been released it transitions to an
 "evacuating" mode, which (once evacuated) becomes "garbage" and (upon
 deletion) is "discarded".
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final ConditionA condition associated with a synchronization lock above that is used to wait for notification and to notify waiting threads.protected final LockThe lock that should be used to control concurrent access to this Journal File.protected final AtomicLongAmount of data that has been released.protected final AtomicLongAmount of data that has been written.protected booleanSet to true when the JournalFile is notified that it is full and its contents have been fully written.protected AbstractJournalRM.JournalFileThe JournalFile that "comes after" this JournalFile in the journal.protected final AtomicLongCurrent state of the JournalFile and the appending offset within the file.protected final intThe file index.static final longState: File is being appended to.static final longState: File is appending, but there is congestion forcing a wait by all appending threads.static final longState: File has been discarded.static final longState: Remaining entries in the file are being evacuated.static final longState: File is full and appends are no longer occurring.static final longState: File is garbage and can safely be discarded.static final longThe bits of them_lStateOffsetthat are used for the current state of the file (one of the STATE_* constants).static final longState: File is reserved by the CollectorDaemon.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancompareAndSetOffset(long lPrevValue, long lOffset) Specify the new offset value of this JournalFile.protected booleancompareAndSetState(long lPrevValue, long lState) Specify the current state of this JournalFile unless the state isSTATE_RESERVEDas it is a special case and should be set viasetReserved(boolean).abstract voiddispose()Invoked when all resources owned by the implementer can safely be released.abstract longEnqueue 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.voidevacuate()Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.longDetermine the number of bytes written.protected StringFormat the object attributes into a String for inclusion in the String returned from thetoString()method.intDetermine the file id (0-511) for this JournalFile.Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.longDetermine the current append offset (or length) of this JournalFile.protected longgetOffset(long lStateOffset) Determine the current append offset (or length) from the provided long.longDetermine the number of bytes that have been released from this JournalFile.longgetState()Determine the current state of this JournalFile.protected longgetState(long lState) Determine the state of the provided (potentially) unmaskedlState.booleanReturn whether the JournalFile can be appended to.booleanReturn whether the JournalFile has been reserved thus can not be used by clients.voidCalled by the CollectorDaemon the first time that the JournalFile is encountered in its FULL state and its data has all been written.abstract Binaryread(long lTicket) Read the Binary associated with the specified ticket from the journal file.voidrelease(int cbValue) Release the specified number of bytes from this journal file.voidsetNextJournalFile(AbstractJournalRM.JournalFile jrnlfileNext) Once this file has been filled, it gets a reference to the file that follows it.protected voidsetReserved(boolean fReserved) Specify whether the current JournalFile is reserved.protected voidsetState(long lState) Specify the current state of this JournalFile.toString()voidtouch()This method is called periodically by the collector daemon to indicate that the file is still being used.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.base.Disposableclose
- 
Field Details- 
STATE_APPENDINGpublic static final long STATE_APPENDINGState: File is being appended to.- See Also:
 
- 
STATE_CONGESTIONpublic static final long STATE_CONGESTIONState: File is appending, but there is congestion forcing a wait by all appending threads.- See Also:
 
- 
STATE_FULLpublic static final long STATE_FULLState: File is full and appends are no longer occurring.- See Also:
 
- 
STATE_EVACUATINGpublic static final long STATE_EVACUATINGState: Remaining entries in the file are being evacuated.- See Also:
 
- 
STATE_GARBAGEpublic static final long STATE_GARBAGEState: File is garbage and can safely be discarded.- See Also:
 
- 
STATE_DISCARDEDpublic static final long STATE_DISCARDEDState: File has been discarded.- See Also:
 
- 
STATE_RESERVEDpublic static final long STATE_RESERVEDState: 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:
 
- 
STATE_MASKpublic static final long STATE_MASKThe bits of them_lStateOffsetthat are used for the current state of the file (one of the STATE_* constants).- See Also:
 
- 
m_nFileprotected final int m_nFileThe file index. Immutable field.
- 
m_lStateOffsetCurrent 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_cbWrittenAmount of data that has been written.
- 
m_cbReleasedAmount of data that has been released.
- 
m_jrnlfileNextThe JournalFile that "comes after" this JournalFile in the journal.
- 
m_fNotifiedFullprotected boolean m_fNotifiedFullSet to true when the JournalFile is notified that it is full and its contents have been fully written.
- 
f_journalFileLockThe lock that should be used to control concurrent access to this Journal File.
- 
f_journalFileConditionA condition associated with a synchronization lock above that is used to wait for notification and to notify waiting threads.
 
- 
- 
Constructor Details- 
JournalFilepublic JournalFile(int nFile) Construct a Journal File.- Parameters:
- nFile- the file number in the range 0-511 (inclusive)
 
 
- 
- 
Method Details- 
enqueueEnqueue 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
 
- 
readRead 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
 
- 
releasepublic void release(int cbValue) Release the specified number of bytes from this journal file.- Parameters:
- cbValue- the number of bytes that are being released
 
- 
getFileIdpublic int getFileId()Determine the file id (0-511) for this JournalFile.- Returns:
- the file id for this JournalFile
 
- 
getStatepublic long getState()Determine the current state of this JournalFile.- Returns:
- the one of the STATE_* constants
 
- 
getOffsetpublic long getOffset()Determine the current append offset (or length) of this JournalFile.- Returns:
- the current append offset
 
- 
getBytesWrittenpublic long getBytesWritten()Determine the number of bytes written.- Returns:
- the number of bytes that have been reported to have been written
 
- 
getReleasedpublic 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
 
- 
isAppendingpublic boolean isAppending()Return whether the JournalFile can be appended to.- Returns:
- whether the JournalFile can be appended to
 
- 
isReservedpublic boolean isReserved()Return whether the JournalFile has been reserved thus can not be used by clients.- Returns:
- whether the JournalFile has been reserved
 
- 
touchpublic void touch()This method is called periodically by the collector daemon to indicate that the file is still being used.
- 
getNextJournalFileDetermine 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
 
- 
setNextJournalFileOnce this file has been filled, it gets a reference to the file that follows it.- Parameters:
- jrnlfileNext- the next file in the journal
 
- 
getDescriptionFormat the object attributes into a String for inclusion in the String returned from thetoString()method.- Returns:
- a comma-delimited String listing the attributes of this object in the form "attribute=value"
 
- 
notifyWriteCompletedpublic 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.
- 
evacuatepublic void evacuate()Called by the CollectorDaemon to evacuate all remaining data from the JournalFile.
- 
setReservedprotected void setReserved(boolean fReserved) Specify whether the current JournalFile is reserved.- Parameters:
- fReserved- whether the JournalFile is reserved
 
- 
disposepublic 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:
- disposein interface- Disposable
 
- 
toString
- 
getStateprotected long getState(long lState) Determine the state of the provided (potentially) unmaskedlState.- Parameters:
- lState- the journal file state
- Returns:
- the state only value
 
- 
setStateprotected void setState(long lState) Specify the current state of this JournalFile.- Parameters:
- lState- one of the STATE_* constants
 
- 
compareAndSetStateprotected boolean compareAndSetState(long lPrevValue, long lState) Specify the current state of this JournalFile unless the state isSTATE_RESERVEDas it is a special case and should be set viasetReserved(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
 
- 
compareAndSetOffsetprotected 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
 
- 
getOffsetprotected 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
 
 
-