HTablePool实例代码
来源:互联网 发布:飞机票图片制作软件 编辑:程序博客网 时间:2024/06/05 17:06
写了一个用HTablePool来做HTable连接池的代码,不对的地方请多指教
直接上代码,仔细看看,应该不难看懂
package com.pzoom.hbase.java;import java.io.IOException;import java.util.ArrayList;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.KeyValue;import org.apache.hadoop.hbase.client.HTableInterface;import org.apache.hadoop.hbase.client.HTablePool;import org.apache.hadoop.hbase.client.Result;import org.apache.hadoop.hbase.client.ResultScanner;import org.apache.hadoop.hbase.client.Scan;import org.apache.hadoop.hbase.filter.PageFilter;import org.apache.hadoop.hbase.util.Bytes;import org.junit.Test;public class TestHTablePool {private static Configuration conf ;static{conf = new Configuration() ;conf.set("hbase.zookeeper.quorum", "192.168.1.171,192.168.1.172,192.168.1.173");conf.set("hbase.zookeeper.property.clientPort", "2181");}@SuppressWarnings("deprecation")public void testTablePool() throws IOException {HTablePool tablePool = new HTablePool(conf, 10);ArrayList<HTableInterface> hts = new ArrayList<HTableInterface>();try {for(int i=0; i <6; i++){HTableInterface hTable = tablePool.getTable(Bytes.toBytes("tab_keyword"));System.out.println("the number:" + i);hts.add(hTable);}} catch (Exception e) {System.out.println("error!");// TODO: handle exceptione.printStackTrace();}System.out.println("tablepool size: " + hts.size());Scan scan = new Scan();//PageFilter filter = new PageFilter(1);//scan.setFilter(filter);scan.setStartRow(Bytes.toBytes("2012-08-03:242969862:0000036"));scan.setStopRow(Bytes.toBytes("2012-08-03:242969862:0000037"));ResultScanner rs = hts.get(0).getScanner(scan);System.out.println("begin!");for (Result result : rs) {System.out.println(Bytes.toString(result.getRow()));for (KeyValue kv : result.raw()) {//if("text".equals(Bytes.toString(kv.getQualifier()))) {//System.out.println("q: " + Bytes.toString(kv.getQualifier()) + " :"//+ Bytes.toString(kv.getValue()));//}}}rs.close();for (HTableInterface hTable : hts) {tablePool.putTable(hTable);}}@Testpublic void testPool() throws IOException {testTablePool();}}
- HTablePool实例代码
- HTablePool的实现分析
- HTablePool简单使用例子
- [HBase] HTable && HTablePool
- HTablePool的实现分析
- HTablePool 的使用方法
- hbase 客户端HTablePool
- HTablePool简单使用例子
- HBase连接池 -- HTablePool
- HTablePool的实现分析
- hbase的 HTablePool
- HTablePool为何弃用?
- 实例代码
- 代码实例
- 代码实例
- HTablePool 连接池源码分析
- HTable和HTablePool使用注意事项
- HTable和HTablePool使用注意事项
- Struts2+Hibernate+Spring 在mysql更新Blob类型的数据
- UML类图几种关系的总结
- java与mysql的连接字符串,指明字符集的写法
- 超级详细的android目录说明
- debug版本与release版本示例
- HTablePool实例代码
- <jsp:include page="" flush="true" /> 中flush="true 的作用
- Tcl/tk实例-工具栏和菜单-图片预览工具
- Spring多数据源的配置
- UML用例图总结
- jsp包含html文件中文乱码解决办法
- 安装交叉编译工具链
- Guid ToString 格式知多少?
- 静态页面中显示系统时间