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
阅读原文请点击框架