HBase数据读写流程(1.3.1)

===数据写入流程===

源码:https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

函数:doMiniBatchMutation

总结:图片来自博客:http://hbasefly.com/2016/03/23/hbase_writer/

源码注释摘录:

// ------------------------------------
      // STEP 1. Try to acquire as many locks as we can, and ensure
      // we acquire at least one.
      // ----------------------------------

      // ------------------------------------
      // STEP 2. Update any LATEST_TIMESTAMP timestamps
      // ----------------------------------

      // ------------------------------------
      // STEP 3. Build WAL edit
      // ----------------------------------

      // -------------------------
      // STEP 4. Append the final edit to WAL. Do not sync wal.
      // -------------------------

      // ------------------------------------
      // STEP 5. Write back to memstore
      // Write to memstore. It is ok to write to memstore
      // first without syncing the WAL because we do not roll
      // forward the memstore MVCC. The MVCC will be moved up when
      // the complete operation is done. These changes are not yet
      // visible to scanners till we update the MVCC. The MVCC is
      // moved only when the sync is complete.
      // ----------------------------------

      // -------------------------------
      // STEP 6. Release row locks, etc.
      // -------------------------------

      // -------------------------
      // STEP 7. Sync wal.
      // -------------------------

      // ------------------------------------------------------------------
      // STEP 8. Advance mvcc. This will make this put visible to scanners and getters.
      // ------------------------------------------------------------------

      // ------------------------------------
      // STEP 9. Run coprocessor post hooks. This should be done after the wal is
      // synced so that the coprocessor contract is adhered to.
      // ------------------------------------

      // if the wal sync was unsuccessful, remove keys from memstore

 

 

===数据读取流程===

参考博客:http://hbasefly.com/2016/12/21/hbase-getorscan/

 

posted @ 2017-09-21 17:03  大墨垂杨  阅读(516)  评论(0编辑  收藏  举报