我已经在单个节点上安装了Quickstart CDH 5.13并设置了kudu服务(所有角色均正常运行)。 kudu大师只有一位,是领袖。我想使用以下代码通过Java Kudu API连接kudu master:
package com.codebind;
import java.util.ArrayList;
import java.util.List;
import org.kududb.ColumnSchema;
import org.kududb.Schema;
import org.kududb.Type;
import org.kududb.ColumnSchema.*;
import org.kududb.client.KuduClient;
import org.kududb.client.KuduClient.KuduClientBuilder;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
KuduClient kuduClient =
new KuduClientBuilder("127.0.0.1:7051").build();
ColumnSchema usernameCol =
new ColumnSchemaBuilder("username", Type.STRING)
.key(true).build();
ColumnSchema ageCol =
new ColumnSchemaBuilder("age", Type.INT8)
.build();
List<ColumnSchema> columns = new ArrayList<ColumnSchema>();
columns.add(usernameCol);
columns.add(ageCol);
Schema schema = new Schema(columns);
String tableName = "table1";
try {
if ( ! kuduClient.tableExists(tableName) ) {
kuduClient.createTable(tableName, schema);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
构建代码时出现以下错误:
421 [新I / O工作者#1]错误org.kududb.client.TabletClient-[Peer Kudu Master-quickstart.cloudera:7051]来自意外的异常 下游[id:0x93e81f9b,/10.0.2.15:37191 => /10.0.2.15:7051] org.kududb.client.InvalidResponseException:无法反序列化 响应,不兼容的RPC?错误是:auths [0] .method at org.kududb.client.KuduRpc.readProtobuf(KuduRpc.java:243)
432 [新I / O工人#1]警告 org.kududb.client.GetMasterRegistrationReceived-收到一个错误 回复自:quickstart.cloudera:7051 org.kududb.client.ConnectionResetException:[Peer Kudu Master- quickstart.cloudera:7051]在[id:0x93e81f9b, /10.0.2.15:37191:> /10.0.2.15:7051] org.kududb.client.TabletClient.cleanup(TabletClient.java:622)
442 [新I / O工人#1]警告 org.kududb.client.GetMasterRegistrationReceived-无法找到 组长(quickstart.cloudera:7051),将重试
但是,当我使用“ kudu master list 127.0.0.1:7051”命令时,它会给出
uuid | rpc地址 ---------------------------------- + --------------- ----------- af5a8a14e1ec4603ad5fa7d6c7398b21 | quickstart.cloudera:7051
我也可以用相同的方式查看平板电脑服务器。
我不明白为什么我的代码无法正常工作,并说出“找不到领导者”,如上所示。你有什么主意吗?