Package com.tangosol.io.journal
Class FlashJournalRM.WriterDaemon
- java.lang.Object
 - 
- com.tangosol.util.Base
 - 
- com.tangosol.util.Daemon
 - 
- com.tangosol.io.journal.FlashJournalRM.WriterDaemon
 
 
 
 
- 
- Enclosing class:
 - FlashJournalRM
 
protected class FlashJournalRM.WriterDaemon extends Daemon
The WriterDaemon takes the enqueued Buffer objects from the PreparerDaemon, and appends them to a JournalFile. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classFlashJournalRM.WriterDaemon.FileFullTaskA task that gets queued to perform cleanup on a file (on the WriterDaemon thread) when the file is full (no more writes will occur to the file).protected classFlashJournalRM.WriterDaemon.PendingWriteTaskA task that gets queued to perform an asynchronous appending write on the WriterDaemon thread.- 
Nested classes/interfaces inherited from class com.tangosol.util.Daemon
Daemon.DaemonWorker 
- 
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter 
 - 
 
- 
Field Summary
Fields Modifier and Type Field Description protected longm_cMillisMultiBlockWritesThe number of milliseconds total spent writing blocks in groups.protected longm_cMillisSingleBlockWritesThe number of milliseconds total spent writing blocks individually.protected longm_cMultiBlockWritesThe number of blocks written in groups (as part of a multi-buffer write).protected longm_cSingleBlockWritesThe number of blocks written individually.protected booleanm_fPreferSingleBlockWritesSet to true if it becomes apparent that single block writes are preferable.protected BlockingQueue<Runnable>m_queueA Queue of items for this daemon to execute. 
- 
Constructor Summary
Constructors Constructor Description WriterDaemon()Construct a WriterDaemon. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenqueueBuffer(FlashJournalRM.JournalFile jrnlfile, FlashJournalRM.Buffer buf, int cbBuffer)Notify the writer thread that a buffer needs to be written.intgetAvgBlockWriteMillis()Determine the average number of milliseconds to write each block.intgetAvgMultiBlockWriteMillis()Determine the average number of milliseconds to write each block using the NIO "scatter/gather" functionality.intgetAvgSingleBlockWriteMillis()Determine the average number of milliseconds to write each block using the NIO "single buffer write" functionality.longgetBlockWriteCount()Determine the total number of blocks written by this daemon.protected StringgetDescription()Format the Daemon attributes into a String for inclusion in the String returned from theDaemon.toString()method.longgetMultiBlockWriteCount()Determine the number of blocks written by this daemon using the NIO "scatter/gather" functionality.longgetSingleBlockWriteCount()Determine the number of blocks written by this daemon using the NIO "single buffer write" functionality.booleanisSingleBlockWritePreferred()Determine if the next write should automatically use the "single buffer write" capability of NIO, instead of attempting to use the NIO scatter/gather capability.voidnotifyFileFull(FlashJournalRM.JournalFile jrnlfile)Notify the writer thread that a file is done being written to.voidrun()The daemon's implementation method.protected voidsetGuardPolicy(Guardian guardian, long cTimeoutMillis, float flPctRecover)Set the Guardian and policy to guard this Daemon with.voidstop()Request the daemon to stop.- 
Methods inherited from class com.tangosol.util.Daemon
changeState, configureWorker, ensureThreadGroup, finishStarting, finishStopping, getConfiguredName, getConfiguredPriority, getContext, getGuardRegisterAction, getMaxWaitMillis, getState, getThread, getThreadContextClassLoader, getWorker, guardIfNeeded, heartbeat, heartbeat, instantiateWorker, isGuarded, isOnWorkerThread, isRunning, isStopping, recover, setConfiguredName, setConfiguredPriority, setContext, setGuardRegisterAction, setThreadContextClassLoader, shutdown, start, terminate, toStateString, toString 
- 
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait 
 - 
 
 - 
 
- 
- 
Field Detail
- 
m_queue
protected BlockingQueue<Runnable> m_queue
A Queue of items for this daemon to execute. 
- 
m_cSingleBlockWrites
protected long m_cSingleBlockWrites
The number of blocks written individually. 
- 
m_cMillisSingleBlockWrites
protected long m_cMillisSingleBlockWrites
The number of milliseconds total spent writing blocks individually. 
- 
m_cMultiBlockWrites
protected long m_cMultiBlockWrites
The number of blocks written in groups (as part of a multi-buffer write). 
- 
m_cMillisMultiBlockWrites
protected long m_cMillisMultiBlockWrites
The number of milliseconds total spent writing blocks in groups. 
- 
m_fPreferSingleBlockWrites
protected boolean m_fPreferSingleBlockWrites
Set to true if it becomes apparent that single block writes are preferable. 
 - 
 
- 
Method Detail
- 
stop
public void stop()
Request the daemon to stop. This method will only have an effect if the daemon sub-class respects the value returned fromDaemon.isStopping(). 
- 
run
public void run()
The daemon's implementation method. Override this method to implement a daemon.An example implementation is:
while (!isStopping()) { // do some processing // ... synchronized (this) { // wait for notification of more work wait(); } } 
- 
setGuardPolicy
protected void setGuardPolicy(Guardian guardian, long cTimeoutMillis, float flPctRecover)
Set the Guardian and policy to guard this Daemon with. The Daemon is registered with the specified Guardian each time the Daemon is started, and is released each time the Daemon is stopped.- Overrides:
 setGuardPolicyin classDaemon- Parameters:
 guardian- the Guardian that will be guarding this DaemoncTimeoutMillis- the timeout in ms for this Daemon, or 0 for the service guardian timeoutflPctRecover- the recovery percentage for this Daemon
 
- 
getDescription
protected String getDescription()
Format the Daemon attributes into a String for inclusion in the String returned from theDaemon.toString()method.- Overrides:
 getDescriptionin classDaemon- Returns:
 - a String listing the attributes of the Daemon
 
 
- 
isSingleBlockWritePreferred
public boolean isSingleBlockWritePreferred()
Determine if the next write should automatically use the "single buffer write" capability of NIO, instead of attempting to use the NIO scatter/gather capability.- Returns:
 - true iff the next write should not attempt to use NIO scatter/gather functionality
 
 
- 
getBlockWriteCount
public long getBlockWriteCount()
Determine the total number of blocks written by this daemon.- Returns:
 - the total number of blocks written by this daemon
 
 
- 
getSingleBlockWriteCount
public long getSingleBlockWriteCount()
Determine the number of blocks written by this daemon using the NIO "single buffer write" functionality.- Returns:
 - the number of NIO individual buffer writes
 
 
- 
getMultiBlockWriteCount
public long getMultiBlockWriteCount()
Determine the number of blocks written by this daemon using the NIO "scatter/gather" functionality. This is not the number of writes, since each write involves multiple blocks being written, one in each buffer.- Returns:
 - the number of NIO scatter/gather buffer writes
 
 
- 
getAvgBlockWriteMillis
public int getAvgBlockWriteMillis()
Determine the average number of milliseconds to write each block.- Returns:
 - the average number of milliseconds to write each block
 
 
- 
getAvgSingleBlockWriteMillis
public int getAvgSingleBlockWriteMillis()
Determine the average number of milliseconds to write each block using the NIO "single buffer write" functionality.- Returns:
 - the average number of milliseconds for NIO individual buffer writes
 
 
- 
getAvgMultiBlockWriteMillis
public int getAvgMultiBlockWriteMillis()
Determine the average number of milliseconds to write each block using the NIO "scatter/gather" functionality.- Returns:
 - the average number of milliseconds for NIO scatter/gather writes
 
 
- 
enqueueBuffer
public void enqueueBuffer(FlashJournalRM.JournalFile jrnlfile, FlashJournalRM.Buffer buf, int cbBuffer)
Notify the writer thread that a buffer needs to be written.- Parameters:
 jrnlfile- the file to append tobuf- the buffer to appendcbBuffer- the number of bytes to append from the buffer
 
- 
notifyFileFull
public void notifyFileFull(FlashJournalRM.JournalFile jrnlfile)
Notify the writer thread that a file is done being written to.- Parameters:
 jrnlfile- the file to append to
 
 - 
 
 -