Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.io.journal
Class FlashJournalRM.WriterDaemon

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.Daemon
          extended by com.tangosol.io.journal.FlashJournalRM.WriterDaemon

All Implemented Interfaces:
Guardable, java.lang.Runnable
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
protected  class FlashJournalRM.WriterDaemon.FileFullTask
          A 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  class FlashJournalRM.WriterDaemon.PendingWriteTask
          A 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

 

Field Summary
protected  long m_cMillisMultiBlockWrites
          The number of milliseconds total spent writing blocks in groups.
protected  long m_cMillisSingleBlockWrites
          The number of milliseconds total spent writing blocks individually.
protected  long m_cMultiBlockWrites
          The number of blocks written in groups (as part of a multi-buffer write).
protected  long m_cSingleBlockWrites
          The number of blocks written individually.
protected  boolean m_fPreferSingleBlockWrites
          Set to true if it becomes apparent that single block writes are preferable.
protected  java.util.concurrent.BlockingQueue m_queue
          A Queue of items for this daemon to execute.

 

Constructor Summary
FlashJournalRM.WriterDaemon()
          Construct a WriterDaemon.

 

Method Summary
 void enqueueBuffer(FlashJournalRM.JournalFile jrnlfile, FlashJournalRM.Buffer buf, int cbBuffer)
          Notify the writer thread that a buffer needs to be written.
 int getAvgBlockWriteMillis()
          Determine the average number of milliseconds to write each block.
 int getAvgMultiBlockWriteMillis()
          Determine the average number of milliseconds to write each block using the NIO "scatter/gather" functionality.
 int getAvgSingleBlockWriteMillis()
          Determine the average number of milliseconds to write each block using the NIO "single buffer write" functionality.
 long getBlockWriteCount()
          Determine the total number of blocks written by this daemon.
protected  java.lang.String getDescription()
          Format the Daemon attributes into a String for inclusion in the String returned from the Daemon.toString() method.
 long getMultiBlockWriteCount()
          Determine the number of blocks written by this daemon using the NIO "scatter/gather" functionality.
 long getSingleBlockWriteCount()
          Determine the number of blocks written by this daemon using the NIO "single buffer write" functionality.
 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.
 void notifyFileFull(FlashJournalRM.JournalFile jrnlfile)
          Notify the writer thread that a file is done being written to.
 void run()
          The daemon's implementation method.
protected  void setGuardPolicy(Guardian guardian, long cTimeoutMillis, float flPctRecover)
          Set the Guardian and policy to guard this Daemon with.
 void stop()
          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

 

Field Detail

m_queue

protected java.util.concurrent.BlockingQueue 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.

Constructor Detail

FlashJournalRM.WriterDaemon

public FlashJournalRM.WriterDaemon()
Construct a WriterDaemon.

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 from Daemon.isStopping().
Overrides:
stop in class Daemon

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();
           }
       }
 
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class Daemon

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:
setGuardPolicy in class Daemon
Parameters:
guardian - the Guardian that will be guarding this Daemon
cTimeoutMillis - the timeout in ms for this Daemon, or 0 for the service guardian timeout
flPctRecover - the recovery percentage for this Daemon

getDescription

protected java.lang.String getDescription()
Format the Daemon attributes into a String for inclusion in the String returned from the Daemon.toString() method.
Overrides:
getDescription in class Daemon
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 to
buf - the buffer to append
cbBuffer - 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

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.