我想用Go客户端操作HBase DB来创建一个表,但是我无法解决这个问题。
代码:
package main
import (
"log"
"github.com/tsuna/gohbase"
"github.com/tsuna/gohbase/hrpc"
"golang.org/x/net/context"
)
func main() {
admin := gohbase.NewAdminClient("master")
columns := []string{"cf"}
createReq := hrpc.NewCreateTable(context.Background(), []byte("goTest"), columns)
result, err := admin.CreateTable(createReq)
if err != nil {
log.Println("err:", err)
}
log.Println("result:", result)
}
当我运行下面的代码时,它给了我一个Java异常:
ym@master:~/gopath/src/test$ go run hbase_createtable.go
2016/05/05 17:22:59 Connected to 192.168.0.116:2181
2016/05/05 17:22:59 Authenticated: id=95836126668718124, timeout=30000
2016/05/05 17:22:59 Recv loop terminated: err=EOF
2016/05/05 17:22:59 Send loop terminated: err=<nil>
2016/05/05 17:22:59 err: HBase Java exception java.io.IOException:
java.io.IOException: null
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2159)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:104)
at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)
at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.hadoop.hbase.HColumnDescriptor.getMaxVersions(HColumnDescriptor.java:617)
at org.apache.hadoop.hbase.master.HMaster.sanityCheckTableDescriptor(HMaster.java:1582)
at org.apache.hadoop.hbase.master.HMaster.createTable(HMaster.java:1452)
at org.apache.hadoop.hbase.master.MasterRpcServices.createTable(MasterRpcServices.java:429)
at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java:52195)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2117)
... 4 more
2016/05/05 17:22:59 result: <nil>
我对Java一无所知,这个问题困扰了我好几天。 我确信master上的hbase服务器工作正常,因为我可以从shell创建一个表。
如果有人可以帮助解决这个异常,我将不胜感激......