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
The WriterDaemon takes the enqueued Buffer objects from the
PreparerDaemon, and appends them to a JournalFile.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA 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 classA 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.DaemonWorkerNested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longThe number of milliseconds total spent writing blocks in groups.protected longThe number of milliseconds total spent writing blocks individually.protected longThe number of blocks written in groups (as part of a multi-buffer write).protected longThe number of blocks written individually.protected booleanSet to true if it becomes apparent that single block writes are preferable.protected BlockingQueue<Runnable> A Queue of items for this daemon to execute. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenqueueBuffer(FlashJournalRM.JournalFile jrnlfile, FlashJournalRM.Buffer buf, int cbBuffer) Notify the writer thread that a buffer needs to be written.intDetermine the average number of milliseconds to write each block.intDetermine the average number of milliseconds to write each block using the NIO "scatter/gather" functionality.intDetermine the average number of milliseconds to write each block using the NIO "single buffer write" functionality.longDetermine the total number of blocks written by this daemon.protected StringFormat the Daemon attributes into a String for inclusion in the String returned from theDaemon.toString()method.longDetermine the number of blocks written by this daemon using the NIO "scatter/gather" functionality.longDetermine the number of blocks written by this daemon using the NIO "single buffer write" functionality.booleanDetermine 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, toStringMethods 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, newHashMap, newHashMap, newHashSet, newHashSet, 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 Details
-
m_queue
A Queue of items for this daemon to execute. -
m_cSingleBlockWrites
protected long m_cSingleBlockWritesThe number of blocks written individually. -
m_cMillisSingleBlockWrites
protected long m_cMillisSingleBlockWritesThe number of milliseconds total spent writing blocks individually. -
m_cMultiBlockWrites
protected long m_cMultiBlockWritesThe number of blocks written in groups (as part of a multi-buffer write). -
m_cMillisMultiBlockWrites
protected long m_cMillisMultiBlockWritesThe number of milliseconds total spent writing blocks in groups. -
m_fPreferSingleBlockWrites
protected boolean m_fPreferSingleBlockWritesSet to true if it becomes apparent that single block writes are preferable.
-
-
Constructor Details
-
WriterDaemon
public WriterDaemon()Construct a WriterDaemon.
-
-
Method Details
-
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
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
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
Notify the writer thread that a file is done being written to.- Parameters:
jrnlfile- the file to append to
-