Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> First postPut coprocessor test drive


Copy link to this message
-
Re: First postPut coprocessor test drive
Hi Thomas,

There are some examples in my book, or here https://github.com/larsgeorge/hbase-book/tree/master/ch04/src/main/java/coprocessor. You can use the live cycle methods start() and stop() to create the resources you need. Since the class is instantiated only once this is a common approach to share resources. You need to use the provided CoprocosserEnvironment instance and its getTable() to retrieve the reference.

Lars

On Nov 30, 2011, at 1:44 PM, Steinmaurer Thomas wrote:

> Hello,
>
> I want to get a hang on implementing a postPut co-processor. A simple
> test case is pretty much adding 1 to received cell values and store that
> into a second HBase table. I basically have this here:
>
> @Override
> public void postPut(
> final ObserverContext<RegionCoprocessorEnvironment> c
> , final Put put
> , final WALEdit edit
> , final boolean writeToWAL
> ) throws IOException {
> Map<byte[], List<KeyValue>> familyMap > put.getFamilyMap();
> RegionCoprocessorEnvironment e = c.getEnvironment();
> if
> (Arrays.equals(e.getRegion().getTableDesc().getName(),
> Bytes.toBytes("t"))) {
> List<KeyValue> kvs = familyMap.get("f1");
> for (KeyValue kv : kvs) {
>
> }
> }
> }
>
> Now the question is how to process in the for loop to get the cell
> value, increment the value by 1 and store that into a second HBase
> table.
>
> In general, I guess instantiating a HBase table should be at a central
> point of my region observer class instead of the postPut implementation
> etc ... Concrete examples on co-processors are rather rare, the only
> useful thing I found were different coprocessor unit test classes, but
> they don't go that far.
>
> Thanks!
>
> Thomas
>

NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB