我的环境:hadoop2.2+hbase0.98自定义编写了一个count功能统计hbase表的行数,服务器端是直接采用RowCountEndpoint.java这个,客户端编写如下:
public void getCount(){
final ExampleProtos.CountRequest request = ExampleProtos.CountRequest.getDefaultInstance();
try {
Map<byte[],Long> result = table.coprocessorService(ExampleProtos.RowCountService.class,
null, null,
new Batch.Call<ExampleProtos.RowCountService,Long>() {
public Long call(ExampleProtos.RowCountService counter) throws IOException {
ServerRpcController controller = new ServerRpcController();
BlockingRpcCallback<ExampleProtos.CountResponse> rpcCallback = new BlockingRpcCallback<ExampleProtos.CountResponse>();
counter.getRowCount(controller, request, rpcCallback);
ExampleProtos.CountResponse response = rpcCallback.get();
if (controller.failedOnException()) {
throw controller.getFailedOn();
}
System.out.println(response.getCount() + "@@@@@@@@@");
return (response != null && response.hasCount()) ? response.getCount() : 0;
}
});
long total = 0;
for (Map.Entry<byte[], Long> entry : result.entrySet()) {
total += entry.getValue().longValue();
System.out.println("Region: " + Bytes.toString(entry.getKey())
+ ", Count: " + entry.getValue());
}
System.out.println("Total Count: " + total);
} catch (ServiceException e) {
e.printStackTrace();
} catch (Throwable e) {
e.printStackTrace();
}
}
把hbase-examples-0.98.1-hadoop2.jar设置到目标表syslog的属性中,用客户端调用。syslog表的行数可以被查出来。测试了几个表都是正常的。
但是当测试库里的一个有1.5亿条数据的表时,这个表有12个region,当查第6个region的时候,出现下面情况:
Eclipse出现如下错误:60000 millis timeout while waiting for channel to be ready for read. ch
hbase regionserver log出现如下错误:WARN [RpcServer.handler=4,port=60020] ipc.RpcServer: RpcServer.handler=4,port=60020: caught a ClosedChannelException, this means that the server was processing a request but the client went away. The error message was: null
2014-06-20 14:20:07,430 ERROR [RpcServer.handler=10,port=60020] ipc.RpcServer: Unexpected throwable object
com.google.protobuf.UninitializedMessageException: Message missing required fields: count
尝试过把<property>
<name>hbase.rpc.timeout</name>
<value>6000000</value>
</property>调整这么大,还是不行。发现查第6个region的时候就出现regionserver log这样的问题。
请各帮忙看看。谢谢。
|