HBASE API测试问题之一记录

因为生产产品运用HBASE, 在整合API的同时,进行必要的测试;

测试目的很简单,执行封装好的HBASE,进行建表删表操作,代码如下

        DBClient client = new HBaseDBClient();
        boolean res1 = client.prepare("test").exec(Commands.CREATETABLE, "testCreateTable", columnList,null);
        System.out.println("is table created?" + res1);
        client.release();

        Thread.sleep(1000 * 20);

        DBClient client2 = new HBaseDBClient();
        boolean res2 = client2.prepare("test").exec(Commands.DELETETABLE, "testCreateTable", columnList,null);
        System.out.println("is table deleted?" + res2);
        client2.release();

于是出现问题.

打印结果为

is table created? true

is table deleted? false

=====================================================================

该测试,使用HBASE API的顺序如下(简单描写)

ConnectionFactory.createConnection(config) -> admin.tableExists() - > admin.createTable -> releaseAllResource()

ConnectionFactory.createConnection(config) -> admin.tableExists() -> admin.disableTable -> admin.dropTable -> releaseAllResource()

接着摸索,发现问题出现在第二次admin.tableExists()返回为false. 该API代码如下

  @Override
  public boolean tableExists(final TableName tableName) throws IOException {
    return executeCallable(new RpcRetryingCallable<Boolean>() {
      @Override
      protected Boolean rpcCall(int callTimeout) throws Exception {
        return MetaTableAccessor.tableExists(connection, tableName);
      }
    });
  }

其作用为在metaTable中的查找该表是否存在记录,在HBASE SHELL中使用以下指令可以查看详细<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值