@Test
  public void testSmallMaxBatchSize() throws IOException {
    AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager();
    ProcedureExecutor<MasterProcedureEnv> procExec =
      UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
    List<RegionInfo> regions = UTIL.getAdmin().getRegions(TABLE_NAME);
    assertTrue(2 <= regions.size());
    Set<StuckRegion> stuckRegions =
      regions.stream().map(r -> stickRegion(am, procExec, r)).collect(Collectors.toSet());
    ReopenTableRegionsProcedure proc =
      new ReopenTableRegionsProcedure(TABLE_NAME, BACKOFF_MILLIS_PER_RS, REOPEN_BATCH_SIZE_MAX);
    procExec.submitProcedure(proc);
    UTIL.waitFor(10000, () -> proc.getState() == ProcedureState.WAITING_TIMEOUT);

    // the first batch should be small
    confirmBatchSize(1, stuckRegions, proc);
    ProcedureSyncWait.waitForProcedureToComplete(procExec, proc, 60_000);

    // other batches should also be small
    assertTrue(proc.getBatchesProcessed() >= regions.size());

    // all regions should only be opened once
    assertEquals(proc.getRegionsReopened(), regions.size());
  }
Confirm that we will batch region reopens when reopening all table regions. This can avoid the
pain associated with reopening too many regions at once.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestReopenTableRegionsProcedureBatching.java