Class SyncFuture

java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.SyncFuture

@Private class SyncFuture extends Object
A Future on a filesystem sync call. It given to a client or 'Handler' for it to wait on till the sync completes.

Handlers coming in call append, append, append, and then do a flush/sync of the edits they have appended the WAL before returning. Since sync takes a while to complete, we give the Handlers back this sync future to wait on until the actual HDFS sync completes. Meantime this sync future goes across a queue and is handled by a background thread; when it completes, it finishes up the future, the handler get or failed check completes and the Handler can then progress.

This is just a partial implementation of Future; we just implement get and failure.

There is not a one-to-one correlation between dfs sync invocations and instances of this class. A single dfs sync call may complete and mark many SyncFutures as done; i.e. we batch up sync calls rather than do a dfs sync call every time a Handler asks for it.

SyncFutures are immutable but recycled. Call #reset(long, Span) before use even if it the first time, start the sync, then park the 'hitched' thread on a call to #get().

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Condition
    Condition to wait on for client threads.
    private final ReentrantLock
    Lock protecting the thread-safe fields.
    private long
    The transaction id that was set in here when we were marked done.
    private boolean
     
    private static final long
     
    private Thread
     
    private Throwable
    If error, the associated throwable.
    private long
    The transaction id of this operation, monotonically increases.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) boolean
    done(long txid, Throwable t)
     
    (package private) long
    get(long timeoutNs)
     
    (package private) Thread
    Returns the thread that owned this sync future, use with caution as we return the reference to the actual thread object.
    (package private) Throwable
     
    (package private) long
     
    (package private) boolean
     
    (package private) boolean
     
    (package private) SyncFuture
    reset(long txid, boolean forceSync)
    Call this method to clear old usage and get it ready for new deploy.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • NOT_DONE

      private static final long NOT_DONE
      See Also:
    • t

      private Thread t
    • doneLock

      private final ReentrantLock doneLock
      Lock protecting the thread-safe fields.
    • doneCondition

      private final Condition doneCondition
      Condition to wait on for client threads.
    • doneTxid

      private long doneTxid
      The transaction id that was set in here when we were marked done. Should be equal or > txnId. Put this data member into the NOT_DONE state while this class is in use.
    • throwable

      If error, the associated throwable. Set when the future is 'done'.
    • txid

      private long txid
      The transaction id of this operation, monotonically increases.
    • forceSync

      private boolean forceSync
  • Constructor Details

  • Method Details