伙计们,我正在尝试向hbase添加一个区域观察者,代码如下:
public class TestAddColumnBaseRegionObserver extends BaseRegionObserver{
@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit, Durability durability) throws IOException {
putUUIDColumnIfMissing(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 = put.toString(); // md5
put.add(Bytes.toBytes("cf1"), Bytes.toBytes("uuid"), Bytes.toBytes(uuid));
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
所以这段代码会添加一个新列&#34; uuid&#34;如果没有&#34; cf1:uuid&#34;表中的列。
当我在hbase shell中手动添加.jar时,它会起作用,但是在执行另一种方式时:通过将hbase.coprocessor.region.classes修改为TestAddColumnBaseRegionObserver类来修改hbase-site.xml
<property>
<name>hbase.coprocessor.region.classes</name>
<value>com.hbase.hook.TestAddColumnBaseRegionObserver</value>
</property>
并重新启动hbase,登录到hbase shell时报告错误并且tred执行hbase命令
ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing at org.apache.hadoop.hbase.master.HMaster.checkInitialized(HMaster.java:2177) at org.apache.hadoop.hbase.master.HMaster.checkNamespaceManagerReady(HMaster.java:2182) at org.apache.hadoop.hbase.master.HMaster.ensureNamespaceExists(HMaster.java:2375) at org.apache.hadoop.hbase.master.HMaster.createTable(HMaster.java:1444) at org.apache.hadoop.hbase.master.MasterRpcServices.createTable(MasterRpcServices.java:422) at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java:48502) at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2114) at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:101) at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130) at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107) at java.lang.Thread.run(Thread.java:745)
之前有没有人遇到过类似的问题?或者你知道导致这个问题的原因吗?