包使用:
import org.apache.hadoop.hbase.thrift.generated.AlreadyExists;
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
import org.apache.hadoop.hbase.thrift.generated.Hbase;
import org.apache.hadoop.hbase.thrift.generated.IOError;
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
import org.apache.hadoop.hbase.thrift.generated.Mutation;
import org.apache.hadoop.hbase.thrift.generated.TCell;
import org.apache.hadoop.hbase.thrift.generated.TRowResult;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
致电方法
public void start() {
try {
TTransport socket = new TSocket("host-name", 9090);// IP Host Name
TProtocol protocol = new TBinaryProtocol(socket, true, true);// Note here
Hbase.Client client = new Hbase.Client(protocol);
socket.open();
System.out.println("open");
try {
System.out.println("scanning tables...");
for (byte[] name : client.getTableNames()) {
//code
}
} catch (Exception e) {
e.printStackTrace();
out.println(e.getMessage());
}
socket.close();
out.println("close");
} catch (TTransportException e) {
e.printStackTrace();
out.println(e.getMessage());
} catch (TException e) {
e.printStackTrace();
out.println(e.getMessage());
}
}
问题:
代码java 得到错误:方法名称无效:' getTableNames' 我无法在Hbase中提供列表 也许我对错过的包裹有疑问
答案 0 :(得分:1)
谢谢,问题解决了,我在 hbase-0.94.19.tar.gz \ hbase-0.94.19 \ src \ examples \ thrift2 中使用了DemoClient.java,这个rar比我安装好了在服务器上。我添加了这种依赖
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-thrift</artifactId>
<version>0.98.2-hadoop2</version>
<type>jar</type>
</dependency>