@@ -1179,6 +1179,17 @@ protected boolean accept(Path p, @CheckForNull Boolean isDir) {
1179
1179
}
1180
1180
}
1181
1181
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
+
1182
1193
/**
1183
1194
* Runs through the HBase rootdir/tablename and creates a reverse lookup map for
1184
1195
* table StoreFile names to the full Path.
@@ -1198,7 +1209,8 @@ protected boolean accept(Path p, @CheckForNull Boolean isDir) {
1198
1209
public static Map <String , Path > getTableStoreFilePathMap (Map <String , Path > map ,
1199
1210
final FileSystem fs , final Path hbaseRootDir , TableName tableName )
1200
1211
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 );
1202
1214
}
1203
1215
1204
1216
/**
@@ -1218,15 +1230,55 @@ public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> map,
1218
1230
* @param tableName name of the table to scan.
1219
1231
* @param sfFilter optional path filter to apply to store files
1220
1232
* @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.
1222
1235
* @return Map keyed by StoreFile name with a value of the full Path.
1223
1236
* @throws IOException When scanning the directory fails.
1224
- * @throws InterruptedException
1237
+ * @deprecated Since 2.3.0. For removal in hbase4. Use ProgressReporter override instead.
1225
1238
*/
1239
+ @ Deprecated
1226
1240
public static Map <String , Path > getTableStoreFilePathMap (Map <String , Path > resultMap ,
1227
1241
final FileSystem fs , final Path hbaseRootDir , TableName tableName , final PathFilter sfFilter ,
1228
- ExecutorService executor , final HbckErrorReporter errors )
1242
+ ExecutorService executor , final HbckErrorReporter progressReporter )
1229
1243
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 {
1230
1282
1231
1283
final Map <String , Path > finalResultMap =
1232
1284
resultMap == null ? new ConcurrentHashMap <>(128 , 0.75f , 32 ) : resultMap ;
@@ -1247,8 +1299,8 @@ public static Map<String, Path> getTableStoreFilePathMap(Map<String, Path> resul
1247
1299
final List <Future <?>> futures = new ArrayList <>(regionDirs .size ());
1248
1300
1249
1301
for (FileStatus regionDir : regionDirs ) {
1250
- if (null != errors ) {
1251
- errors .progress ();
1302
+ if (null != progressReporter ) {
1303
+ progressReporter .progress (regionDir );
1252
1304
}
1253
1305
final Path dd = regionDir .getPath ();
1254
1306
@@ -1271,8 +1323,8 @@ public void run() {
1271
1323
return ;
1272
1324
}
1273
1325
for (FileStatus familyDir : familyDirs ) {
1274
- if (null != errors ) {
1275
- errors .progress ();
1326
+ if (null != progressReporter ) {
1327
+ progressReporter .progress (familyDir );
1276
1328
}
1277
1329
Path family = familyDir .getPath ();
1278
1330
if (family .getName ().equals (HConstants .RECOVERED_EDITS_DIR )) {
@@ -1282,8 +1334,8 @@ public void run() {
1282
1334
// put in map
1283
1335
FileStatus [] familyStatus = fs .listStatus (family );
1284
1336
for (FileStatus sfStatus : familyStatus ) {
1285
- if (null != errors ) {
1286
- errors .progress ();
1337
+ if (null != progressReporter ) {
1338
+ progressReporter .progress (sfStatus );
1287
1339
}
1288
1340
Path sf = sfStatus .getPath ();
1289
1341
if (sfFilter == null || sfFilter .accept (sf )) {
@@ -1362,12 +1414,45 @@ public static int getRegionReferenceFileCount(final FileSystem fs, final Path p)
1362
1414
* @param hbaseRootDir The root directory to scan.
1363
1415
* @return Map keyed by StoreFile name with a value of the full Path.
1364
1416
* @throws IOException When scanning the directory fails.
1365
- * @throws InterruptedException
1366
1417
*/
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 )
1369
1420
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
+ });
1371
1456
}
1372
1457
1373
1458
/**
@@ -1382,14 +1467,15 @@ public static Map<String, Path> getTableStoreFilePathMap(
1382
1467
* @param hbaseRootDir The root directory to scan.
1383
1468
* @param sfFilter optional path filter to apply to store files
1384
1469
* @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.
1386
1472
* @return Map keyed by StoreFile name with a value of the full Path.
1387
1473
* @throws IOException When scanning the directory fails.
1388
1474
* @throws InterruptedException
1389
1475
*/
1390
1476
public static Map <String , Path > getTableStoreFilePathMap (
1391
1477
final FileSystem fs , final Path hbaseRootDir , PathFilter sfFilter ,
1392
- ExecutorService executor , HbckErrorReporter errors )
1478
+ ExecutorService executor , ProgressReporter progressReporter )
1393
1479
throws IOException , InterruptedException {
1394
1480
ConcurrentHashMap <String , Path > map = new ConcurrentHashMap <>(1024 , 0.75f , 32 );
1395
1481
@@ -1399,7 +1485,7 @@ public static Map<String, Path> getTableStoreFilePathMap(
1399
1485
// only include the directory paths to tables
1400
1486
for (Path tableDir : FSUtils .getTableDirs (fs , hbaseRootDir )) {
1401
1487
getTableStoreFilePathMap (map , fs , hbaseRootDir ,
1402
- FSUtils .getTableName (tableDir ), sfFilter , executor , errors );
1488
+ FSUtils .getTableName (tableDir ), sfFilter , executor , progressReporter );
1403
1489
}
1404
1490
return map ;
1405
1491
}
0 commit comments