Hi all:
I want to dynamic add coprocessor in order to not restart hbase.
Following is my code:
Path path = new Path("/coprocessor_jars");
FileSystem fs = FileSystem.get(conf);
FileStatus[] status = fs.listStatus(path);
Path[] listedPaths = FileUtil.stat2Paths(status);
for (Path p : listedPaths) {
if(p.getName().contains("test.jar")){
hdfsPath = p;
}
}
HBaseAdmin hadmin = new HBaseAdmin(conf);
HTableDescriptor tableDesc =
hadmin.getTableDescriptor("testTbl".getBytes());
tableDesc.addCoprocessor("org.apache.hadoop.hbase.coprocessor.transactional.TestRegionEndpoint",
hdfsPath,
Coprocessor.PRIORITY_USER, null);
//
tableDesc.removeCoprocessor("org.apache.hadoop.hbase.coprocessor.transactional.TrxRegionEndpoint");
for (Entry<ImmutableBytesWritable, ImmutableBytesWritable> entry :
tableDesc.getValues().entrySet()) {
System.out.println(Bytes.toString(entry.getKey().get()) + " = " +
Bytes.toString(entry.getValue().get()));
}
hadmin.disableTable("testTbl".getBytes());
hadmin.modifyTable("testTbl", tableDesc);
hadmin.enableTable("testTbl");
the syso print : coprocessor$1 =
hdfs://192.168.0.17:17400/coprocessor_jars/test.jar|org.apache.hadoop.hbase.coprocessor.transactional.TestRegionEndpoint|1073741823|
and the remote side return Exception:
org.apache.hadoop.hbase.DoNotRetryIOException:
org.apache.hadoop.hbase.DoNotRetryIOException: Class
org.apache.hadoop.hbase.coprocessor.transactional.TestRegionEndpoint cannot be
loaded Set hbase.table.sanity.checks to false at conf or table descriptor if
you want to bypass sanity checks
I use hbase 1.2 and the test.jar is not under hbase/lib, I just put the
test.jar in hdfs.
If I add test.jar to hbase/lib but not restart hbase, the upon code still throw
same exception.
If I add test.jar to hbase/lib and restart hbase, the upon code will exec
successful.
But my requirement is not restart hbase.
Is there someone can give me a favor.
Thanks