HBase体系结构02(Client)
来源:互联网 发布:淘宝订单险有什么用 编辑:程序博客网 时间:2024/05/24 06:35
HBase Client通过查询hbase:meta表找到感兴趣的RegionServers,这些RegionServers服务于特定的行范围。找到region(s)后,Client联络服务此region(s)的RegionServer,而不是联络master来处理读写请求。当执行负载均衡或RegionServer死亡时,master就会将region(s)重新分配,Client就需要重新查询目录表确定用户region的新位置。
1 集群连接
连接配置信息的API在HBase 1.0有所改变,参考Client configuration and dependencies connecting to an HBase cluster。
1.1 HBase 1.0 API
HBase 1.0简洁地返回接口而不是特定类型,通过ConnectionFactory
获取Connection
对象,然后在需要时获取Table
,Admin
,RegionLocator
等实例,用完后关闭实例,最后在退出时清理Connection
实例。Connections
是重量级对象但是线程安全,所有你只需创建一个该实例为你的应用程序。Table
,Admin
,RegionLocator
等实例是轻量级的,创建完使用,使用完关闭。
1.2 HBase 1.0 API前
HBase 1.0 API前运用HTable
与HBase集群交互,Table
实例不是线程安全的,任何时候只允许一个线程操作该实例。为了共享ZooKeeper和socket实例,运用同样的HBaseConfiguration实例,如下:
HBaseConfiguration conf = HBaseConfiguration.create();HTable table1 = new HTable(conf, "myTable");HTable table2 = new HTable(conf, "myTable");
而不是:
HBaseConfiguration conf1 = HBaseConfiguration.create();HTable table1 = new HTable(conf1, "myTable");HBaseConfiguration conf2 = HBaseConfiguration.create();HTable table2 = new HTable(conf2, "myTable");
连接池
当应用程序需要高并发访问时,可以预先创建Connection
,如下:
// Create a connection to the cluster.Configuration conf = HBaseConfiguration.create();try (Connection connection = ConnectionFactory.createConnection(conf)) { try (Table table = connection.getTable(TableName.valueOf(tablename)) { // use table as needed, the table returned is lightweight }}
构建HTableInterface
实现非常轻量级,资源也是可控的。
HTablePool
在HBase 0.94,0.95,0.96中废弃,0.98.1中移除,HConnection
在HBase 1.0中废弃,代替使用Connection
。
2 写缓存和批处理
在HBase 1.0及之后,废弃支持Table的HTable
,Table不在自动autoflush,运用BufferedMutator
类。
HTable
废弃前,通过调用close()
,flushCommits()
,刷写缓存。
更细粒度批量Puts
和Deletes
,参见batch。
3 外部客户端
非Java客户端和自定义协议相关信息,参见Apache HBase External APIs。
- HBase体系结构02(Client)
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase体系结构
- HBase Client
- [HBase] HBase体系结构
- HBase详解:HBase体系结构
- HBase之体系结构(Architecture)
- HBase的体系结构
- HBase体系结构(转)
- HBase体系结构(转)
- HBase体系结构(转)
- libsvm在matlab中的使用方法
- 第九周项目四:广义表算法库及应用(1)
- OpenCV图片拼接
- Motion Classification and Target Tracking
- <黑马程序员> 第五篇:常用类
- HBase体系结构02(Client)
- 第十周项目3-利用二叉树遍历思想解决问题(1)
- 半正定矩阵
- 第十三周项目1 prim算法
- 使用TypeScript拓展你自己的VS Code!
- 《TCP/IP详解 卷1:协议》 读书笔记 第九章 IP选路
- uoj128/bzoj4196/NOI2015.软件包管理器(树链剖分)
- 轻松学习JavaScript五:JavaScript的变量和数据类型
- CNN网络提取哪层输出作为最后提取的特征为宜?