2
votes

I am trying to add user-define coprocessor for secondary storage purpose locally on my system, I have refered "https://www.3pillarglobal.com/insights/hbase-coprocessors" link for implementation. While doing so when I am trying to do static coprocessor loading I am getting some errors related to RegionCoprocessor saying that the mention classed is not type of RegionCoprocessor. Please help me out to get this functionality done.

DatabaseCrudCoprocessor.java > Implementation >

 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
@InterfaceStability.Evolving
public class DatabaseCrudCoprocessor  implements RegionObserver {
    private static final String className = "DatabaseCrudCoprocessor";
    private static JsonObject object = new JsonObject();
    static final CloudLogger logger = CloudLogger.getLogger("DatabaseCrudCoprocessor");


    public void postPut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit, Durability durability)
            throws IOException {
        try {
            Connection con = c.getEnvironment().getConnection();
            logger.info("---------------------This Code Is Excecute---------------------------");
        }catch(Exception e) {
            logger.error("In "+className+" postPut : Exception : "+e);
        }
    }
}

Log.Errors on HBase > > >

On Hadoop-Master >>>>>>

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/demo-0.0.2-SNAPSHOT-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/phoenix-5.0.0-HBase-2.0-client.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/phoenix-5.0.0-HBase-2.0-hive.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/phoenix-5.0.0-HBase-2.0-pig.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/phoenix-5.0.0-HBase-2.0-thin-client.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hbase/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 0 [RS-EventLoopGroup-1-2] INFO SecurityLogger.org.apache.hadoop.hbase.Server - Connection from 127.0.0.1:45903, version=2.2.2, sasl=false, ugi=hadoop (auth:SIMPLE), service=RegionServerStatusService 1266 [master/localhost:60000:becomeActiveMaster] ERROR org.apache.hadoop.hbase.master.RegionServerTracker - localhost,60020,1576052978374 has no matching ServerCrashProcedure 1266 [master/localhost:60000:becomeActiveMaster] ERROR org.apache.hadoop.hbase.master.RegionServerTracker - localhost,60020,1539250172019 has no matching ServerCrashProcedure 1266 [master/localhost:60000:becomeActiveMaster] ERROR org.apache.hadoop.hbase.master.RegionServerTracker - localhost,60020,1576071410923 has no matching ServerCrashProcedure 1266 [master/localhost:60000:becomeActiveMaster] ERROR org.apache.hadoop.hbase.master.RegionServerTracker - localhost,60020,1576127072238 has no matching ServerCrashProcedure

On RegionServer >>>>>>>>

0    [RS-EventLoopGroup-1-3] INFO  SecurityLogger.org.apache.hadoop.hbase.Server  - Connection from 127.0.0.1:33828, version=2.2.2, sasl=false, ugi=hadoop (auth:SIMPLE), service=AdminService

167 [RS_CLOSE_META-regionserver/localhost:60020-0] ERROR org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost - demo.DatabaseCrudCoprocessor is not of type RegionCoprocessor. Check the configuration of hbase.coprocessor.region.classes 167 [RS_CLOSE_META-regionserver/localhost:60020-0] ERROR org.apache.hadoop.hbase.coprocessor.CoprocessorHost - Cannot load coprocessor DatabaseCrudCoprocessor 1302 [RS-EventLoopGroup-1-4] INFO SecurityLogger.org.apache.hadoop.hbase.Server - Connection from 127.0.0.1:33830, version=2.2.2, sasl=false, ugi=hadoop (auth:SIMPLE), service=ClientService

2

2 Answers

3
votes

Try to implement RegionCoprocessor and RegionObserver and override getRegionObserver() method.If you are using hbase 2.0 version

  public class RegionObserverExample implements RegionCoprocessor, RegionObserver {
         @Override
        public Optional<RegionObserver> getRegionObserver() {
          return Optional.of(this);
        }
       ...
     }
0
votes

To be a RegionCoprocessor your class should also implement org.apache.hadoop.hbase.coprocessor.RegionCoprocessor