Class FlashJournalRM.WriterDaemon.PendingWriteTask

  • All Implemented Interfaces:
    Runnable
    Enclosing class:
    FlashJournalRM.WriterDaemon

    protected class FlashJournalRM.WriterDaemon.PendingWriteTask
    extends Object
    implements Runnable
    A task that gets queued to perform an asynchronous appending write on the WriterDaemon thread.
    • Constructor Detail

      • PendingWriteTask

        public PendingWriteTask​(FlashJournalRM.JournalFile jrnlfile,
                                FlashJournalRM.Buffer buf,
                                int cbBuffer)
        Construct a PendingWriteInfo "struct".
        Parameters:
        jrnlfile - the file to append to
        buf - the buffer to append
        cbBuffer - the number of bytes to append from the buffer
    • Method Detail

      • run

        public void run()
        Execute the task, writing the buffer to the end of the file.
        Specified by:
        run in interface Runnable
      • processWriteException

        protected void processWriteException​(IOException ioe,
                                             List<FlashJournalRM.Buffer> listBuffer,
                                             ByteBuffer[] aniobuf,
                                             FlashJournalRM.JournalFile jrnlfile)
        Process IOException while flushing the buffers to disk.

        Upon encountering a write exception the write is reattempted with an increasing interval between attempts. This method switches the FlashJournalRM.CongestionPolicy allowing exceptions to be thrown to the client as the Journal naturally enters congestion.

        Control may be returned to the caller with the Journal being unable to be repaired; this is highlighted by the throwing of a RuntimeException or the current thread's interrupt bit being set. In the latter case the Journal may wish to operate in a read-only mode.

        Parameters:
        ioe - the IOException
        listBuffer - the list of buffers to be flushed to disk
        aniobuf - the array of byte buffers to be flushed to disk
        jrnlfile - the FlashJournalRM.JournalFile being written from
        Throws:
        IllegalStateException - if the write could not be completed / repaired
      • writeRemainder

        protected void writeRemainder​(IOException e,
                                      List<FlashJournalRM.Buffer> listBuffer,
                                      ByteBuffer[] aniobuf,
                                      boolean fSingleBlockWrite)
                               throws IOException
        Write what has not been written (remainder) to disk. The remainder is derived based on current-buffers - bytes-written-to-file. This method is invoked as a result of some raw (device) error thus the exception argument. This ensures we do not lose the initial cause as we replay writes.
        Parameters:
        e - the IOException
        listBuffer - the list of buffers to be flushed to disk
        aniobuf - the array of byte buffers to be flushed to disk
        fSingleBlockWrite - whether to switch the preference in favor of single block writes
        Throws:
        IOException