1. 程式人生 > >HBase --- 讀寫流程(一)

HBase --- 讀寫流程(一)

整體流程

讀寫流程主要分為兩大部分:

  1. Client從MetaTable路由到Region所在的Region Server;
  2. Client直接與對應的Region Server進行互動;

        這裡寫圖片描述

路由表MetaTable

  MetaTable儲存Region與Region Server的對應關係,其結構如下所示:
這裡寫圖片描述

路由表的獲取時機

  Client 首次讀寫時會首先從Zookeeper獲取MetaTable,然後快取在本地;

Region Server寫流程

  1. 寫請求追加寫入WAL;
    這裡寫圖片描述
  2. 寫入MemStore,給客戶端返回ACK;
    這裡寫圖片描述
  3. 如果MemStore超過設定閾值,持久化到磁碟生成HFile;
    這裡寫圖片描述

Region Server讀流程

  1. 首先,從讀快取BlockCache(LRU策略)查詢;
  2. 其次,從寫快取MemStore查詢;
  3. 最後,根據Bloom Filter定位到對應的HFile,並載入到記憶體,返回對應的單元值;

First, the scanner looks for the Row cells in the Block cache - the read cache. Recently Read Key Values are cached here, and Least Recently Used are evicted when memory is needed. Next, the scanner looks in the MemStore, the write cache in memory containing the most recent writes. If the scanner does not find all of the row cells in the MemStore and Block Cache, then HBase will use the Block Cache indexes and bloom filters to load HFiles into memory, which may contain the target row cells.

這裡寫圖片描述

參考: