我目前正在尝试使用Java API连接到hbase并创建一个新表 . 它似乎工作,但admin.createTable()方法没有完成 . 所以“完成!”从未打印过,程序永远不会结束 . 请参阅下面的代码 .
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "xxx.xxx.xxx.xxx");
config.set("hbase.zookeeper.property.clientport", "2181");
String tableName = "actors";
Connection connection;
try {
connection = ConnectionFactory.createConnection(config);
Admin admin = connection.getAdmin();
Table table = connection.getTable(TableName.valueOf(tableName));
HTableDescriptor htable = new HTableDescriptor(TableName.valueOf(tableName));
htable.addFamily( new HColumnDescriptor("movies"));
System.out.println( "Creating Table..." );
admin.createTable( htable );
System.out.println("Done!");
table.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
没有例外 . 如果我打开一个hbase shell,则会创建包含列族电影的表actor . 我在这里想到了我可能做错的事情 .