hbase2.0.0 之上重编译phoenix-5.0.0

部分组件版本 hbase 2.1.0, hadoop 3.0.0。通过phoenix 构建在HBase上的一个SQL层,能让我们用标准的JDBC APIs而不是HBase客户端APIs来进行数据操作。

目前官方最高版本为基于hbase2.0的phoenix5.0版本,没有提供基于hbase2.1版本,故只能自己编译。

 

phoenix 代码

bin/目录是编译后的执行客户端,去src目录下载phoenix5.0.0-hbase2.0 tag代码, 打包编译没有问题。
将pom.xml中的hbase版本从2.0.0改到2.0.2,先进行小版本升级实验,mvn打包报错如下:

具体idea log如下

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project phoenix-core: Compilation failure
[ERROR] /D:/360安全浏览器下载/apache-phoenix-5.0.0-HBase-2.0-src (1)/apache-phoenix-5.0.0-HBase-2.0-src/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/covered/data/IndexMemStore.java:[84,18] <匿名org.apache.phoenix.hbase.index.covered.data.IndexMemStore$1>中的compare(org.apache.hadoop.hbase.Cell,org.apache.hadoop.hbase.Cell)无法覆盖org.apache.hadoop.hbase.CellComparatorImpl中的compare(org.apache.hadoop.hbase.Cell,org.apache.hadoop.hbase.Cell)
[ERROR] 被覆盖的方法为final
 或者

2019-03-20 15:44:21,036 [426266923]  Unable to import maven project -      #org.jetbrains.idea.maven - org.eclipse.aether.internal.impl.DefaultArtifactResolver.setLoggerFactory(Lorg/eclipse/aether/spi/log/LoggerFactory;)Lorg/eclipse/aether/internal/impl/DefaultArtifactResolver; 
java.lang.NoSuchMethodError: org.eclipse.aether.internal.impl.DefaultArtifactResolver.setLoggerFactory(Lorg/eclipse/aether/spi/log/LoggerFactory;)Lorg/eclipse/aether/internal/impl/DefaultArtifactResolver;
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.resolve(Maven3ServerEmbedderImpl.java:1223)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.doResolve(Maven3ServerEmbedderImpl.java:1178)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.doResolve(Maven3ServerEmbedderImpl.java:1172)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.resolve(Maven3ServerEmbedderImpl.java:1041)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2019-03-20 15:44:21,037 [426266924]  ERROR -      #org.jetbrains.idea.maven - IntelliJ IDEA 2017.3.4  Build #IU-173.4548.28 

将hbase版本由2.0.0改为2.1.0,build提示CellComparatorImp构造方法参数问题,原来的compare方法用的是两参数方法,现在原来的方法设置了final属性,我这里改为三参数方法,但里面的默认值不变。修改后如下

this(new CellComparatorImpl(){
      @Override
      public int compare(Cell a, Cell b, boolean ignoreSequenceid) {
          return super.compare(a, b, true);
      }
  });

至此可以打包编译,很顺利没有其他问题

扩充

2019-03-20 17:45:39,705 ERROR [RS_OPEN_PRIORITY_REGION-regionserver/hadoop001:60020-1] coprocessor.CoprocessorHost: The coprocessor org.apache.phoenix.coprocessor.MetaDataEndpointImpl threw java.lang.NoClassDefFoundError: org/apache/htrace/Sampler
java.lang.NoClassDefFoundError: org/apache/htrace/Sampler
	at org.apache.phoenix.coprocessor.MetaDataEndpointImpl.start(MetaDataEndpointImpl.java:520)
	at org.apache.hadoop.hbase.coprocessor.BaseEnvironment.startup(BaseEnvironment.java:72)
	at org.apache.hadoop.hbase.coprocessor.CoprocessorHost.checkAndLoadInstance(CoprocessorHost.java:263)
	at org.apache.hadoop.hbase.coprocessor.CoprocessorHost.load(CoprocessorHost.java:226)
	at org.apache.hadoop.hbase.coprocessor.CoprocessorHost.load(CoprocessorHost.java:185)
	at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.loadTableCoprocessors(RegionCoprocessorHost.java:388)
	at org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost.(RegionCoprocessorHost.java:275)
	at org.apache.hadoop.hbase.regionserver.HRegion.(HRegion.java:826)
	at org.apache.hadoop.hbase.regionserver.HRegion.(HRegion.java:715)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.apache.hadoop.hbase.regionserver.HRegion.newHRegion(HRegion.java:7002)
	at org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:7199)
	at org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:7172)
	at org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:7130)
	at org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:7081)
	at org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler.openRegion(OpenRegionHandler.java:283)
	at org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler.process(OpenRegionHandler.java:108)
	at org.apache.hadoop.hbase.executor.EventHandler.run(EventHandler.java:104)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.htrace.Sampler
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 24 more

报错显示缺少htrace对应jar包,发现hbase 2.1.0版本引入htrace,缺这个包,需要自己拷贝到hbase/lib

https://mvnrepository.com/artifact/org.apache.htrace/htrace-core4/4.2.0-incubating

你可能感兴趣的:(hbase2.0.0 之上重编译phoenix-5.0.0)