Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,8 @@ private static void updateLocation(Connection connection, RegionInfo regionInfo,
* @param regionInfo region to be deleted from META
* @throws IOException
*/
public static void deleteRegion(Connection connection, RegionInfo regionInfo) throws IOException {
public static void deleteRegionInfo(Connection connection, RegionInfo regionInfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the method name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the method only delete the info column family (will keep other cf), so name it deleteRegionInfo will be better.

throws IOException {
long time = EnvironmentEdgeManager.currentTime();
Delete delete = new Delete(regionInfo.getRegionName());
delete.addFamily(getCatalogFamily(), time);
Expand All @@ -1832,16 +1833,17 @@ public static void deleteRegion(Connection connection, RegionInfo regionInfo) th
* @param connection connection we're using
* @param regionsInfo list of regions to be deleted from META
*/
public static void deleteRegions(Connection connection, List<RegionInfo> regionsInfo)
public static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo)
throws IOException {
deleteRegions(connection, regionsInfo, EnvironmentEdgeManager.currentTime());
deleteRegionInfos(connection, regionsInfo, EnvironmentEdgeManager.currentTime());
}

/**
* Deletes the specified regions from META.
* @param connection connection we're using
* @param regionsInfo list of regions to be deleted from META
*/
public static void deleteRegions(Connection connection, List<RegionInfo> regionsInfo, long ts)
public static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo, long ts)
throws IOException {
List<Delete> deletes = new ArrayList<>(regionsInfo.size());
for (RegionInfo hri : regionsInfo) {
Expand All @@ -1860,11 +1862,11 @@ public static void deleteRegions(Connection connection, List<RegionInfo> regions
* @param connection connection we're using
* @param regionInfos list of regions to be added to META
*/
public static void overwriteRegions(Connection connection,
List<RegionInfo> regionInfos, int regionReplication) throws IOException {
public static void overwriteRegions(Connection connection, List<RegionInfo> regionInfos,
int regionReplication) throws IOException {
// use master time for delete marker and the Put
long now = EnvironmentEdgeManager.currentTime();
deleteRegions(connection, regionInfos, now);
deleteRegionInfos(connection, regionInfos, now);
// Why sleep? This is the easiest way to ensure that the previous deletes does not
// eclipse the following puts, that might happen in the same ts from the server.
// See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected Flow executeFromState(MasterProcedureEnv env, GCRegionState state)
am.getRegionStates().deleteRegion(getRegion());
}
}
MetaTableAccessor.deleteRegion(masterServices.getConnection(), getRegion());
MetaTableAccessor.deleteRegionInfo(masterServices.getConnection(), getRegion());
masterServices.getServerManager().removeRegion(getRegion());
FavoredNodesManager fnm = masterServices.getFavoredNodesManager();
if (fnm != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public void deleteRegion(final RegionInfo regionInfo) throws IOException {
}

public void deleteRegions(final List<RegionInfo> regions) throws IOException {
MetaTableAccessor.deleteRegions(master.getConnection(), regions);
MetaTableAccessor.deleteRegionInfos(master.getConnection(), regions);
}

// ==========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ protected static void deleteFromFs(final MasterProcedureEnv env,
}

/**
* There may be items for this table still up in hbase:meta in the case where the
* info:regioninfo column was empty because of some write error. Remove ALL rows from hbase:meta
* that have to do with this table. See HBASE-12980.
* There may be items for this table still up in hbase:meta in the case where the info:regioninfo
* column was empty because of some write error. Remove ALL rows from hbase:meta that have to do
* with this table. See HBASE-12980.
*/
private static void cleanAnyRemainingRows(final MasterProcedureEnv env,
final TableName tableName) throws IOException {
private static void cleanRegionsInMeta(final MasterProcedureEnv env, final TableName tableName)
throws IOException {
Connection connection = env.getMasterServices().getConnection();
Scan tableScan = MetaTableAccessor.getScanForTableName(connection, tableName);
try (Table metaTable = connection.getTable(TableName.META_TABLE_NAME)) {
Expand All @@ -373,19 +373,17 @@ private static void cleanAnyRemainingRows(final MasterProcedureEnv env,
}
}
if (!deletes.isEmpty()) {
LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName +
" from " + TableName.META_TABLE_NAME);
LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName + " from "
+ TableName.META_TABLE_NAME);
metaTable.delete(deletes);
}
}
}

protected static void deleteFromMeta(final MasterProcedureEnv env,
final TableName tableName, List<RegionInfo> regions) throws IOException {
MetaTableAccessor.deleteRegions(env.getMasterServices().getConnection(), regions);

protected static void deleteFromMeta(final MasterProcedureEnv env, final TableName tableName,
List<RegionInfo> regions) throws IOException {
// Clean any remaining rows for this table.
cleanAnyRemainingRows(env, tableName);
cleanRegionsInMeta(env, tableName);

// clean region references from the server manager
env.getMasterServices().getServerManager().removeRegions(regions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private void updateMETA(final MasterProcedureEnv env) throws IOException {
// not overwritten/removed, so you end up with old informations
// that are not correct after the restore.
if (regionsToRemove != null) {
MetaTableAccessor.deleteRegions(conn, regionsToRemove);
MetaTableAccessor.deleteRegionInfos(conn, regionsToRemove);
deleteRegionsFromInMemoryStates(regionsToRemove, env, regionReplication);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ public static HRegion createHDFSRegionDir(Configuration conf,
*/
public static void removeParentInMeta(Configuration conf, RegionInfo hri) throws IOException {
Connection conn = ConnectionFactory.createConnection(conf);
MetaTableAccessor.deleteRegion(conn, hri);
MetaTableAccessor.deleteRegionInfo(conn, hri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testConsistency() throws IOException {
assertTrue(report.isEmpty());
// Now remove first region in table t2 to see if catalogjanitor scan notices.
List<RegionInfo> t2Ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), T2);
MetaTableAccessor.deleteRegion(TEST_UTIL.getConnection(), t2Ris.get(0));
MetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), t2Ris.get(0));
gc = janitor.scan();
report = janitor.getLastReport();
assertFalse(report.isEmpty());
Expand Down