jatsakthi commented on a change in pull request #14: HBASE-22843 [HBCK2] Fix HBCK2 after HBASE-22777 & HBASE-22758 URL: https://github.com/apache/hbase-operator-tools/pull/14#discussion_r314435416
########## File path: hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBCKMetaTableAccessor.java ########## @@ -0,0 +1,134 @@ +package org.apache.hbase.hbck1; + +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellUtil; +import org.apache.hadoop.hbase.HConstants; +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.Mutation; +import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.Table; +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * hbck's local version of the MetaTableAccessor from the hbase repo + */ [email protected] +class HBCKMetaTableAccessor { + + private static final Logger LOG = LoggerFactory.getLogger(HBCKMetaTableAccessor.class); + private static final Logger HBCKMETALOG = LoggerFactory.getLogger("org.apache.hadoop.hbase.META"); + + public static List<RegionInfo> getMergeRegions(Cell[] cells) { + if (cells == null) { + return null; + } + List<RegionInfo> regionsToMerge = null; + for (Cell cell: cells) { + if (!isMergeQualifierPrefix(cell)) { + continue; + } + // Ok. This cell is that of a info:merge* column. + RegionInfo ri = RegionInfo.parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), + cell.getValueLength()); + if (ri != null) { + if (regionsToMerge == null) { + regionsToMerge = new ArrayList<>(); + } + regionsToMerge.add(ri); + } + } + return regionsToMerge; + } + + private static boolean isMergeQualifierPrefix(Cell cell) { + // Check to see if has family and that qualifier starts with the merge qualifier 'merge' + return CellUtil.matchingFamily(cell, HConstants.CATALOG_FAMILY) && + HBCKPrivateCellUtil.qualifierStartsWith(cell, HBCKConstants.MERGE_QUALIFIER_PREFIX); + } + + /** + * Returns the column family used for meta columns. + * @return HConstants.CATALOG_FAMILY. + */ + public static byte[] getCatalogFamily() { + return HConstants.CATALOG_FAMILY; + } + + /** + * Delete the passed <code>d</code> from the <code>hbase:meta</code> table. + * @param connection connection we're using + * @param d Delete to add to hbase:meta + */ + private static void deleteFromMetaTable(final Connection connection, final Delete d) + throws IOException { + List<Delete> dels = new ArrayList<>(1); + dels.add(d); + deleteFromMetaTable(connection, dels); + } + + /** + * Callers should call close on the returned {@link Table} instance. + * @param connection connection we're using to access Meta + * @return An {@link Table} for <code>hbase:meta</code> + */ + public static Table getMetaHTable(final Connection connection) Review comment: Consolidated. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
