|
17 | 17 | */ |
18 | 18 | package org.apache.hadoop.hbase.mob; |
19 | 19 |
|
| 20 | +import static org.apache.hadoop.hbase.mob.MobConstants.DEFAULT_MOB_CLEANER_BATCH_SIZE_UPPER_BOUND; |
| 21 | +import static org.apache.hadoop.hbase.mob.MobConstants.MOB_CLEANER_BATCH_SIZE_UPPER_BOUND; |
| 22 | + |
20 | 23 | import java.io.FileNotFoundException; |
21 | 24 | import java.io.IOException; |
22 | 25 | import java.nio.ByteBuffer; |
@@ -314,20 +317,30 @@ public static void cleanExpiredMobFiles(FileSystem fs, Configuration conf, Table |
314 | 317 | } |
315 | 318 | filesToClean |
316 | 319 | .add(new HStoreFile(fs, file.getPath(), conf, cacheConfig, BloomType.NONE, true)); |
| 320 | + if ( |
| 321 | + filesToClean.size() >= conf.getInt(MOB_CLEANER_BATCH_SIZE_UPPER_BOUND, |
| 322 | + DEFAULT_MOB_CLEANER_BATCH_SIZE_UPPER_BOUND) |
| 323 | + ) { |
| 324 | + if ( |
| 325 | + removeMobFiles(conf, fs, tableName, mobTableDir, columnDescriptor.getName(), |
| 326 | + filesToClean) |
| 327 | + ) { |
| 328 | + deletedFileCount += filesToClean.size(); |
| 329 | + } |
| 330 | + filesToClean.clear(); |
| 331 | + } |
317 | 332 | } |
318 | 333 | } catch (Exception e) { |
319 | 334 | LOG.error("Cannot parse the fileName " + fileName, e); |
320 | 335 | } |
321 | 336 | } |
322 | | - if (!filesToClean.isEmpty()) { |
323 | | - try { |
324 | | - removeMobFiles(conf, fs, tableName, mobTableDir, columnDescriptor.getName(), filesToClean); |
325 | | - deletedFileCount = filesToClean.size(); |
326 | | - } catch (IOException e) { |
327 | | - LOG.error("Failed to delete the mob files " + filesToClean, e); |
328 | | - } |
| 337 | + if ( |
| 338 | + !filesToClean.isEmpty() && removeMobFiles(conf, fs, tableName, mobTableDir, |
| 339 | + columnDescriptor.getName(), filesToClean) |
| 340 | + ) { |
| 341 | + deletedFileCount += filesToClean.size(); |
329 | 342 | } |
330 | | - LOG.info("{} expired mob files are deleted", deletedFileCount); |
| 343 | + LOG.info("Table {} {} expired mob files in total are deleted", tableName, deletedFileCount); |
331 | 344 | } |
332 | 345 |
|
333 | 346 | /** |
@@ -459,10 +472,17 @@ public static boolean isMobRegionName(TableName tableName, byte[] regionName) { |
459 | 472 | * @param family The name of the column family. |
460 | 473 | * @param storeFiles The files to be deleted. |
461 | 474 | */ |
462 | | - public static void removeMobFiles(Configuration conf, FileSystem fs, TableName tableName, |
463 | | - Path tableDir, byte[] family, Collection<HStoreFile> storeFiles) throws IOException { |
464 | | - HFileArchiver.archiveStoreFiles(conf, fs, getMobRegionInfo(tableName), tableDir, family, |
465 | | - storeFiles); |
| 475 | + public static boolean removeMobFiles(Configuration conf, FileSystem fs, TableName tableName, |
| 476 | + Path tableDir, byte[] family, Collection<HStoreFile> storeFiles) { |
| 477 | + try { |
| 478 | + HFileArchiver.archiveStoreFiles(conf, fs, getMobRegionInfo(tableName), tableDir, family, |
| 479 | + storeFiles); |
| 480 | + LOG.info("Table {} {} expired mob files are deleted", tableName, storeFiles.size()); |
| 481 | + return true; |
| 482 | + } catch (IOException e) { |
| 483 | + LOG.error("Failed to delete the mob files, table {}", tableName, e); |
| 484 | + } |
| 485 | + return false; |
466 | 486 | } |
467 | 487 |
|
468 | 488 | /** |
|
0 commit comments