zoukankan      html  css  js  c++  java
  • HBase EndPoint加载失败

    概述

      参考博客(http://blog.csdn.net/carl810224/article/details/52224441)编写EndPoint协处理器,编写完成后使用Maven打包(使用assembly插件,指定descriptorRefs值为jar-with-dependencies,将依赖的jar包也加进来),再将jar包上传到HDFS上,然后使用添加协处理器到指定表:

    disable 'test_table'
    alter 'test_table',METHOD=>'table_att','coprocessor'=>'hdfs://nameservice:/sum.jar|com.hbase.demo.endpoint.SumEndPoint|100'
    enable 'test_table'
    describe 'test_table'

    卸载处理器:

    alter 'test_table',METHOD=>'table_att_unset',NAME=>'coprocessor$1'

    coprocessor$1表示第一个协处理,可以通过describe命令查看表加载的处理器信息。

      使用alter添加endpoint之后,输入decribe查看表信息,发现表信息中心增加了coprocessor字段,事实上这并不表示已经加载成功。然后运行client程序,报错信息是

    “hbase.ipc.CoprocessorRpcChannel:Call failed on IOException”
    
    “UnknownProtocolException:No registered coprocessor service found for name SumService in region test_table.......”

      查看RegionServer日志,发现错误信息是     

    “RegionCoprocessorHost:Failed to load coprocessor com.hbase.demo.endpoint.SumEndPoint”
    “java.lang.LinkageError:loader constraint violation in interface itable initialization:when resolving method
      com.hbase.demo.endpoint.SumEndPoint.getService()Lcom/google/protobuf/Service;... the class loader......
        have different Class objects for the type obuf/Service;used in the signature...."

    实际上协处理器并没有加载成功。

    为什么没有加载成功

      “java.lang.LinkageError:loader constraint violation in interface itable initialization...”表示发生了jar包冲突,就是一个工程中不止1个jar包中包含了完全相同的类,JVM不确定应该使用哪个jar包,解决办法就是直接删除多余jar包(确保jar包其余类不会被工程使用)。由于使用Maven的assembly插件打包时,选择了“jar-with-dependencies”的方式将依赖的所有jar包也打到了EndPoint中,在加载EndPoint时,EndPoint对应jar包中的类与HBase ClassPath中某个jar包对应的类完全相同,JVM不确定应该使用哪个Jar包,因此加载不成功。

    怎么加载成功

       找到了原因,对应的解决方法就很简单了,去掉Maven的assembly插件中的“jar-with-dependencies”选项,仅将SumEndPoint.java和Sum.java打到jar包中,然后重新加载就可以了。

      最后,Hbase 1.2.0使用protobuf作为RPC协议,因此需要首先下载protobuf变异.proto文件生成对应的.java文件,下载地址:github.com/google/protobuf/releases,Hbase 1.2.0对应protoc-2.5.0-win32.zip。下载完成后,进入bin目录,变异proto文件

    proto --java_out=./ sum.proto
  • 相关阅读:
    QT5编程入门教程
    bstr_t与BSTR
    Android Studio 更改APP图标
    Indy服务器关闭所有客户端连接
    使用高德地图API
    内网渗透——Hadoop未授权访问getshell
    内网渗透——struts2远程任意代码执行(s2-046)
    工具使用——cobalt strike使用
    工具使用——docker使用
    漏洞复现——weblogic任意文件上传(cve-2018-2894)
  • 原文地址:https://www.cnblogs.com/lz3018/p/7580962.html
Copyright © 2011-2022 走看看