Class FSHLog.SyncRunner

java.lang.Object
java.lang.Thread
org.apache.hadoop.hbase.regionserver.wal.FSHLog.SyncRunner
All Implemented Interfaces:
Runnable
Enclosing class:
FSHLog

private class FSHLog.SyncRunner extends Thread
Thread to runs the hdfs sync call. This call takes a while to complete. This is the longest pole adding edits to the WAL and this must complete to be sure all edits persisted. We run multiple threads sync'ng rather than one that just syncs in series so we have better latencies; otherwise, an edit that arrived just after a sync started, might have to wait almost the length of two sync invocations before it is marked done.

When the sync completes, it marks all the passed in futures done. On the other end of the sync future is a blocked thread, usually a regionserver Handler. There may be more than one future passed in the case where a few threads arrive at about the same time and all invoke 'sync'. In this case we'll batch up the invocations and run one filesystem sync only for a batch of Handler sync invocations. Do not confuse these Handler SyncFutures with the futures an ExecutorService returns when you call submit. We have no use for these in this model. These SyncFutures are 'artificial', something to hold the Handler until the filesystem sync completes.

  • Field Details

  • Constructor Details

  • Method Details

    • offer

      void offer(long sequence, SyncFuture[] syncFutures, int syncFutureCount)
    • releaseSyncFuture

      private int releaseSyncFuture(SyncFuture syncFuture, long currentSequence, Throwable t)
      Release the passed syncFuture
      Returns:
      Returns 1.
    • releaseSyncFutures

      private int releaseSyncFutures(long currentSequence, Throwable t)
      Release all SyncFutures whose sequence is <= currentSequence.
      Parameters:
      t - May be non-null if we are processing SyncFutures because an exception was thrown.
      Returns:
      Count of SyncFutures we let go.
    • updateHighestSyncedSequence

      private long updateHighestSyncedSequence(long sequence)
      Parameters:
      sequence - The sequence we ran the filesystem sync against.
      Returns:
      Current highest synced sequence.
    • areSyncFuturesReleased

    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread