hbase java端调用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hbase java端调用相关的知识,希望对你有一定的参考价值。
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/thirdparty/guava/common/primitives/UnsignedBytes
at org.apache.hadoop.io.FastByteComparisons$LexicographicalComparerHolder$UnsafeComparer.compareTo(FastByteComparisons.java:226)
at org.apache.hadoop.io.FastByteComparisons$LexicographicalComparerHolder$UnsafeComparer.compareTo(FastByteComparisons.java:113)
at org.apache.hadoop.io.FastByteComparisons.compareTo(FastByteComparisons.java:42)
at org.apache.hadoop.io.WritableComparator.compareBytes(WritableComparator.java:150)
at org.apache.hadoop.hbase.io.ImmutableBytesWritable.compareTo(ImmutableBytesWritable.java:174)
at org.apache.hadoop.hbase.io.ImmutableBytesWritable.equals(ImmutableBytesWritable.java:200)
at java.util.HashMap.put(Unknown Source)
at org.apache.hadoop.hbase.HColumnDescriptor.setValue(HColumnDescriptor.java:475)
at org.apache.hadoop.hbase.HColumnDescriptor.setValue(HColumnDescriptor.java:493)
at org.apache.hadoop.hbase.HColumnDescriptor.setInMemory(HColumnDescriptor.java:662)
at org.apache.hadoop.hbase.HTableDescriptor.<clinit>(HTableDescriptor.java:1114)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at $Proxy4.<clinit>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:178)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:335)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:312)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:364)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:682)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:110)
at jd.meiyx.nosql.TestHDFS.createTable(TestHDFS.java:17)
at jd.meiyx.nosql.TestHDFS.main(TestHDFS.java:34)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.thirdparty.guava.common.primitives.UnsignedBytes
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more
你可以到jarsearch上搜索含有这个类的jar包,然后把它放到classpath下就行了
hbase笔记
UserGroupInformation#getCurrentUser函数
该函数比较难理解之处在于Server端调用时,通过
AccessControlContext context = AccessController.getContext();
获取一个AccessControlContext对象,该对象包含当前线程中所有的Subject实体,由于服务器端会启动多个handler线程并行处理客户端请求,因此每个handler内部的AccessControlContext均是不同的,它们通常与对应的客户端信息相同。很多人阅读代码时不明白AccessControlContext是怎样自动填充的?这个对象的内容在RPC 层调用UserGroupInformation#doAs函数时会自动填充,具体可了解JDK中对AccessControlContext的说明文档。
以上是关于hbase java端调用的主要内容,如果未能解决你的问题,请参考以下文章