Package com.tangosol.io.journal
Class FlashJournalRM.JournalFile
- java.lang.Object
-
- com.tangosol.io.journal.AbstractJournalRM.JournalFile
-
- com.tangosol.io.journal.FlashJournalRM.JournalFile
-
- All Implemented Interfaces:
Disposable,AutoCloseable
- Enclosing class:
- FlashJournalRM
protected class FlashJournalRM.JournalFile extends AbstractJournalRM.JournalFile
A JournalFile is created for each OS 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 Summary
Fields Modifier and Type Field Description protected byte[]m_abOvRandom overlay data.protected FileChannelm_channelReadA random access FileChannel for read purposes.protected FileChannelm_channelWriteA FileOutputStream FileChannel for append purposes.protected Filem_fileThe file.protected longm_ofNextFlushThe offset of the next Binary to clean out of the map (ie "flush" out of memory).-
Fields inherited from class com.tangosol.io.journal.AbstractJournalRM.JournalFile
m_cbReleased, m_cbWritten, m_fNotifiedFull, m_jrnlfileNext, m_lStateOffset, m_nFile, STATE_APPENDING, STATE_CONGESTION, STATE_DISCARDED, STATE_EVACUATING, STATE_FULL, STATE_GARBAGE, STATE_MASK, STATE_RESERVED
-
-
Constructor Summary
Constructors Constructor Description JournalFile(int nFile)Construct a Journal File.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FlashJournalRM.BufferallocateBuffer()Allocate a Buffer to use with this JournalFile.protected voidcongestionCheck(int cbDelta)Check if a change to the backlog causes a change to the congestion state.voiddispose()Invoked when all resources owned by the implementer can safely be released.longenqueue(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.protected StringgetDescription()Format the object attributes into a String for inclusion in the String returned from theAbstractJournalRM.JournalFile.toString()method.FilegetFile()Obtain the File that this JournalFile object represents.FlashJournalRM.JournalFilegetNextJournalFile()Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.FileChannelgetReadChannel()Obtain the FileChannel used for reading from the JournalFile.FileChannelgetWriteChannel()Obtain the FileChannel used for appending to the JournalFile.voidnotifyWriteBehindCompleted()Called by the WriterDaemon to indicate that all the data for the JournalFile has been flushed.voidnotifyWriteOccurred(int cbWritten)Called by the WriterDaemon to indicate that more data has been flushed from the write-behind queue to disk.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.voidtouch()This method is called periodically by the collector daemon to indicate that the file is still being used.-
Methods inherited from class com.tangosol.io.journal.AbstractJournalRM.JournalFile
compareAndSetOffset, compareAndSetState, evacuate, getBytesWritten, getFileId, getOffset, getOffset, getReleased, getState, getState, isAppending, isReserved, notifyWriteCompleted, setNextJournalFile, setReserved, setState, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close
-
-
-
-
Field Detail
-
m_file
protected final File m_file
The file. Immutable field.
-
m_channelRead
protected FileChannel m_channelRead
A random access FileChannel for read purposes.
-
m_channelWrite
protected final FileChannel m_channelWrite
A FileOutputStream FileChannel for append purposes.
-
m_abOv
protected final byte[] m_abOv
Random overlay data.
-
m_ofNextFlush
protected long m_ofNextFlush
The offset of the next Binary to clean out of the map (ie "flush" out of memory).
-
-
Method Detail
-
enqueue
public 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.- Specified by:
enqueuein classAbstractJournalRM.JournalFile- 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 Binary read(long lTicket)
Read the Binary associated with the specified ticket from the journal file.- Specified by:
readin classAbstractJournalRM.JournalFile- Parameters:
lTicket- a ticket previously returned fromAbstractJournalRM.JournalFile.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.- Overrides:
releasein classAbstractJournalRM.JournalFile- Parameters:
cbValue- the number of bytes that are being released
-
getNextJournalFile
public FlashJournalRM.JournalFile getNextJournalFile()
Determine the JournalFile for the file in the journal that follows the file represented by this JournalFile.- Overrides:
getNextJournalFilein classAbstractJournalRM.JournalFile- Returns:
- the next file in the journal, or null if it has not yet been set
-
getFile
public File getFile()
Obtain the File that this JournalFile object represents.- Returns:
- a File object representing the OS file that this JournalFile writes and reads to and from
-
getReadChannel
public FileChannel getReadChannel()
Obtain the FileChannel used for reading from the JournalFile.- Returns:
- a random access FileChannel
-
getWriteChannel
public FileChannel getWriteChannel()
Obtain the FileChannel used for appending to the JournalFile.- Returns:
- an appending FileChannel
-
touch
public void touch()
This method is called periodically by the collector daemon to indicate that the file is still being used.- Overrides:
touchin classAbstractJournalRM.JournalFile
-
getDescription
protected String getDescription()
Format the object attributes into a String for inclusion in the String returned from theAbstractJournalRM.JournalFile.toString()method.- Overrides:
getDescriptionin classAbstractJournalRM.JournalFile- Returns:
- a comma-delimited String listing the attributes of this object in the form "attribute=value"
-
notifyWriteOccurred
public void notifyWriteOccurred(int cbWritten)
Called by the WriterDaemon to indicate that more data has been flushed from the write-behind queue to disk.- Parameters:
cbWritten- the number of additional bytes written
-
notifyWriteBehindCompleted
public void notifyWriteBehindCompleted()
Called by the WriterDaemon to indicate that all the data for the JournalFile has been flushed.
-
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- Specified by:
disposein classAbstractJournalRM.JournalFile
-
congestionCheck
protected void congestionCheck(int cbDelta)
Check if a change to the backlog causes a change to the congestion state.- Parameters:
cbDelta- number of bytes added to or removed from the backlog
-
allocateBuffer
public FlashJournalRM.Buffer allocateBuffer()
Allocate a Buffer to use with this JournalFile.- Returns:
- a new (or pooled) Buffer
-
-