hbck源码系列(四)--表的完整性检查和修复

一,完整性检查
  1检查表在HDFS的完整性

二.checkRegionChain方法
     完整性检查,主要检查工作在checkRegionChain方法,该方法主要两个作用:

   1.根据检查条件,检查异常

   2.根据检查条件,修复异常

    检查条件和异常都指什么?

    2.1  异常
  @Override
  public void handleRegionStartKeyNotEmpty(HbckInfo hi) throws IOException{
    errors.reportError(ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,
        "First region should start with an empty key.  You need to "
        + " create a new region and regioninfo in HDFS to plug the hole.",
        getTableInfo(), hi);
  }
 
  @Override
  public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
    errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
        "Last region should end with an empty key. You need to "
            + "create a new region and regioninfo in HDFS to plug the hole.", getTableInfo());
  }
 
  @Override
  public void handleDegenerateRegion(HbckInfo hi) throws IOException{
    errors.reportError(ERROR_CODE.DEGENERATE_REGION,
        "Region has the same start and end key.", getTableInfo(), hi);
  }
 
  @Override
  public void handleDuplicateStartKeys(HbckInfo r1, HbckInfo r2) throws IOException{
    byte[] key = r1.getStartKey();
    // dup start key
    errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
        "Multiple regions have the same startkey: "
        + Bytes.toStringBinary(key), getTableInfo(), r1);
    errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
        "Multiple regions have the same startkey: "
        + Bytes.toStringBinary(key), getTableInfo(), r2);
  }
 
  @Override
  public void handleSplit(HbckInfo r1, HbckInfo r2) throws IOException{
    byte[] key = r1.getStartKey();
    // dup start key
    errors.reportError(ERROR_CODE.DUPE_ENDKEYS,
      "Multiple regions have the same regionID: "
        + Bytes.toStringBinary(key), getTableInfo(), r1);
    errors.reportError(ERROR_CODE.DUPE_ENDKEYS,
      "Multiple regions have the same regionID: "
        + Bytes.toStringBinary(key), getTableInfo(), r2);
  }
 
  @Override
  public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2) throws IOException{
    errors.reportError(ERROR_CODE.OVERLAP_IN_REGION_CHAIN,
        "There is an overlap in the region chain.",
        getTableInfo(), hi1, hi2);
  }
 
  @Override
  public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop) throws IOException{
    errors.reportError(
        ERROR_CODE.HOLE_IN_REGION_CHAIN,
        "There is a hole in the region chain between "
            + Bytes.toStringBinary(holeStart) + " and "
            + Bytes.toStringBinary(holeStop)
            + ".  You need to create a new .regioninfo and region "
            + "dir in hdfs to plug the hole.");
  }
};
2.2检查条件
     之前说过表的完整性检查主要是检查表的hole、overlap和orphan等情况,检查条件是判断上述异常的依据,在源码中的判断依据是什么,这里根据不同的情况,描述不同的检查条件,详见各个章节。

   hole
  orphan
  overlap
  others
————————————————
版权声明:本文为CSDN博主「shfshihuafeng」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shfshihuafeng/article/details/90704629

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值