You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2020/03/04 16:28:41 UTC

[hbase-operator-tools] branch master updated: HBASE-23791 [operator tools] Remove reference to I.A. Private interfa… (#53)

This is an automated email from the ASF dual-hosted git repository.

wchevreuil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git


The following commit(s) were added to refs/heads/master by this push:
     new 4764829  HBASE-23791 [operator tools] Remove reference to I.A. Private interfa… (#53)
4764829 is described below

commit 4764829afe8a2fd1e504de48fb8a9907cac3581e
Author: Wellington Ramos Chevreuil <wc...@apache.org>
AuthorDate: Wed Mar 4 16:28:25 2020 +0000

    HBASE-23791 [operator tools] Remove reference to I.A. Private interfa… (#53)
    
    Signed-off-by: Josh Elser <el...@apache.org>
---
 .../org/apache/hbase/FsRegionsMetaRecoverer.java   |  28 +-
 .../main/java/org/apache/hbase/HBCKActions.java    |   7 +-
 .../org/apache/hbase/HBCKMetaTableAccessor.java    | 591 ++++++++++++++++++++-
 .../java/org/apache/hbase/hbck1/HBaseFsck.java     |  68 +--
 .../org/apache/hbase/hbck1/HBaseFsckRepair.java    |   5 +-
 .../src/test/java/org/apache/hbase/TestHBCK2.java  |  29 +-
 6 files changed, 659 insertions(+), 69 deletions(-)

diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
index e3cd643..b6cb28b 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Connection;
@@ -112,7 +111,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
 
   void putRegionInfoFromHdfsInMeta(Path region) throws IOException {
     RegionInfo info = HRegionFileSystem.loadRegionInfoFileContent(fs, region);
-    MetaTableAccessor.addRegionToMeta(conn, info);
+    HBCKMetaTableAccessor.addRegionToMeta(conn, info);
   }
 
   List<String> addMissingRegionsInMeta(List<Path> regionsPath) throws IOException {
@@ -135,15 +134,20 @@ public class FsRegionsMetaRecoverer implements Closeable {
     List<String> nameSpaceOrTable) throws IOException {
     if(nameSpaceOrTable.size()>0) {
       InternalMetaChecker<RegionInfo> extraChecker = new InternalMetaChecker<>();
-      return extraChecker.processRegionsMetaCleanup(this::reportTablesExtraRegions, regions -> {
-        MetaTableAccessor.deleteRegionInfos(conn, regions);
-        return regions.stream().map(r -> r.getEncodedName()).collect(Collectors.toList());
-      }, nameSpaceOrTable);
-    } else {
-      return null;
+      return extraChecker.processRegionsMetaCleanup(this::reportTablesExtraRegions,
+        this::deleteAllRegions, nameSpaceOrTable);
     }
+    return null;
   }
 
+  private List<String> deleteAllRegions(List<RegionInfo> regions) throws IOException {
+    List<String> resulting = new ArrayList<>();
+    for(RegionInfo r : regions){
+      HBCKMetaTableAccessor.deleteRegionInfo(conn, r);
+      resulting.add(r.getEncodedName());
+    }
+    return resulting;
+  }
 
   @Override
   public void close() throws IOException {
@@ -156,16 +160,16 @@ public class FsRegionsMetaRecoverer implements Closeable {
         CheckingFunction<List<RegionInfo>, List<Path>, T> checkingFunction) throws IOException {
       final List<Path> regionsDirs = getTableRegionsDirs(table);
       TableName tableName = TableName.valueOf(table);
-      List<RegionInfo> regions = MetaTableAccessor.
-        getTableRegions(FsRegionsMetaRecoverer.this.conn, tableName, false);
+      List<RegionInfo> regions = HBCKMetaTableAccessor.
+        getTableRegions(FsRegionsMetaRecoverer.this.conn, tableName);
       return checkingFunction.check(regions, regionsDirs);
     }
 
     Map<TableName,List<T>> reportTablesRegions(final List<String> namespacesOrTables,
       ExecFunction<List<T>, String> checkingFunction) throws IOException {
       final Map<TableName,List<T>> result = new HashMap<>();
-      List<TableName> tableNames = MetaTableAccessor.
-        getTableStates(FsRegionsMetaRecoverer.this.conn).keySet().stream()
+      List<TableName> tableNames = HBCKMetaTableAccessor.
+        getTables(FsRegionsMetaRecoverer.this.conn).stream()
           .filter(tableName -> {
             if(namespacesOrTables==null || namespacesOrTables.isEmpty()){
               return true;
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
index 779e8a0..a1126b6 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKActions.java
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
@@ -84,12 +83,12 @@ public class HBCKActions {
     TableName tn = TableName.valueOf(tname);
     try (Connection connection = ConnectionFactory.createConnection(conf)) {
       Table metaTable = connection.getTable(TableName.valueOf("hbase:meta"));
-      List<RegionInfo> ris = MetaTableAccessor.getTableRegions(connection, tn);
+      List<RegionInfo> ris = HBCKMetaTableAccessor.getTableRegions(connection, tn);
       System.out.println(String.format("Current Regions of the table " + tn.getNameAsString()
           + " in Meta before deletion of the region are: " + ris));
       RegionInfo ri = ris.get(ris.size() / 2);
       System.out.println("Deleting Region " + ri.getRegionNameAsString());
-      byte[] key = MetaTableAccessor.getMetaKeyForRegion(ri);
+      byte[] key = HBCKMetaTableAccessor.getMetaKeyForRegion(ri);
 
       Delete delete = new Delete(key);
       delete.addFamily(Bytes.toBytes("info"));
@@ -97,7 +96,7 @@ public class HBCKActions {
 
       Thread.sleep(500);
 
-      ris = MetaTableAccessor.getTableRegions(connection, tn);
+      ris = HBCKMetaTableAccessor.getTableRegions(connection, tn);
       System.out.println("Current Regions of the table " + tn.getNameAsString()
           + " in Meta after deletion of the region are: " + ris);
     }
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
index 53e1964..efc1f4b 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
@@ -17,24 +17,61 @@
  */
 package org.apache.hbase;
 
+import static org.apache.hadoop.hbase.HConstants.CATALOG_FAMILY;
+import static org.apache.hadoop.hbase.HConstants.REGIONINFO_QUALIFIER;
+import static org.apache.hadoop.hbase.HConstants.TABLE_FAMILY;
+import static org.apache.hadoop.hbase.HConstants.TABLE_STATE_QUALIFIER;
+import static org.apache.hadoop.hbase.MetaTableAccessor.getMetaHTable;
+
+import edu.umd.cs.findbugs.annotations.Nullable;
+
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.SortedMap;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellBuilder;
+import org.apache.hadoop.hbase.CellBuilderFactory;
+import org.apache.hadoop.hbase.CellBuilderType;
 import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.RegionLocations;
+import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.RegionInfoBuilder;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.hadoop.hbase.client.RegionReplicaUtil;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableState;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.PairOfSameType;
 import org.apache.yetus.audience.InterfaceAudience;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
+
 /**
  * hbck's local version of the MetaTableAccessor from the hbase repo
  * A Utility class to facilitate hbck2's access to Meta table.
@@ -42,6 +79,13 @@ import org.slf4j.LoggerFactory;
 @InterfaceAudience.Private
 public final class HBCKMetaTableAccessor {
 
+  /** The delimiter for meta columns for replicaIds &gt; 0 */
+  static final char META_REPLICA_ID_DELIMITER = '_';
+
+  /** A regex for parsing server columns from meta. See above javadoc for meta layout */
+  private static final Pattern SERVER_COLUMN_PATTERN
+    = Pattern.compile("^server(_[0-9a-fA-F]{4})?$");
+
   /**
    * Private constructor to keep this class from being instantiated.
    */
@@ -138,4 +182,549 @@ public final class HBCKMetaTableAccessor {
       t.delete(deletes);
     }
   }
+
+  /**
+   * Returns all regions in meta for the given table.
+   * @param conn a valid, open connection.
+   * @param table the table to list regions in meta.
+   * @return a list of <code>RegionInfo</code> for all table regions present in meta.
+   * @throws IOException on any issues related with scanning meta table
+   */
+  public static List<RegionInfo> getTableRegions(final Connection conn, final TableName table)
+      throws IOException {
+    final MetaScanner<RegionInfo> scanner = new MetaScanner<>();
+    final String startRow = Bytes.toString(table.getName()) + ",,";
+    final String stopRow = Bytes.toString(table.getName()) + " ,,";
+    return scanner.scanMeta(conn,
+      scan -> {
+        scan.withStartRow(Bytes.toBytes(startRow));
+        scan.withStopRow(Bytes.toBytes(stopRow));
+      },
+      r -> {
+        Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, REGIONINFO_QUALIFIER);
+        if(cell != null) {
+          RegionInfo info = RegionInfo
+            .parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
+          return info;
+        }
+        return null;
+      });
+  }
+
+  /**
+   * Returns a list of all tables having related entries on meta.
+   * @param conn a valid, open connection.
+   * @return a list of <code>TableName</code> for each table having at least one entry in meta.
+   * @throws IOException on any issues related with scanning meta table
+   */
+  public static List<TableName> getTables(final Connection conn) throws IOException {
+    MetaScanner<TableName> scanner = new MetaScanner<>();
+    return scanner.scanMeta(conn,
+      scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER),
+      r -> {
+        final byte[] rowBytes = r.getRow();
+        String table = Bytes.toString(rowBytes);
+        if(table.lastIndexOf(HConstants.DELIMITER)>0) {
+          table = table.substring(0, table.lastIndexOf(HConstants.DELIMITER));
+        }
+        return TableName.valueOf(table);
+      });
+  }
+
+  /**
+   * Converts and adds the passed <code>RegionInfo</code> parameter into a valid 'info:regioninfo'
+   * cell value in 'hbase:meta'.
+   * @param conn a valid, open connection.
+   * @param region the region to be inserted in meta.
+   * @throws IOException on any issues related with scanning meta table
+   */
+  public static void addRegionToMeta(Connection conn, RegionInfo region) throws IOException {
+    conn.getTable(TableName.META_TABLE_NAME).put(makePutFromRegionInfo(region,
+      System.currentTimeMillis()));
+  }
+
+  /**
+   * List all valid regions currently in META, excluding parent whoese been completely split.
+   * @param conn a valid, open connection.
+   * @return a list of all regions in META, excluding split parents.
+   * @throws IOException on any issues related with scanning meta table
+   */
+  public static List<RegionInfo> getAllRegions(Connection conn) throws IOException {
+    MetaScanner<RegionInfo> scanner = new MetaScanner<>();
+    return scanner.scanMeta(conn,
+      scan -> scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER),
+      r -> {
+        Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY,
+          HConstants.REGIONINFO_QUALIFIER);
+        RegionInfo info = RegionInfo.parseFromOrNull(cell.getValueArray(),
+          cell.getValueOffset(), cell.getValueLength());
+        return info.isSplit() ? null : info;
+      });
+  }
+
+  /**
+   * Scans all "table:state" cell values existing in meta and returns as a map of
+   * <code>TableName</code> as key and <code>TableState</code> as the value.
+   * @param conn a valid, open connection.
+   * @return a Map of <code>TableName</code> as key and <code>TableState</code> as the value.
+   * @throws IOException on any issues related with scanning meta table
+   */
+  public static Map<TableName, TableState> getAllTablesStates(Connection conn) throws IOException {
+    final MetaScanner<Pair<TableName, TableState>> scanner = new MetaScanner<>();
+    final Map<TableName, TableState> resultMap = new HashMap<>();
+    scanner.scanMeta(conn,
+      scan -> scan.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER),
+      r -> {
+        try {
+          TableState state = getTableState(r);
+          TableName name = TableName.valueOf(r.getRow());
+          resultMap.put(name, state);
+        } catch (IOException e) {
+          LOG.error(e.getMessage());
+        }
+        return null;
+      });
+    return resultMap;
+  }
+
+
+  /**
+   * (Copied partially from MetaTableAccessor)
+   * @param tableName table we're working with
+   * @return start row for scanning META according to query type
+   */
+  public static byte[] getTableStartRowForMeta(TableName tableName) {
+    if (tableName == null) {
+      return null;
+    }
+    byte[] startRow = new byte[tableName.getName().length + 2];
+    System.arraycopy(tableName.getName(), 0, startRow, 0,
+      tableName.getName().length);
+    startRow[startRow.length - 2] = HConstants.DELIMITER;
+    startRow[startRow.length - 1] = HConstants.DELIMITER;
+    return startRow;
+  }
+
+  /**
+   * @param tableName table we're working with
+   * @return stop row for scanning META according to query type
+   */
+  public static byte[] getTableStopRowForMeta(TableName tableName) {
+    if (tableName == null) {
+      return null;
+    }
+    final byte[] stopRow;
+    stopRow = new byte[tableName.getName().length + 3];
+    System.arraycopy(tableName.getName(), 0, stopRow, 0,
+      tableName.getName().length);
+    stopRow[stopRow.length - 3] = ' ';
+    stopRow[stopRow.length - 2] = HConstants.DELIMITER;
+    stopRow[stopRow.length - 1] = HConstants.DELIMITER;
+    return stopRow;
+  }
+
+  /** Returns the row key to use for this regionInfo */
+  public static byte[] getMetaKeyForRegion(RegionInfo regionInfo) {
+    if (regionInfo.isMetaRegion()) {
+      return RegionInfoBuilder.newBuilder(regionInfo.getTable())
+        .setRegionId(regionInfo.getRegionId())
+        .setReplicaId(0)
+        .setOffline(regionInfo.isOffline())
+        .build().getRegionName();
+    } else {
+      return RegionInfoBuilder.newBuilder(regionInfo.getTable())
+        .setStartKey(regionInfo.getStartKey())
+        .setEndKey(regionInfo.getEndKey())
+        .setSplit(regionInfo.isSplit())
+        .setRegionId(regionInfo.getRegionId())
+        .setReplicaId(0)
+        .setOffline(regionInfo.isOffline())
+        .build().getRegionName();
+    }
+  }
+
+  public static Put addLocation(Put p, ServerName sn, long openSeqNum, int replicaId)
+    throws IOException {
+    CellBuilder builder = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY);
+    return p.add(builder.clear()
+      .setRow(p.getRow())
+      .setFamily(CATALOG_FAMILY)
+      .setQualifier(getServerColumn(replicaId))
+      .setTimestamp(p.getTimestamp())
+      .setType(Cell.Type.Put)
+      .setValue(Bytes.toBytes(sn.getAddress().toString()))
+      .build())
+      .add(builder.clear()
+        .setRow(p.getRow())
+        .setFamily(CATALOG_FAMILY)
+        .setQualifier(getStartCodeColumn(replicaId))
+        .setTimestamp(p.getTimestamp())
+        .setType(Cell.Type.Put)
+        .setValue(Bytes.toBytes(sn.getStartcode()))
+        .build())
+      .add(builder.clear()
+        .setRow(p.getRow())
+        .setFamily(CATALOG_FAMILY)
+        .setQualifier(getSeqNumColumn(replicaId))
+        .setTimestamp(p.getTimestamp())
+        .setType(Cell.Type.Put)
+        .setValue(Bytes.toBytes(openSeqNum))
+        .build());
+  }
+
+  /**
+   * Count regions in <code>hbase:meta</code> for passed table.
+   * @param connection Connection object
+   * @param tableName table name to count regions for
+   * @return Count or regions in table <code>tableName</code>
+   */
+  public static int getRegionCount(final Connection connection, final TableName tableName)
+    throws IOException {
+    try (RegionLocator locator = connection.getRegionLocator(tableName)) {
+      List<HRegionLocation> locations = locator.getAllRegionLocations();
+      return locations == null ? 0 : locations.size();
+    }
+  }
+
+  /**
+   * Decode table state from META Result.
+   * Should contain cell from HConstants.TABLE_FAMILY
+   * (Copied from MetaTableAccessor)
+   * @return null if not found
+   */
+  @Nullable
+  public static TableState getTableState(Result r) throws IOException {
+    Cell cell = r.getColumnLatestCell(TABLE_FAMILY, TABLE_STATE_QUALIFIER);
+    if (cell == null) {
+      return null;
+    }
+    try {
+      return TableState.parseFrom(TableName.valueOf(r.getRow()),
+        Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(),
+          cell.getValueOffset() + cell.getValueLength()));
+    } catch (DeserializationException e) {
+      throw new IOException(e);
+    }
+  }
+
+  /**
+   * Fetch table state for given table from META table
+   * @param conn connection to use
+   * @param tableName table to fetch state for
+   */
+  @Nullable
+  public static TableState getTableState(Connection conn, TableName tableName)
+    throws IOException {
+    if (tableName.equals(TableName.META_TABLE_NAME)) {
+      return new TableState(tableName, TableState.State.ENABLED);
+    }
+    Table metaHTable = getMetaHTable(conn);
+    Get get = new Get(tableName.getName()).addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER);
+    Result result = metaHTable.get(get);
+    return getTableState(result);
+  }
+
+  /**
+   * Construct PUT for given state
+   * @param state new state
+   */
+  public static Put makePutFromTableState(TableState state, long ts) {
+    Put put = new Put(state.getTableName().getName(), ts);
+    put.addColumn(TABLE_FAMILY, TABLE_STATE_QUALIFIER,
+      state.convert().toByteArray());
+    return put;
+  }
+
+  /**
+   * Generates and returns a Put containing the region into for the catalog table
+   */
+  public static Put makePutFromRegionInfo(RegionInfo region, long ts) throws IOException {
+    Put put = new Put(region.getRegionName(), ts);
+    //copied from MetaTableAccessor
+    put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
+      .setRow(put.getRow())
+      .setFamily(HConstants.CATALOG_FAMILY)
+      .setQualifier(HConstants.REGIONINFO_QUALIFIER)
+      .setTimestamp(put.getTimestamp())
+      .setType(Cell.Type.Put)
+      // Serialize the Default Replica HRI otherwise scan of hbase:meta
+      // shows an info:regioninfo value with encoded name and region
+      // name that differs from that of the hbase;meta row.
+      .setValue(RegionInfo.toByteArray(RegionReplicaUtil.getRegionInfoForDefaultReplica(region)))
+      .build());
+    return put;
+  }
+
+  /**
+   * Remove state for table from meta
+   * (Copied from MetaTableAccessor)
+   * @param connection to use for deletion
+   * @param table to delete state for
+   */
+  public static void deleteTableState(Connection connection, TableName table)
+    throws IOException {
+    long time = EnvironmentEdgeManager.currentTime();
+    Delete delete = new Delete(table.getName());
+    delete.addColumns(TABLE_FAMILY, HConstants.TABLE_STATE_QUALIFIER, time);
+    deleteFromMetaTable(connection, delete);
+    LOG.info("Deleted table " + table + " state from META");
+  }
+
+  /**
+   * Updates state in META
+   * @param conn connection to use
+   * @param tableName table to look for
+   */
+  public static void updateTableState(Connection conn, TableName tableName,
+    TableState.State actual) throws IOException {
+    Put put = makePutFromTableState(new TableState(tableName, actual),
+      EnvironmentEdgeManager.currentTime());
+    conn.getTable(TableName.META_TABLE_NAME).put(put);
+  }
+
+  /**
+   * Returns the RegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and
+   * <code>qualifier</code> of the catalog table result.
+   * (Copied from MetaTableAccessor)
+   * @param r a Result object from the catalog table scan
+   * @param qualifier Column family qualifier
+   * @return An RegionInfo instance or null.
+   */
+  @Nullable
+  public static RegionInfo getRegionInfo(final Result r, byte [] qualifier) {
+    Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, qualifier);
+    if (cell == null) {
+      return null;
+    }
+    return RegionInfo.parseFromOrNull(cell.getValueArray(),
+      cell.getValueOffset(), cell.getValueLength());
+  }
+
+  /**
+   * Returns the HRegionLocation parsed from the given meta row Result
+   * for the given regionInfo and replicaId. The regionInfo can be the default region info
+   * for the replica.
+   * (Copied from MetaTableAccessor)
+   * @param r the meta row result
+   * @param regionInfo RegionInfo for default replica
+   * @param replicaId the replicaId for the HRegionLocation
+   * @return HRegionLocation parsed from the given meta row Result for the given replicaId
+   */
+  private static HRegionLocation getRegionLocation(final Result r, final RegionInfo regionInfo,
+    final int replicaId) {
+    ServerName serverName = getServerName(r, replicaId);
+    long seqNum = getSeqNumDuringOpen(r, replicaId);
+    RegionInfo replicaInfo = RegionReplicaUtil.getRegionInfoForReplica(regionInfo, replicaId);
+    return new HRegionLocation(replicaInfo, serverName, seqNum);
+  }
+
+  /**
+   * The latest seqnum that the server writing to meta observed when opening the region.
+   * E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.
+   * (Copied from MetaTableAccessor)
+   * @param r Result to pull the seqNum from
+   * @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.
+   */
+  private static long getSeqNumDuringOpen(final Result r, final int replicaId) {
+    Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, getSeqNumColumn(replicaId));
+    if (cell == null || cell.getValueLength() == 0) {
+      return HConstants.NO_SEQNUM;
+    }
+    return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
+  }
+
+  /**
+   * Returns a {@link ServerName} from catalog table {@link Result}.
+   * (Copied from MetaTableAccessor)
+   * @param r Result to pull from
+   * @return A ServerName instance or null if necessary fields not found or empty.
+   */
+  @Nullable
+  @InterfaceAudience.Private // for use by HMaster#getTableRegionRow which is used for testing only
+  public static ServerName getServerName(final Result r, final int replicaId) {
+    byte[] serverColumn = getServerColumn(replicaId);
+    Cell cell = r.getColumnLatestCell(CATALOG_FAMILY, serverColumn);
+    if (cell == null || cell.getValueLength() == 0) {
+      return null;
+    }
+    String hostAndPort = Bytes.toString(
+      cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
+    byte[] startcodeColumn = getStartCodeColumn(replicaId);
+    cell = r.getColumnLatestCell(CATALOG_FAMILY, startcodeColumn);
+    if (cell == null || cell.getValueLength() == 0) {
+      return null;
+    }
+    try {
+      return ServerName.valueOf(hostAndPort,
+        Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
+    } catch (IllegalArgumentException e) {
+      LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e);
+      return null;
+    }
+  }
+
+  /**
+   * Returns an HRegionLocationList extracted from the result.
+   * (Copied from MetaTableAccessor)
+   * @return an HRegionLocationList containing all locations for the region range or null if
+   *   we can't deserialize the result.
+   */
+  @Nullable
+  public static RegionLocations getRegionLocations(final Result r) {
+    if (r == null) {
+      return null;
+    }
+    RegionInfo regionInfo = getRegionInfo(r, REGIONINFO_QUALIFIER);
+    if (regionInfo == null) {
+      return null;
+    }
+
+    List<HRegionLocation> locations = new ArrayList<>(1);
+    NavigableMap<byte[], NavigableMap<byte[],byte[]>> familyMap = r.getNoVersionMap();
+
+    locations.add(getRegionLocation(r, regionInfo, 0));
+
+    NavigableMap<byte[], byte[]> infoMap = familyMap.get(CATALOG_FAMILY);
+    if (infoMap == null) {
+      return new RegionLocations(locations);
+    }
+
+    // iterate until all serverName columns are seen
+    int replicaId = 0;
+    byte[] serverColumn = getServerColumn(replicaId);
+    SortedMap<byte[], byte[]> serverMap;
+    serverMap = infoMap.tailMap(serverColumn, false);
+
+    if (serverMap.isEmpty()) {
+      return new RegionLocations(locations);
+    }
+
+    for (Map.Entry<byte[], byte[]> entry : serverMap.entrySet()) {
+      replicaId = parseReplicaIdFromServerColumn(entry.getKey());
+      if (replicaId < 0) {
+        break;
+      }
+      HRegionLocation location = getRegionLocation(r, regionInfo, replicaId);
+      // In case the region replica is newly created, it's location might be null. We usually do not
+      // have HRL's in RegionLocations object with null ServerName. They are handled as null HRLs.
+      if (location.getServerName() == null) {
+        locations.add(null);
+      } else {
+        locations.add(location);
+      }
+    }
+
+    return new RegionLocations(locations);
+  }
+
+  /**
+   * Returns the daughter regions by reading the corresponding columns of the catalog table
+   * Result.
+   * (Copied from MetaTableAccessor)
+   * @param data a Result object from the catalog table scan
+   * @return pair of RegionInfo or PairOfSameType(null, null) if region is not a split parent
+   */
+  public static PairOfSameType<RegionInfo> getDaughterRegions(Result data) {
+    RegionInfo splitA = getRegionInfo(data, HConstants.SPLITA_QUALIFIER);
+    RegionInfo splitB = getRegionInfo(data, HConstants.SPLITB_QUALIFIER);
+    return new PairOfSameType<>(splitA, splitB);
+  }
+
+  /**
+   * Returns the column qualifier for serialized region state
+   * (Copied from MetaTableAccessor)
+   * @param replicaId the replicaId of the region
+   * @return a byte[] for sn column qualifier
+   */
+  @VisibleForTesting
+  static byte[] getServerNameColumn(int replicaId) {
+    return replicaId == 0 ? HConstants.SERVERNAME_QUALIFIER
+      : Bytes.toBytes(HConstants.SERVERNAME_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
+      + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+  }
+
+  /**
+   * Returns the column qualifier for server column for replicaId
+   * (Copied from MetaTableAccessor)
+   * @param replicaId the replicaId of the region
+   * @return a byte[] for server column qualifier
+   */
+  @VisibleForTesting
+  public static byte[] getServerColumn(int replicaId) {
+    return replicaId == 0
+      ? HConstants.SERVER_QUALIFIER
+      : Bytes.toBytes(HConstants.SERVER_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
+      + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+  }
+
+  /**
+   * Returns the column qualifier for server start code column for replicaId
+   * (Copied from MetaTableAccessor)
+   * @param replicaId the replicaId of the region
+   * @return a byte[] for server start code column qualifier
+   */
+  @VisibleForTesting
+  public static byte[] getStartCodeColumn(int replicaId) {
+    return replicaId == 0
+      ? HConstants.STARTCODE_QUALIFIER
+      : Bytes.toBytes(HConstants.STARTCODE_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
+      + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+  }
+
+  /**
+   * Returns the column qualifier for seqNum column for replicaId
+   * (Copied from MetaTableAccessor)
+   * @param replicaId the replicaId of the region
+   * @return a byte[] for seqNum column qualifier
+   */
+  @VisibleForTesting
+  public static byte[] getSeqNumColumn(int replicaId) {
+    return replicaId == 0
+      ? HConstants.SEQNUM_QUALIFIER
+      : Bytes.toBytes(HConstants.SEQNUM_QUALIFIER_STR + META_REPLICA_ID_DELIMITER
+      + String.format(RegionInfo.REPLICA_ID_FORMAT, replicaId));
+  }
+
+  /**
+   * Parses the replicaId from the server column qualifier. See top of the class javadoc
+   * for the actual meta layout
+   * (Copied from MetaTableAccessor)
+   * @param serverColumn the column qualifier
+   * @return an int for the replicaId
+   */
+  @VisibleForTesting
+  static int parseReplicaIdFromServerColumn(byte[] serverColumn) {
+    String serverStr = Bytes.toString(serverColumn);
+
+    Matcher matcher = SERVER_COLUMN_PATTERN.matcher(serverStr);
+    if (matcher.matches() && matcher.groupCount() > 0) {
+      String group = matcher.group(1);
+      if (group != null && group.length() > 0) {
+        return Integer.parseInt(group.substring(1), 16);
+      } else {
+        return 0;
+      }
+    }
+    return -1;
+  }
+
+  public static class MetaScanner<R> {
+
+    public List<R> scanMeta(final Connection conn, Consumer<Scan> scanDecorator,
+        Function<Result, R> scanProcessor) throws IOException {
+      final Scan metaScan = new Scan();
+      scanDecorator.accept(metaScan);
+      final Table metaTable = conn.getTable(TableName.META_TABLE_NAME);
+      final ResultScanner rs = metaTable.getScanner(metaScan);
+      final List<R> results = new ArrayList<>();
+      Result result;
+      while((result = rs.next())!=null){
+        R processedResult = scanProcessor.apply(result);
+        if(processedResult != null) {
+          results.add(processedResult);
+        }
+      }
+      return results;
+    }
+  }
 }
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
index 7cb6c7a..dcf88bb 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
@@ -59,6 +59,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
@@ -85,7 +86,6 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
@@ -940,7 +940,7 @@ public class HBaseFsck extends Configured implements Closeable {
   public void checkRegionBoundaries() {
     try {
       ByteArrayComparator comparator = new ByteArrayComparator();
-      List<RegionInfo> regions = MetaTableAccessor.getAllRegions(connection, true);
+      List<RegionInfo> regions = HBCKMetaTableAccessor.getAllRegions(connection);
       final RegionBoundariesInformation currentRegionBoundariesInformation =
           new RegionBoundariesInformation();
       Path hbaseRoot = FSUtils.getRootDir(getConf());
@@ -1777,7 +1777,7 @@ public class HBaseFsck extends Configured implements Closeable {
       TableName ns = TableDescriptorBuilder.NAMESPACE_TABLEDESC.getTableName();
       TableState.State state = ti.getName().equals(ns)?
           TableState.State.ENABLED: TableState.State.DISABLED;
-      puts.add(MetaTableAccessor.makePutFromTableState(
+      puts.add(HBCKMetaTableAccessor.makePutFromTableState(
         new TableState(ti.tableName, state), System.currentTimeMillis()));
       for (Entry<byte[], Collection<HbckInfo>> spl : ti.regionSplitCalculator.getStarts().asMap()
           .entrySet()) {
@@ -1794,7 +1794,7 @@ public class HBaseFsck extends Configured implements Closeable {
         // add the row directly to meta.
         HbckInfo hi = his.iterator().next();
         RegionInfo hri = hi.getHdfsHRI(); // hi.metaEntry;
-        Put p = MetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
+        Put p = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
         addRegionStateToPut(p, org.apache.hadoop.hbase.master.RegionState.State.CLOSED);
         addEmptyLocation(p, 0);
         puts.add(p);
@@ -1811,21 +1811,21 @@ public class HBaseFsck extends Configured implements Closeable {
     return p.add(builder.clear()
         .setRow(p.getRow())
         .setFamily(getCatalogFamily())
-        .setQualifier(MetaTableAccessor.getServerColumn(replicaId))
+        .setQualifier(HBCKMetaTableAccessor.getServerColumn(replicaId))
         .setTimestamp(p.getTimestamp())
         .setType(Cell.Type.Put)
         .build())
         .add(builder.clear()
             .setRow(p.getRow())
             .setFamily(getCatalogFamily())
-            .setQualifier(MetaTableAccessor.getStartCodeColumn(replicaId))
+            .setQualifier(HBCKMetaTableAccessor.getStartCodeColumn(replicaId))
             .setTimestamp(p.getTimestamp())
             .setType(Cell.Type.Put)
             .build())
         .add(builder.clear()
             .setRow(p.getRow())
             .setFamily(getCatalogFamily())
-            .setQualifier(MetaTableAccessor.getSeqNumColumn(replicaId))
+            .setQualifier(HBCKMetaTableAccessor.getSeqNumColumn(replicaId))
             .setTimestamp(p.getTimestamp())
             .setType(Cell.Type.Put)
             .build());
@@ -2115,7 +2115,7 @@ public class HBaseFsck extends Configured implements Closeable {
    * Load the list of disabled tables in ZK into local set.
    */
   private void loadTableStates() throws IOException {
-    tableStates = MetaTableAccessor.getTableStates(connection);
+    tableStates = HBCKMetaTableAccessor.getAllTablesStates(connection);
     // Add hbase:meta so this tool keeps working. In hbase2, meta is always enabled though it
     // has no entry in the table states. HBCK doesn't work right w/ hbase2 but just do this in
     // meantime.
@@ -2418,8 +2418,8 @@ public class HBaseFsck extends Configured implements Closeable {
           && !tableName.isSystemTable()
           && tableInfo == null) {
         if (fixMeta) {
-          MetaTableAccessor.deleteTableState(connection, tableName);
-          TableState state = MetaTableAccessor.getTableState(connection, tableName);
+          HBCKMetaTableAccessor.deleteTableState(connection, tableName);
+          TableState state = HBCKMetaTableAccessor.getTableState(connection, tableName);
           if (state != null) {
             errors.reportError(ErrorReporter.ERROR_CODE.ORPHAN_TABLE_STATE,
                 tableName + " unable to delete dangling table state " + tableState);
@@ -2436,8 +2436,8 @@ public class HBaseFsck extends Configured implements Closeable {
     for (TableName tableName : tablesInfo.keySet()) {
       if (isTableIncluded(tableName) && !tableStates.containsKey(tableName)) {
         if (fixMeta) {
-          MetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);
-          TableState newState = MetaTableAccessor.getTableState(connection, tableName);
+          HBCKMetaTableAccessor.updateTableState(connection, tableName, TableState.State.ENABLED);
+          TableState newState = HBCKMetaTableAccessor.getTableState(connection, tableName);
           if (newState == null) {
             errors.reportError(ErrorReporter.ERROR_CODE.NO_TABLE_STATE,
                 "Unable to change state for table " + tableName + " in meta ");
@@ -2503,7 +2503,7 @@ public class HBaseFsck extends Configured implements Closeable {
         .setOffline(false)
         .setSplit(false)
         .build();
-    Put p = MetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
+    Put p = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
     mutations.add(p);
 
     meta.mutateRow(mutations);
@@ -2610,12 +2610,12 @@ public class HBaseFsck extends Configured implements Closeable {
     if (hi.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {
       int numReplicas = admin.getDescriptor(hi.getTableName()).getRegionReplication();
       for (int i = 0; i < numReplicas; i++) {
-        get.addColumn(HConstants.CATALOG_FAMILY, MetaTableAccessor.getServerColumn(i));
-        get.addColumn(HConstants.CATALOG_FAMILY, MetaTableAccessor.getStartCodeColumn(i));
+        get.addColumn(HConstants.CATALOG_FAMILY, HBCKMetaTableAccessor.getServerColumn(i));
+        get.addColumn(HConstants.CATALOG_FAMILY, HBCKMetaTableAccessor.getStartCodeColumn(i));
       }
     }
     Result r = meta.get(get);
-    RegionLocations rl = MetaTableAccessor.getRegionLocations(r);
+    RegionLocations rl = HBCKMetaTableAccessor.getRegionLocations(r);
     if (rl == null) {
       LOG.warn("Unable to close region " + hi.getRegionNameAsString() +
           " since meta does not have handle to reach it");
@@ -4025,9 +4025,9 @@ public class HBaseFsck extends Configured implements Closeable {
    * @throws IOException if an error is encountered
    */
   boolean loadMetaEntries() throws IOException {
-    MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {
+    List<RegionInfo> result = null;
+    Function<Result, RegionInfo> visitor = new Function<Result, RegionInfo>() {
       int countRecord = 1;
-
       // comparator to sort KeyValues with latest modtime
       final Comparator<Cell> comp = new Comparator<Cell>() {
         @Override
@@ -4035,19 +4035,17 @@ public class HBaseFsck extends Configured implements Closeable {
           return Long.compare(k1.getTimestamp(), k2.getTimestamp());
         }
       };
-
       @Override
-      public boolean visit(Result result) throws IOException {
+      public RegionInfo apply(Result result) {
         try {
-
           // record the latest modification of this META record
           long ts =  Collections.max(result.listCells(), comp).getTimestamp();
-          RegionLocations rl = MetaTableAccessor.getRegionLocations(result);
+          RegionLocations rl = HBCKMetaTableAccessor.getRegionLocations(result);
           if (rl == null) {
             emptyRegionInfoQualifiers.add(result);
             errors.reportError(ErrorReporter.ERROR_CODE.EMPTY_META_CELL,
               "Empty REGIONINFO_QUALIFIER found in hbase:meta");
-            return true;
+            return null;
           }
           ServerName sn = null;
           if (rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID) == null ||
@@ -4055,14 +4053,14 @@ public class HBaseFsck extends Configured implements Closeable {
             emptyRegionInfoQualifiers.add(result);
             errors.reportError(ErrorReporter.ERROR_CODE.EMPTY_META_CELL,
               "Empty REGIONINFO_QUALIFIER found in hbase:meta");
-            return true;
+            return null;
           }
           RegionInfo hri = rl.getRegionLocation(RegionInfo.DEFAULT_REPLICA_ID).getRegion();
           if (!(isTableIncluded(hri.getTable())
               || hri.isMetaRegion())) {
-            return true;
+            return hri;
           }
-          PairOfSameType<RegionInfo> daughters = MetaTableAccessor.getDaughterRegions(result);
+          PairOfSameType<RegionInfo> daughters = HBCKMetaTableAccessor.getDaughterRegions(result);
           for (HRegionLocation h : rl.getRegionLocations()) {
             if (h == null || h.getRegion() == null) {
               continue;
@@ -4082,7 +4080,7 @@ public class HBaseFsck extends Configured implements Closeable {
             } else if (previous.metaEntry == null) {
               previous.metaEntry = m;
             } else {
-              throw new IOException("Two entries in hbase:meta are same " + previous);
+              LOG.error("Two entries in hbase:meta are same " + previous);
             }
           }
           List<RegionInfo> mergeParents = HBCKMetaTableAccessor.getMergeRegions(result.rawCells());
@@ -4101,7 +4099,7 @@ public class HBaseFsck extends Configured implements Closeable {
             errors.progress();
           }
           countRecord++;
-          return true;
+          return hri;
         } catch (RuntimeException e) {
           LOG.error("Result=" + result);
           throw e;
@@ -4110,10 +4108,14 @@ public class HBaseFsck extends Configured implements Closeable {
     };
     if (!checkMetaOnly) {
       // Scan hbase:meta to pick up user regions
-      MetaTableAccessor.fullScanRegions(connection, visitor);
+      final HBCKMetaTableAccessor.MetaScanner<RegionInfo> scanner =
+        new HBCKMetaTableAccessor.MetaScanner<>();
+      result = scanner.scanMeta(connection,
+        scan -> {},
+        visitor);
     }
 
-    return true;
+    return !result.isEmpty();
   }
 
   /**
@@ -5526,10 +5528,8 @@ public class HBaseFsck extends Configured implements Closeable {
     barrierScan.setCaching(100);
     barrierScan.addFamily(HConstants.REPLICATION_BARRIER_FAMILY);
     barrierScan
-        .withStartRow(MetaTableAccessor.getTableStartRowForMeta(cleanReplicationBarrierTable,
-          MetaTableAccessor.QueryType.REGION))
-        .withStopRow(MetaTableAccessor.getTableStopRowForMeta(cleanReplicationBarrierTable,
-          MetaTableAccessor.QueryType.REGION));
+        .withStartRow(HBCKMetaTableAccessor.getTableStartRowForMeta(cleanReplicationBarrierTable))
+        .withStopRow(HBCKMetaTableAccessor.getTableStopRowForMeta(cleanReplicationBarrierTable));
     Result result;
     try (ResultScanner scanner = meta.getScanner(barrierScan)) {
       while ((result = scanner.next()) != null) {
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
index ef47c55..e9207c9 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsckRepair.java
@@ -27,7 +27,6 @@ import java.util.Random;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.ClusterMetrics.Option;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
@@ -164,7 +163,7 @@ public final class HBaseFsckRepair {
       RegionInfo hri, Collection<ServerName> servers, int numReplicas) throws IOException {
     Connection conn = ConnectionFactory.createConnection(conf);
     Table meta = conn.getTable(TableName.META_TABLE_NAME);
-    Put put = MetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
+    Put put = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
     if (numReplicas > 1) {
       Random r = new Random();
       ServerName[] serversArr = servers.toArray(new ServerName[servers.size()]);
@@ -174,7 +173,7 @@ public final class HBaseFsckRepair {
         // see the additional replicas when it is asked to assign. The
         // final value of these columns will be different and will be updated
         // by the actual regionservers that start hosting the respective replicas
-        MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), i);
+        HBCKMetaTableAccessor.addLocation(put, sn, sn.getStartcode(), i);
       }
     }
     meta.put(put);
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
index a095040..dd08b0f 100644
--- a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java
@@ -35,7 +35,6 @@ import java.util.stream.Collectors;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.ClusterConnection;
@@ -230,7 +229,7 @@ public class TestHBCK2 {
 
   @Test
   public void testReportMissingRegionsInMetaSpecificTblAndNsTblAlsoMissing() throws Exception {
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), TableName.valueOf("hbase:namespace"));
     HBCKMetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), regions.get(0));
     this.testReportMissingRegionsInMeta(5, 6,
@@ -251,7 +250,7 @@ public class TestHBCK2 {
   @Test
   public void testFormatReportMissingInMetaOneMissing() throws IOException {
     TableName tableName = createTestTable(5);
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     HBCKMetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), regions.get(0));
     String expectedResult = "Missing Regions for each table:\n";
@@ -294,13 +293,13 @@ public class TestHBCK2 {
     throws Exception {
     TableName tableName = createTestTable(totalRegions);
     HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     Connection connection = TEST_UTIL.getConnection();
     regions.subList(0, missingRegions).forEach(r -> deleteRegionInfo(connection, r));
     int remaining = totalRegions - missingRegions;
     assertEquals("Table should have " + remaining + " regions in META.", remaining,
-      MetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
+      HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
     List<Future<List<String>>> result = hbck.addMissingRegionsInMetaForTables("default:" +
       tableName.getNameAsString());
 
@@ -314,16 +313,16 @@ public class TestHBCK2 {
     }).reduce(0, Integer::sum);
     assertEquals(missingRegions, total.intValue());
     assertEquals("Table regions should had been re-added in META.", totalRegions,
-      MetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
+      HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
     //compare the added regions to make sure those are the same
-    List<RegionInfo> newRegions = MetaTableAccessor
+    List<RegionInfo> newRegions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     assertEquals("All re-added regions should be the same", regions, newRegions);
   }
 
   private void testReportMissingRegionsInMeta(int missingRegionsInTestTbl,
       int expectedTotalMissingRegions, String... namespaceOrTable) throws Exception {
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
     Connection connection = TEST_UTIL.getConnection();
     regions.subList(0, missingRegionsInTestTbl).forEach(r -> deleteRegionInfo(connection, r));
@@ -410,7 +409,7 @@ public class TestHBCK2 {
   @Test
   public void testReportExtraRegionsInMetaSpecificTblAndNsTblAlsoExtra() throws Exception {
     TableName tableName = createTestTable(5);
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     deleteRegionDir(tableName, regions.get(0).getEncodedName());
     this.testReportExtraRegionsInMeta(5, 6,
@@ -432,7 +431,7 @@ public class TestHBCK2 {
   @Test
   public void testFormatReportExtraInMetaOneExtra() throws IOException {
     TableName tableName = createTestTable(5);
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     deleteRegionDir(tableName, regions.get(0).getEncodedName());
     String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
@@ -470,7 +469,7 @@ public class TestHBCK2 {
   @Test
   public void testFormatFixExtraInMetaOneExtra() throws IOException {
     TableName tableName = createTestTable(5);
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     deleteRegionDir(tableName, regions.get(0).getEncodedName());
     String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
@@ -489,7 +488,7 @@ public class TestHBCK2 {
   @Test
   public void testFormatFixExtraInMetaOneExtraSpecificTable() throws IOException {
     TableName tableName = createTestTable(5);
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     deleteRegionDir(tableName, regions.get(0).getEncodedName());
     String expectedResult = "Regions in Meta but having no equivalent dir, for each table:\n";
@@ -536,7 +535,7 @@ public class TestHBCK2 {
     throws Exception {
     TableName tableName = createTestTable(totalRegions);
     HBCK2 hbck = new HBCK2(TEST_UTIL.getConfiguration());
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), tableName);
     regions.subList(0, extraRegions).forEach(r -> deleteRegionDir(tableName, r.getEncodedName()));
     int remaining = totalRegions - extraRegions;
@@ -545,12 +544,12 @@ public class TestHBCK2 {
         "default:" + tableName.getNameAsString()
       }).get(tableName).size());
     assertEquals("Table regions should had been removed from META.", remaining,
-      MetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
+      HBCKMetaTableAccessor.getRegionCount(TEST_UTIL.getConnection(), tableName));
   }
 
   private void testReportExtraRegionsInMeta(int extraRegionsInTestTbl,
     int expectedTotalExtraRegions, String... namespaceOrTable) throws Exception {
-    List<RegionInfo> regions = MetaTableAccessor
+    List<RegionInfo> regions = HBCKMetaTableAccessor
       .getTableRegions(TEST_UTIL.getConnection(), TABLE_NAME);
     regions.subList(0, extraRegionsInTestTbl).forEach(r -> deleteRegionDir(TABLE_NAME,
       r.getEncodedName()));