hbase学习笔记-----REST客户端
1. 启动REST服务
a.启动一个非守护进程模式的REST服务器(ctrl+c 终止)
bin/hbase rest start
b.启动守护进程模式的REST服务器
bin/hbase-daemon.sh start rest
默认启动的是8080端口(可以使用参数在启动时指定端口),可以被访问。eg. curl http://<servername>:8080/

2.访问服务端的数据


3.使用Java API访问
package rest; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
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.rest.client.Client;
import org.apache.hadoop.hbase.rest.client.Cluster;
import org.apache.hadoop.hbase.rest.client.RemoteHTable;
import org.apache.hadoop.hbase.util.Bytes;
import util.HBaseHelper; import java.io.IOException; /**
* Created by root on 15-1-9.
*/
public class RestExample {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create(); HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
System.out.println("Adding rows to table...");
helper.fillTable("testtable", 1, 10, 5, "colfam1"); Cluster cluster=new Cluster();
cluster.add("hadoop",8080); Client client=new Client(cluster); RemoteHTable table=new RemoteHTable(client,"testtable"); Get get = new Get(Bytes.toBytes("row-30"));
get.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("col-3"));
Result result1 = table.get(get); System.out.println("Get result1: " + result1); Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes("row-10"));
scan.setStopRow(Bytes.toBytes("row-15"));
scan.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("col-5"));
ResultScanner scanner = table.getScanner(scan);
for (Result result2 : scanner) {
System.out.println("Scan row[" + Bytes.toString(result2.getRow()) +
"]: " + result2);
} } }
hbase学习笔记-----REST客户端的更多相关文章
- HBASE学习笔记(四)
这两天把要前几天的知识点回顾一下,接下来我会用自己对知识点的理解来写一些东西 一.知识点回顾 1.hbase集群启动:$>start-hbase.sh ===>hbase-daemon.s ...
- Mina框架的学习笔记——Android客户端的实现
Apache MINA(Multipurpose Infrastructure for Network Applications) 是 Apache 组织一个较新的项目,它为开发高性能和高可用性的网络 ...
- HBase学习笔记之HBase的安装和配置
HBase学习笔记之HBase的安装和配置 我是为了调研和验证hbase的bulkload功能,才安装hbase,学习hbase的.为了快速的验证bulkload功能,我安装了一个节点的hadoop集 ...
- HBase学习笔记之BulkLoad
HBase学习之BulkLoad bulkload的学习以后再写文章. 参考资料: 1.https://blog.csdn.net/shixiaoguo90/article/details/78038 ...
- HBase学习笔记之HBase原理和Shell使用
HBase学习指南之HBase原理和Shell使用 参考资料: 1.https://www.cnblogs.com/nexiyi/p/hbase_shell.html,hbase shell
- HBase学习笔记1 - 如何编写高性能的客户端Java代码
转载请标注原链接:http://www.cnblogs.com/xczyd/p/5577124.html 客户在使用HBase的时候,经常会抱怨说写入太慢,并发上不去等等.从前我遇到这种情况,一般都二 ...
- HBase学习笔记(四)—— 架构模型
在逻辑上,HBase 的数据模型同关系型数据库很类似,数据存储在一张表中,有行有列. 但从 HBase 的底层物理存储结构(K-V)来看,HBase 更像是一个 multi-dimensional m ...
- Hbase学习笔记01
最近做项目接触到了HDFS.mapreduce以及Hbase,有了实战机会,今天打算将这些知识好好总结下,以备不时之需.首先从Hbase开始吧. Hbase是建立在HDFS上的分布式数据库,下图是Hb ...
- HBase学习笔记-高级(一)
HBase1. hbase.id记录了集群的唯一标识:hbase.version记录了文件格式的版本号2. split和.corrupt目录在日志分裂过程中使用,以便保存一些中间结果和损坏的日志在表目 ...
随机推荐
- JavaScript split()
http://www.w3school.com.cn/jsref/jsref_split.asp
- Java数据结构漫谈-ArrayList
ArrayList是一个基于数组实现的链表(List),这一点可以从源码中看出: transient Object[] elementData; // non-private to simplify ...
- C#在foreach循环中修改字典等集合出错的处理
C#在foreach循环中修改字典等集合出错:System.InvalidOperationException: Collection was modified; enumeration operat ...
- 2、shell命令学习
1.第一个例子 touch test.sh vim test.sh #!/bin/bash echo "hello world" chmod 755 test.sh ./test. ...
- C++深层复制解决指针悬挂
代码: #include <iostream> #include <cstring> using namespace std; class mystring{ public: ...
- 慕课linux学习笔记(六)常用命令(3)
Find 命令 #搜索文件 Find [搜索范围] [搜索条件] e.g. find / -name isnstall.log 搜索速度会非常慢 避免大范围搜索,会非常耗费系统资源 Find是在系统当 ...
- HTML5画布(矩形)
canvas元素用于绘制图形. canvas元素是HTML5中新增的一个重要元素,元素本身是没有绘图能力,所有的绘制工作必须在javascript内部完成. 案例1: <!DOCTYPE htm ...
- 永久存储:腌制一缸美味的泡菜 - 零基础入门学习Python031
永久存储:腌制一缸美味的泡菜 让编程改变世界 Change the world by program 从一个文件里读取字符串非常简单,但如果想要读取出数值,那就需要多费点儿周折.因为无论是read() ...
- C 中va_list,va_arg,va_start,va_end usage
1.在学习c语言,难免会遇到多参函数,刚好c中也提供了一些机制:宏函数 #ifdef _M_ALPHA typedef struct { char *a0; /* pointer to first h ...
- 【转】sqlmap用户手册
http://192.168.136.131/sqlmap/mysql/get_int.php?id=1 当给sqlmap这么一个url的时候,它会: 1.判断可注入的参数2.判断可以用那种SQL注入 ...