From 4687ab24213fb2292a5cf13606efc0f8fd043d51 Mon Sep 17 00:00:00 2001 From: Sakthi Date: Tue, 29 Jan 2019 18:38:04 -0800 Subject: [PATCH] HBASE-21794: Update the Coprocessor observer example given in section 111.1 of the ref guide. --- src/main/asciidoc/_chapters/cp.adoc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/asciidoc/_chapters/cp.adoc b/src/main/asciidoc/_chapters/cp.adoc index abe334c68afbd0f1a5e995b951882293e4efc2be..aa7e0b2e8258a9f93b7a3f8b69c5f849b3051214 100644 --- a/src/main/asciidoc/_chapters/cp.adoc +++ b/src/main/asciidoc/_chapters/cp.adoc @@ -483,8 +483,7 @@ The following Observer coprocessor prevents the details of the user `admin` from returned in a `Get` or `Scan` of the `users` table. . Write a class that implements the -link:https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/coprocessor/RegionObserver.html[RegionObserver] -class. +link:https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/coprocessor/RegionCoprocessor.html[RegionCoprocessor], link:https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/coprocessor/RegionObserver.html[RegionObserver] class. . Override the `preGetOp()` method (the `preGet()` method is deprecated) to check whether the client has queried for the rowkey with value `admin`. If so, return an @@ -500,15 +499,19 @@ empty result. Otherwise, process the request as normal. Following are the implementation of the above steps: - [source,java] ---- -public class RegionObserverExample implements RegionObserver { +public class RegionObserverExample implements RegionCoprocessor, RegionObserver { private static final byte[] ADMIN = Bytes.toBytes("admin"); private static final byte[] COLUMN_FAMILY = Bytes.toBytes("details"); private static final byte[] COLUMN = Bytes.toBytes("Admin_det"); private static final byte[] VALUE = Bytes.toBytes("You can't see Admin details"); + + @Override + public Optional getRegionObserver() { + return Optional.of(this); + } @Override public void preGetOp(final ObserverContext e, final Get get, final List results) -- 2.17.2 (Apple Git-113)