@Test
  public void testOnConfigurationChange() throws Exception {
    int availableProcessorNum = Runtime.getRuntime().availableProcessors();
    if (availableProcessorNum == 1) { // no need to run this test
      return;
    }

    // have at least 2 available processors/cores
    int initPoolSize = availableProcessorNum / 2;
    int changedPoolSize = availableProcessorNum;

    Stoppable stop = new StoppableImplementation();
    Configuration conf = UTIL.getConfiguration();
    Path testDir = UTIL.getDataTestDir();
    FileSystem fs = UTIL.getTestFileSystem();
    String confKey = "hbase.test.cleaner.delegates";
    conf.set(confKey, AlwaysDelete.class.getName());
    conf.set(CleanerChore.CHORE_POOL_SIZE, String.valueOf(initPoolSize));
    AllValidPaths chore =
      new AllValidPaths("test-file-cleaner", stop, conf, fs, testDir, confKey, POOL);
    chore.setEnabled(true);
    // Create subdirs under testDir
    int dirNums = 6;
    Path[] subdirs = new Path[dirNums];
    for (int i = 0; i < dirNums; i++) {
      subdirs[i] = new Path(testDir, "subdir-" + i);
      fs.mkdirs(subdirs[i]);
    }
    // Under each subdirs create 6 files
    for (Path subdir : subdirs) {
      createFiles(fs, subdir, 6);
    }
    // Start chore
    Thread t = new Thread(() -> chore.chore());
    t.setDaemon(true);
    t.start();
    // Change size of chore's pool
    conf.set(CleanerChore.CHORE_POOL_SIZE, String.valueOf(changedPoolSize));
    POOL.onConfigurationChange(conf);
    assertEquals(changedPoolSize, chore.getChorePoolSize());
    // Stop chore
    t.join();
  }
The cleaner runs in a loop, where it first checks to see all the files under a directory can be
deleted. If they all can, then we try to delete the directory. However, a file may be added
that directory to after the original check. This ensures that we don't accidentally delete that
directory on and don't get spurious IOExceptions.
<p>
This was from HBASE-7465.
@throws Exception on failure
hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java