Hbase-coprocessor-the introduction and use of observer (trigger) for the observer of the Coprocessor | That Yi-Wipe smile

Source: Internet
Author: User
Tags hadoop fs

BlogThat Yi-Wipe smilecsdn Blog Address:http://blog.csdn.net/u012185296 itdog8 address link: http://www.itdog8.com/thread-216-1-1.html
Post title:Hbase-coprocessor-the introduction and use of observer (trigger) for the coprocessor viewer
Personality Signature:The furthest distance in the world is not the horizon, nor the cape, but I stand in front of you, but you do not feel my presence
Technical Direction:Flume+kafka+storm+redis/hbase+hadoop+hive+mahout+spark ... Cloud Computing Technology
Reprint statement:can be reproduced, but must be in the form of hyperlinks to indicate the original source and author information and copyright statement, thank you for your cooperation!
QQ Exchange Group:214293307 (look forward to learning with you, common progress)


1 co-processorCo-processor is divided into Viewer Observer and terminal Endpoint
1.1 Observer Observer (similar to trigger Triggerin a traditional database)
interface under 1.1.1 coprocessor
For more information, see the comments on the interface directly!!!
1.1.2 Use of Java APIsInherit the corresponding abstract class on the line, each abstract class has a different function, see the name of the understanding, do not explain 、、、
public class Testaddcolumnbaseregionobserver extends baseregionobserver{@Override public void Preput (observercontext& Lt Regioncoprocessorenvironment> E, put put, waledit edit, durability durability) throws IOException {Putuuidcolumnifmis Sing (E, put, edit, durability); } private void Putuuidcolumnifmissing (observercontext<regioncoprocessorenvironment> E, put put, waledit edit, Durability Durability) {try {if (!put.has (Bytes.tobytes ("CF1"), Bytes.tobytes ("UUID"))) {String uuid = Md5util.enc    Rypt (Put.tostring ());   Put.add (Bytes.tobytes ("CF1"), Bytes.tobytes ("uuid"), Bytes.tobytes (UUID));  }} catch (Exception E1) {e1.printstacktrace (); } }}
1.1.3 into Itdog8-yting-hbase-coprocessor-observer-1.0.0.jar and uploaded to HDFs (hbase shell mode loading coprocessor to be used)bash-4.1$ Hadoop fs-put/usr/yting/hbase/coprocessor/test/itdog8-yting-hbase-coprocessor-observer-1.0.0.jar/usr/ itdog8/yting/hbase/coprocessor/test/
1.1.4 hbase Shell mode load coprocessorHBase (main):017:0> alter ' itdog8:hbase_coprocessor_test_1 ', ' coprocessor ' = ' hdfs:///usr/yting/hbase/ coprocessor/test/itdog8-yting-hbase-coprocessor-observer-1.0.0.jar| Com.itdog8.study.cloud.hbase.coprocessor.observer.testaddcolumnbaseregionobserver|1001|arg1=1,arg2=2 ' Updating All regions with the new schema ... 0/1 regions UPDATED.1/1 Regions updated. done.0 row (s) in 2.1490 seconds
1.1.5 Testhbase (Main):025:0> scan ' itdog8:hbase_coprocessor_test_1 'ROW Column+cell 0 row (s) in 0.0130 seconds
hbase (main):026:0> put ' itdog8:hbase_coprocessor_test_1 ', ' Row-zhagnsan ', ' cf1:name ', ' Zhangsan '0 row (s) in 0.0120 seconds
hbase (Main):027:0> scan ' itdog8:hbase_coprocessor_test_1 'ROW                                                 Column+cell                 &NBS P                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp               row-zhagnsan               and nbsp                       Column=cf1:name, timestamp=1438919899641, Val Ue=zhangsan                               &NBSP ; &nbsp                          ,         &NB Sp                         row-zhagnsan                                       COLUMN=CF 1:uuid, timestamp=1438919899641, value=2a66e9ed97e9ded4c21d1ef555cfa69e                                      ,         &NB Sp                      1 Row (s) in 0.0110 seconds
HBase (Main):028:0>
It can be found that the hbase-coprocessor-observer (trigger) has successfully triggered and executed (or is known as a trigger habit point and easier to understand) when we put the data, he put the UUID in when there was no UUID. OK
1.1.6 hbase Shell mode uninstall coprocessoralter ' itdog8:hbase_coprocessor_test_1 ', METHOD = ' Table_att_unset ', NAME = ' coprocessor$1 '
1.2 terminal Endpoint (similar to a stored procedure in a traditional database)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hbase-coprocessor-the introduction and use of observer (trigger) for the observer of the Coprocessor | That Yi-Wipe smile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.