Database Reference
In-Depth Information
MasterObserver : This observer provides hooks for data deinition type
operations such as table creation, deletion, schema modiication, and so on.
The MasterObserver coprocessor runs within the context of HBase Master
and can be registered by setting the hbase.coprocessor.master.classes
coniguration property.
For each type of observer coprocessor, a base abstract class is deined that
implements the default behavior for the methods declared in the implemented
interface. For example, BaseRegionObserver implements all the methods
with the default behavior declared in the RegionObserver interface. Similarly,
BaseMasterObserver implements all the methods with the default behavior
declared in the MasterObserver interface. This provides the lexibility of overriding
only in the focus methods without worrying about implementing the rest of the
methods. The following skeleton code shows how to implement a coprocessor by
extending the base abstract classes:
package com.ch5;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.
RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.security.AccessDeniedException;
// Sample access-control observer coprocessor. It utilizes //
RegionObserverand intercept preGet() method to check user //
privilege for the given table and column family.
Public class ObserverCoprocessorEx extends BaseRegionObserver {
// @Override
Public void preGet(ObserverContext<RegionCoprocessorEnvironment> c,Get
get, List<KeyValue> result) throws IOException {
byte[] region = c.getEnvironment().getRegion().getRegionInfo()
.getRegionName();
// TODO Code for checking the permissions over
// table or region...
if (ACCESS_NOT_ALLOWED) {
throw new AccessDeniedException("User is not allowed for access");
}
}
// Similarly override prePut(), preDelete(), etc. based on the
// need.
}
 
Search WWH ::




Custom Search