in hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java [1768:1810]
private ArrayList<Put> generatePuts(SortedMap<TableName, TableInfo> tablesInfo)
throws IOException {
ArrayList<Put> puts = new ArrayList<>();
boolean hasProblems = false;
for (Entry<TableName, TableInfo> e : tablesInfo.entrySet()) {
TableName name = e.getKey();
// skip "hbase:meta"
if (name.compareTo(TableName.META_TABLE_NAME) == 0) {
continue;
}
TableInfo ti = e.getValue();
// Userspace tables are added in DISABLED state but Namespace table is added ENABLED.
// Adding ns ENABLED makes it so less steps for operator performing recovery.
TableName ns = TableDescriptorBuilder.NAMESPACE_TABLEDESC.getTableName();
TableState.State state = ti.getName().equals(ns)?
TableState.State.ENABLED: TableState.State.DISABLED;
puts.add(HBCKMetaTableAccessor.makePutFromTableState(
new TableState(ti.tableName, state), System.currentTimeMillis()));
for (Entry<byte[], Collection<HbckInfo>> spl : ti.regionSplitCalculator.getStarts().asMap()
.entrySet()) {
Collection<HbckInfo> his = spl.getValue();
int sz = his.size();
if (sz != 1) {
// problem
LOG.error("Split starting at " + Bytes.toStringBinary(spl.getKey()) +
" had " + sz + " regions instead of exactly 1.");
hasProblems = true;
continue;
}
// add the row directly to meta.
HbckInfo hi = his.iterator().next();
RegionInfo hri = hi.getHdfsHRI(); // hi.metaEntry;
Put p = HBCKMetaTableAccessor.makePutFromRegionInfo(hri, System.currentTimeMillis());
addRegionStateToPut(p, org.apache.hadoop.hbase.master.RegionState.State.CLOSED);
addEmptyLocation(p, 0);
puts.add(p);
}
}
return hasProblems? null: puts;
}