最近在试用Hbase1.0的客户端API,发觉变化还是挺大(以前版本也不熟)。到处都是deprecated。

现在应该是这样子:

Configuration  conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "quorum1,quorum2,quorum3");
conf.set("hbase.zookeeper.property.clientPort", "2181");

connection = ConnectionFactory.createConnection(conf);// HBase 0.99+

//connection = HConnectionManager.createConnection(conf); // HBase <0.99

Table table = connection.getTable(TableName.valueOf("TestTable"));

新的客户端API中,Connection处于关键位置,以下api说明翻译下:

关于 Connection接口的说明:
A cluster connection
encapsulating lower level individual connections to actual servers and a
connection to zookeeper. Connections are instantiated through the ConnectionFactory class.
The lifecycle of the connection is managed by the caller, who has to close() the
connection to release the resources.

The connection object contains logic to find the master, locate
regions out on the cluster, keeps a cache of locations and then knows
how to re-calibrate after they move. The individual connections to
servers, meta cache, zookeeper connection, etc are all
shared by the Table and Admin instances
obtained from this connection.

Connection creation is a heavy-weight operation. Connection
implementations are thread-safe, so that the client can create a
connection once, and share it with different threads. Table and Admin instances,

on the other hand, are light-weight and are not thread-safe. Typically,
a single connection per client application is instantiated and every
thread will obtain its own Table instance. Caching or pooling of Table and Admin is
not recommended.

This class replaces HConnection,
which is now deprecated.

Connection封装了底层与各实际服务器的连接以及与zookeeper的连接。Connection通过 ConnectionFactory类实例化。Connection的生命周期由调用者维护,调用者通过调用close(),释放资源。
连接对象包含发现master,定位region,缓存region位置一边当region移动后,重新矫正位置。通往各服务器的连接,meta数据缓存,zookeeper连接等,与通过Connection获取的Table,Admin实例都是共享的。
创建Connection是重量级
操作。
Connection是线程安全的,因此,多个客户端线程可以共享一个Connection。Table和Admin实例,相反地,是轻量级的并且非线程
安全。典型的用法,一个客户端程序共享一个单独的Connection,每一个线程获取自己的Table实例。不建议缓存或者池化
(pooling)Table、Admin。

关于 ConnectionFactory.createConnection函数的说明:

public static Connection createConnection(org.apache.hadoop.conf.Configuration conf)
Create a new Connection instance using the passed conf instance. Connection encapsulates all housekeeping for a connection to the cluster. All tables and interfaces created from returned connection share zookeeper connection, meta cache, and connections to region servers and masters. 
The caller is responsible for calling Connection.close() on
the returned connection instance.
Connection封装了连接到集群的所有维护工作。通过返回的connection生成的table、接口等共享zookeeper连接,meta缓存,到region server以及master的连接。
调用者负责释放connection实例。
Similarly, Connection also
returns Admin and RegionLocator implementations
类似返回table接口,Connection还可以返回Admin,RegionLoacator实例。

Hbase1.0 客户端api的更多相关文章

  1. HBase1.0以上版本的API改变

    HBase1.0以上版本已经废弃了 HTableInterface,HTable,HBaseAdmin等API的使用,新增了一些API来实现之前的功能: Connectioninterface: Co ...

  2. HBase1.0以上版本号的API改变

    HBase1.0以上版本号已经废弃了 HTableInterface,HTable,HBaseAdmin等API的使用.新增了一些API来实现之前的功能: Connectioninterface: C ...

  3. SignalR的Javascript客户端API使用方式整理

    SignalR的服务端提供了两种实现方式,分别是PersistentConnection和Hub,这两种方式的侧重点不同: PersistentConnection更接近于底层,编程接口比较简单,传输 ...

  4. JAVA客户端API调用memcached两种方式

    1. memcached client for java客户端API:memcached client for java 引入jar包:java-memcached-2.6.2.jar package ...

  5. Redis C客户端API - God's blog - 博客频道 - CSDN.NET

    Redis C客户端API - God's blog - 博客频道 - CSDN.NET Redis安装步骤: 1.redis server安装 wget http://redis.googlecod ...

  6. 通过 Jersey Http请求头,Http响应头,客户端 API 调用 REST 风格的 Web 服务

    原地址:http://blog.csdn.net/li575098618/article/details/47853263 Jersey 1.0 是一个开源的.可以用于生产环境的 JAX-RS(RES ...

  7. Jersey客户端API调用REST风格的Web服务

    Jersey 客户端 API 基础 jersey-1.14.jar 密码: cxug 要开始使用 Jersey 客户端 API,你首先需要创建一个 com.sun.jersey .api.client ...

  8. RabbitMQ系列教程之七:RabbitMQ的 C# 客户端 API 的简介

    今天这篇博文是我翻译的RabbitMQ的最后一篇文章了,介绍一下RabbitMQ的C#开发的接口.好了,言归正传吧. Net/C# 客户端 API简介1.主要的命名空间,接口和类  定义核心的API的 ...

  9. 从头编写 asp.net core 2.0 web api 基础框架 (1)

    工具: 1.Visual Studio 2017 V15.3.5+ 2.Postman (Chrome的App) 3.Chrome (最好是) 关于.net core或者.net core 2.0的相 ...

随机推荐

  1. 莫队算法 2038: [2009国家集训队]小Z的袜子(hose)

    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 2038: [2009国家集训队]小Z的袜子(hose) Time Limit: 20 ...

  2. go sample - hello world

    入门级别的hello world package mainimport "fmt"func main() { fmt.Println("blibliblbibl!&quo ...

  3. php获取文件夹下面的文件列表和文件夹列表

    function getDir($dir) { $dirArray[] = NULL; if (false != ($handle = opendir( $dir ))) { $i=0; while ...

  4. thinkphp 两表、三表联合查询

    //两表联合查询 $Model = M('T1');$Model->join('left join t2 on t1.cid = t2.id')->select();// $list = ...

  5. App界面交互设计规范

    策划007-App界面交互设计规范 字数1805 阅读3544 评论20 喜欢154 交互设计规范 在上篇<策划006-APP界面设计风格>确定下来后,产品经理(兼交互设计)还不用着急将所 ...

  6. SecureCRT上传和下载文件(下载默认目录)

    SecureCR 下的文件传输协议有ASCII .Xmodem .Ymodem .Zmodem ASCII:这是最快的传输协议,但只能传送文本文件. Xmodem:这种古老的传输协议速度较慢,但由于使 ...

  7. 系统剖析Android中的内存泄漏

    [转发]作为Android开发人员,我们或多或少都听说过内存泄漏.那么何为内存泄漏,Android中的内存泄漏又是什么样子的呢,本文将简单概括的进行一些总结. 关于内存泄露的定义,我可以理解成这样 没 ...

  8. Linux环境变量设置指南

    以配置java环境变量为例 目录 [隐藏]  1 修改/etc/profile文件 2 修改用户目录下的.bash_profile 3 修改.bashrc文件 4 直接在shell下设置 5 查看环境 ...

  9. 苹果推送(APNs)ios push小结

    把app删除后就推送不成功了,可以看出deviceToken应该是设备+app来一起识别的,重新安装后仍然为同一个 简介 推送服务APNs(Apple Push Notification servic ...

  10. 在caffe中添加新的layer

    比如现在要添加一个vision layer,名字叫Ly_Layer:(一般命名第一个字母大写,其余小写.) 1.属于哪个类型的layer(共五种:common_layer, data_layer, l ...