最近在试用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函数的说明:

  1. 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. Solr入门之(8)中文分词器配置

    Solr中虽然提供了一个中文分词器,但是效果很差,可以使用IKAnalyzer或Mmseg4j 或其他中文分词器. 一.IKAnalyzer分词器配置: 1.下载IKAnalyzer(IKAnalyz ...

  2. PHP数组合并的常见问题

    一维数组的合并 <?php $arr1=array("a","b","c"); $arr2=array("c",& ...

  3. 利用Browser Link提高前端开发的生产力

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:Browser Link是VS 2013开始引入的一个强大功能,让前端代码(比如Ang ...

  4. 链接器工具错误 LNK2026 XXX模块对于 SAFESEH 映像是不安全的

    解决方法: 1.打开该项目的"属性页"对话框. 2.单击"链接器"文件夹. 3.单击"命令行"属性页. 4.将 /SAFESEH:NO 键入 ...

  5. csc.rsp Invent by Microshaoft

    # This file contains command-line options that the C# # command line compiler (CSC) will process as ...

  6. NuGet学习笔记(2) 使用图形化界面打包自己的类库

    上文NuGet学习笔记(1) 初识NuGet及快速安装使用说到NuGet相对于我们最重要的功能是能够搭建自己的NuGet服务器,实现公司内部类库的轻松共享更新.在安装好NuGet扩展后,我们已经能够通 ...

  7. Android中log使用方法

    private static final String ACTIVITY_TAG="MainActivity"; Log.v(MainActivity.ACTIVITY_TAG, ...

  8. Vue入门笔记#过渡

    Vue过渡,可以在元素从DOM中移除,插入时自动调用过渡效果.根据设定,会适时的触发过渡效果. 在使用的目标标签里添加 transition: <div transition="my_ ...

  9. ArrayList集合&特殊集合

    一.ArrayList集合 集合内可以放不同类型的元素 另:object类型为所有数据类型的基类 添加元素:.add(); 清空集合:al.clear(); 克隆集合:.clone(); 判断是否包含 ...

  10. 到程序集里取DLL

    C:\Windows\assembly\gac_msil