Friday, September 13, 2013

How-to: Test the HBase Coprocessor tutorial

here is a quick tutorial to setup hbase instance and hook up with a basic coprocessor.

Download the tar file and unzip it from http://mirror.tcpdiag.net/apache/hbase/hbase-0.94.11/
   Change the Hbase-site.xml, point the hbase.rootdir to the local folder, by default Hbase will load the default one embedded in the hbase-x.jar, and default setting is local temp folder,

image

change it to a folder you fell comfortable,
  also change the hbase.temp.dir to a well know folder, you can see all the underlying folder it used,
My final change,

image

then you can start the hbase server ./bin/start-hbase.sh

  check the port it listened, should be a port called 60030
 image

then you can go the http://ip:60030 to see the hbase console of the given region. and 60010 for the hbase master
image

image

then create a table and put a record

image

check the folder

image

Now let’s write a basic java program to read the data in hbase.

Create a new maven project by clicking the eclipse wizard,
image_thumb[2]
Click the pom.xml, right click to add one dependency hbase.

image_thumb[3]

Simple Query in another server, make sure the zookeeper ip and host name are accessible from client machine,

image

for the coprocessor, they are bascailly observers in 3 levels.
  Master level, you can hookup with all the DDL like create table,update column,etc (check BaseMasterObserver)
image

and DML level in the region servers,
image

And WAL level, all changes going to WAL, basically you can see all the changes. you can even reject the change
image
 
I will put the WALobserver as a example, just dump out any changes to the cluseter, we can send the changeset to another server do secondary indexing, or for logging /auditing purpose.

image

compile and package it to a jar file,then copy to the hbase lib folder, or any folder which is in the HBASE_CLASSPATH

then change hbase-site.xml, point to our WALobserver

image

then restart the instance, from the region server, you can see our WAL is loaded,
image

then make some changes to the data,
image

from the log, you should see our logging , data changes captured here
image

Please note the WALobserver runs in the same JVM of the hbase, make sure not fail safe and no huge extra performance hit.

No comments:

 
Locations of visitors to this page