Thrift server是HBase中的一種服務,主要用於對多語言API的支持。基於Apache Thrift(多語言支持的通訊框架)開發,目前有兩種版本thrift和thrift2。git
thrift2是當時爲了適應新的Java API,提出來的。因爲種種緣由,thrift2沒有完美兼容並替代thrift,全部就留下了兩個版本。github
// Thrift2 的get接口,傳入TGet(對應Java API種的Get類) // 用過Java API的同窗看起來應該會更親切 TResult get( /** the table to get from */ 1: required binary table, /** the TGet to fetch */ 2: required TGet tget ) throws (1: TIOError io)
// Thrift 的get接口,沒有TGet這些包裝,比較裸 list<TCell> get( /** name of table */ 1:Text tableName, /** row key */ 2:Text row, /** column name */ 3:Text column, /** Get attributes */ 4:map<Text, Text> attributes ) throws (1:IOError io)
Thrfit其實就是個代理,你的請求發到Thrift server上後,server經過Java API再幫你訪問HBase。
Thrift實現類是org.apache.hadoop.hbase.thrift.ThriftServer
,thrift2的實現類是org.apache.hadoop.hbase.thrift2.ThriftServer
。它們訪問HBase使用的也是普通的HBase client API,因此當你的請求到達Thrift server後,它經過client API去幫你定位數據,而後讀取數據。這麼來看,Thrift Server比較靈活,你能夠部署在客戶機上,也能夠獨立部署一個thrift集羣。apache
閱讀原文請點擊框架