无法使用Java API连接到HBase

时间:2019-04-03 12:06:18

标签: java hbase

我需要使用Java来操作HBase的人的帮助,但是有问题,我已经在线寻找答案半天了。但是没有解决方案。...希望您能为我提供帮助。

    @Before
    public void init() throws Exception {
        Configuration config = HBaseConfiguration.create();
        // 指定zookeeper的地址
        config.set("hbase.zookeeper.quorum", "192.168.220.128:2181");
        config.setInt("hbase.rpc.timeout",20000);
        config.setInt("hbase.client.operation.timeout",30000);
        config.setInt("hbase.client.scanner.timeout.period",200000);
        connection = ConnectionFactory.createConnection(config);

    }

    @Test
    public void testCreateTable() throws Exception {

        String[] cfs = new String[] { "name","age" };
        Admin admin = connection.getAdmin();
        if (admin.tableExists(TableName.valueOf("person"))) {
            System.out.println("sorry, table already exist !");
        }
        HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf("people"));
        Arrays.stream(cfs).forEach(cf -> {
            HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf);
            columnDescriptor.setMaxVersions(1);
            hTableDescriptor.addFamily(columnDescriptor);
        });
        admin.createTable(hTableDescriptor);
    }

所以我运行此测试方法,控制台会提示:

 Call exception, tries=10, retries=35, started=45479 ms ago, cancelled=false, msg=row 'person,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=localhost,16201,1554286011145, seqNum=0

error screenshot

我希望我能在Hbase中成功创建一个表 我该怎么办

0 个答案:

没有答案