Skip to content

Commit e50ec76

Browse files
committed
HBASE-22961 Deprecate hbck1 in core
Adds deprecations on HBaseFsck and on supporting classes such as the reporting Interface. Provides alternatives in FSUtils for progress reporting and deprecates methods that use hbck1 facility. Signed-off-by: Peter Somogyi <psomogyi@apache.org>
1 parent 2e0e1f8 commit e50ec76

File tree

3 files changed

+115
-22
lines changed

3 files changed

+115
-22
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Lines changed: 103 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,17 @@ protected boolean accept(Path p, @CheckForNull Boolean isDir) {
11791179
}
11801180
}
11811181

1182+
/**
1183+
* Called every so-often by storefile map builder getTableStoreFilePathMap to
1184+
* report progress.
1185+
*/
1186+
interface ProgressReporter {
1187+
/**
1188+
* @param status File or directory we are about to process.
1189+
*/
1190+
void progress(FileStatus status);
1191+
}
1192+
11821193
/**
11831194
* Runs through the HBase rootdir/tablename and creates a reverse lookup map for
11841195
* table StoreFile names to the full Path.
@@ -1198,7 +1209,8 @@ protected boolean accept(Path p, @CheckForNull Boolean isDir) {
11981209
public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> map,
11991210
final FileSystem fs, final Path hbaseRootDir, TableName tableName)
12001211
throws IOException, InterruptedException {
1201-
return getTableStoreFilePathMap(map, fs, hbaseRootDir, tableName, null, null, null);
1212+
return getTableStoreFilePathMap(map, fs, hbaseRootDir, tableName, null, null,
1213+
(ProgressReporter)null);
12021214
}
12031215

12041216
/**
@@ -1218,15 +1230,55 @@ public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> map,
12181230
* @param tableName name of the table to scan.
12191231
* @param sfFilter optional path filter to apply to store files
12201232
* @param executor optional executor service to parallelize this operation
1221-
* @param errors ErrorReporter instance or null
1233+
* @param progressReporter Instance or null; gets called every time we move to new region of
1234+
* family dir and for each store file.
12221235
* @return Map keyed by StoreFile name with a value of the full Path.
12231236
* @throws IOException When scanning the directory fails.
1224-
* @throws InterruptedException
1237+
* @deprecated Since 2.3.0. For removal in hbase4. Use ProgressReporter override instead.
12251238
*/
1239+
@Deprecated
12261240
public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> resultMap,
12271241
final FileSystem fs, final Path hbaseRootDir, TableName tableName, final PathFilter sfFilter,
1228-
ExecutorService executor, final HbckErrorReporter errors)
1242+
ExecutorService executor, final HbckErrorReporter progressReporter)
12291243
throws IOException, InterruptedException {
1244+
return getTableStoreFilePathMap(resultMap, fs, hbaseRootDir, tableName, sfFilter, executor,
1245+
new ProgressReporter() {
1246+
@Override
1247+
public void progress(FileStatus status) {
1248+
// status is not used in this implementation.
1249+
progressReporter.progress();
1250+
}
1251+
});
1252+
}
1253+
1254+
/*
1255+
* Runs through the HBase rootdir/tablename and creates a reverse lookup map for
1256+
* table StoreFile names to the full Path. Note that because this method can be called
1257+
* on a 'live' HBase system that we will skip files that no longer exist by the time
1258+
* we traverse them and similarly the user of the result needs to consider that some
1259+
* entries in this map may not exist by the time this call completes.
1260+
* <br>
1261+
* Example...<br>
1262+
* Key = 3944417774205889744 <br>
1263+
* Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744
1264+
*
1265+
* @param resultMap map to add values. If null, this method will create and populate one
1266+
* to return
1267+
* @param fs The file system to use.
1268+
* @param hbaseRootDir The root directory to scan.
1269+
* @param tableName name of the table to scan.
1270+
* @param sfFilter optional path filter to apply to store files
1271+
* @param executor optional executor service to parallelize this operation
1272+
* @param progressReporter Instance or null; gets called every time we move to new region of
1273+
* family dir and for each store file.
1274+
* @return Map keyed by StoreFile name with a value of the full Path.
1275+
* @throws IOException When scanning the directory fails.
1276+
* @throws InterruptedException
1277+
*/
1278+
public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> resultMap,
1279+
final FileSystem fs, final Path hbaseRootDir, TableName tableName, final PathFilter sfFilter,
1280+
ExecutorService executor, final ProgressReporter progressReporter)
1281+
throws IOException, InterruptedException {
12301282

12311283
final Map<String, Path> finalResultMap =
12321284
resultMap == null ? new ConcurrentHashMap<>(128, 0.75f, 32) : resultMap;
@@ -1247,8 +1299,8 @@ public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> resul
12471299
final List<Future<?>> futures = new ArrayList<>(regionDirs.size());
12481300

12491301
for (FileStatus regionDir : regionDirs) {
1250-
if (null != errors) {
1251-
errors.progress();
1302+
if (null != progressReporter) {
1303+
progressReporter.progress(regionDir);
12521304
}
12531305
final Path dd = regionDir.getPath();
12541306

@@ -1271,8 +1323,8 @@ public void run() {
12711323
return;
12721324
}
12731325
for (FileStatus familyDir : familyDirs) {
1274-
if (null != errors) {
1275-
errors.progress();
1326+
if (null != progressReporter) {
1327+
progressReporter.progress(familyDir);
12761328
}
12771329
Path family = familyDir.getPath();
12781330
if (family.getName().equals(HConstants.RECOVERED_EDITS_DIR)) {
@@ -1282,8 +1334,8 @@ public void run() {
12821334
// put in map
12831335
FileStatus[] familyStatus = fs.listStatus(family);
12841336
for (FileStatus sfStatus : familyStatus) {
1285-
if (null != errors) {
1286-
errors.progress();
1337+
if (null != progressReporter) {
1338+
progressReporter.progress(sfStatus);
12871339
}
12881340
Path sf = sfStatus.getPath();
12891341
if (sfFilter == null || sfFilter.accept(sf)) {
@@ -1362,12 +1414,45 @@ public static int getRegionReferenceFileCount(final FileSystem fs, final Path p)
13621414
* @param hbaseRootDir The root directory to scan.
13631415
* @return Map keyed by StoreFile name with a value of the full Path.
13641416
* @throws IOException When scanning the directory fails.
1365-
* @throws InterruptedException
13661417
*/
1367-
public static Map<String, Path> getTableStoreFilePathMap(
1368-
final FileSystem fs, final Path hbaseRootDir)
1418+
public static Map<String, Path> getTableStoreFilePathMap(final FileSystem fs,
1419+
final Path hbaseRootDir)
13691420
throws IOException, InterruptedException {
1370-
return getTableStoreFilePathMap(fs, hbaseRootDir, null, null, null);
1421+
return getTableStoreFilePathMap(fs, hbaseRootDir, null, null, (ProgressReporter)null);
1422+
}
1423+
1424+
/**
1425+
* Runs through the HBase rootdir and creates a reverse lookup map for
1426+
* table StoreFile names to the full Path.
1427+
* <br>
1428+
* Example...<br>
1429+
* Key = 3944417774205889744 <br>
1430+
* Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744
1431+
*
1432+
* @param fs The file system to use.
1433+
* @param hbaseRootDir The root directory to scan.
1434+
* @param sfFilter optional path filter to apply to store files
1435+
* @param executor optional executor service to parallelize this operation
1436+
* @param progressReporter Instance or null; gets called every time we move to new region of
1437+
* family dir and for each store file.
1438+
* @return Map keyed by StoreFile name with a value of the full Path.
1439+
* @throws IOException When scanning the directory fails.
1440+
* @deprecated Since 2.3.0. Will be removed in hbase4. Used {@link
1441+
* #getTableStoreFilePathMap(FileSystem, Path, PathFilter, ExecutorService, ProgressReporter)}
1442+
*/
1443+
@Deprecated
1444+
public static Map<String, Path> getTableStoreFilePathMap(final FileSystem fs,
1445+
final Path hbaseRootDir, PathFilter sfFilter, ExecutorService executor,
1446+
HbckErrorReporter progressReporter)
1447+
throws IOException, InterruptedException {
1448+
return getTableStoreFilePathMap(fs, hbaseRootDir, sfFilter, executor,
1449+
new ProgressReporter() {
1450+
@Override
1451+
public void progress(FileStatus status) {
1452+
// status is not used in this implementation.
1453+
progressReporter.progress();
1454+
}
1455+
});
13711456
}
13721457

13731458
/**
@@ -1382,14 +1467,15 @@ public static Map<String, Path> getTableStoreFilePathMap(
13821467
* @param hbaseRootDir The root directory to scan.
13831468
* @param sfFilter optional path filter to apply to store files
13841469
* @param executor optional executor service to parallelize this operation
1385-
* @param errors ErrorReporter instance or null
1470+
* @param progressReporter Instance or null; gets called every time we move to new region of
1471+
* family dir and for each store file.
13861472
* @return Map keyed by StoreFile name with a value of the full Path.
13871473
* @throws IOException When scanning the directory fails.
13881474
* @throws InterruptedException
13891475
*/
13901476
public static Map<String, Path> getTableStoreFilePathMap(
13911477
final FileSystem fs, final Path hbaseRootDir, PathFilter sfFilter,
1392-
ExecutorService executor, HbckErrorReporter errors)
1478+
ExecutorService executor, ProgressReporter progressReporter)
13931479
throws IOException, InterruptedException {
13941480
ConcurrentHashMap<String, Path> map = new ConcurrentHashMap<>(1024, 0.75f, 32);
13951481

@@ -1399,7 +1485,7 @@ public static Map<String, Path> getTableStoreFilePathMap(
13991485
// only include the directory paths to tables
14001486
for (Path tableDir : FSUtils.getTableDirs(fs, hbaseRootDir)) {
14011487
getTableStoreFilePathMap(map, fs, hbaseRootDir,
1402-
FSUtils.getTableName(tableDir), sfFilter, executor, errors);
1488+
FSUtils.getTableName(tableDir), sfFilter, executor, progressReporter);
14031489
}
14041490
return map;
14051491
}

hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@
150150
* HBaseFsck (hbck) is a tool for checking and repairing region consistency and
151151
* table integrity problems in a corrupted HBase. This tool was written for hbase-1.x. It does not
152152
* work with hbase-2.x; it can read state but is not allowed to change state; i.e. effect 'repair'.
153-
* See hbck2 (HBASE-19121) for a hbck tool for hbase2.
153+
* Even though it can 'read' state, given how so much has changed in how hbase1 and hbase2 operate,
154+
* it will often misread. See hbck2 (HBASE-19121) for a hbck tool for hbase2. This class is
155+
* deprecated.
154156
*
155157
* <p>
156158
* Region consistency checks verify that hbase:meta, region deployment on region
@@ -193,7 +195,9 @@
193195
* If hbck is run from the command line, there are a handful of arguments that
194196
* can be used to limit the kinds of repairs hbck will do. See the code in
195197
* {@link #printUsageAndExit()} for more details.
198+
* @deprecated For removal in hbase-4.0.0. Use HBCK2 instead.
196199
*/
200+
@Deprecated
197201
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
198202
@InterfaceStability.Evolving
199203
public class HBaseFsck extends Configured implements Closeable {

hbase-server/src/main/java/org/apache/hadoop/hbase/util/HbckErrorReporter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Licensed to the Apache Software Foundation (ASF) under one
33
* or more contributor license agreements. See the NOTICE file
44
* distributed with this work for additional information
@@ -20,12 +20,15 @@
2020
import java.util.ArrayList;
2121

2222
import org.apache.yetus.audience.InterfaceAudience;
23-
import org.apache.yetus.audience.InterfaceStability;
2423

24+
/**
25+
* Used by {@link HBaseFsck} reporting system.
26+
* @deprecated Since 2.3.0. To be removed in hbase4. Use HBCK2 instead. Remove when
27+
* {@link HBaseFsck} is removed.
28+
*/
29+
@Deprecated
2530
@InterfaceAudience.Private
26-
@InterfaceStability.Evolving
2731
public interface HbckErrorReporter {
28-
2932
enum ERROR_CODE {
3033
UNKNOWN, NO_META_REGION, NULL_META_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META,
3134
NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META,

0 commit comments

Comments
 (0)