Skip to content
Permalink
Browse files
HBASE-23791 [operator tools] Remove reference to I.A. Private interfa… (
#53)

Signed-off-by: Josh Elser <elserj@apache.org>
  • Loading branch information
wchevreuil committed Mar 4, 2020
1 parent 5b26f20 commit 4764829afe8a2fd1e504de48fb8a9907cac3581e
Showing 6 changed files with 659 additions and 69 deletions.
@@ -36,7 +36,6 @@
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 @@ List<RegionInfo> findExtraRegionsInMETA(String table) throws IOException {

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 List<Future<List<String>>> removeExtraRegionsFromMetaForTables(
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 @@ List<T> checkRegionsInMETA(String table,
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;
@@ -22,7 +22,6 @@

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,20 +83,20 @@ private void deleteRegionFromMeta(String tname) throws IOException, InterruptedE
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"));
metaTable.delete(delete);

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);
}

0 comments on commit 4764829

Please sign in to comment.