joshelser commented on a change in pull request #53: HBASE-23791 [operator
tools] Remove reference to I.A. Private interfa…
URL:
https://github.com/apache/hbase-operator-tools/pull/53#discussion_r375480224
##########
File path:
hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
##########
@@ -138,4 +182,550 @@ private static void deleteFromMetaTable(final Connection
connection, final Delet
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;
+ } else {
Review comment:
Nit: can just be `if () { } return null;`
----------------------------------------------------------------
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