@Test
  public void testEarlyTerminationOfCompactorByDefault() throws Exception {
    DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
    diskRegionProperties.setRegionName(regionName);
    diskRegionProperties.setRolling(true);
    diskRegionProperties.setCompactionThreshold(100);
    diskRegionProperties.setDiskDirs(diskDirs);
    diskRegionProperties.setMaxOplogSize(100);
    diskRegionProperties.setPersistBackup(true);

    DiskStoreFactory diskStoreFactory = toDiskStoreFactory(diskRegionProperties);

    createDiskStoreWithSizeInBytes(diskStoreName, diskStoreFactory, 100);

    Region<String, String> region =
        createRegion(regionName, diskStoreName, true, true, false, false, 0);

    AtomicReference<Future<Void>> closeRegionFuture = new AtomicReference<>();
    CountDownLatch closingRegionLatch = new CountDownLatch(1);
    CountDownLatch allowCompactorLatch = new CountDownLatch(1);

    LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = true;
    CacheObserverHolder.setInstance(new CacheObserverAdapter() {
      private final CountDownLatch compactorSignalledLatch = new CountDownLatch(1);
      private final CountDownLatch compactorCompletedLatch = new CountDownLatch(1);
      private volatile int oplogSizeBeforeRolling;

      @Override
      public void beforeGoingToCompact() {
        try {
          // wait for operations to get over
          awaitLatch(allowCompactorLatch);

          DiskRegion diskRegion = getDiskRegion(region);
          oplogSizeBeforeRolling = diskRegion.getOplogIdToOplog().size();
          assertThat(oplogSizeBeforeRolling).isGreaterThan(0);

          closeRegionFuture.set(executorServiceRule.runAsync(() -> {
            closingRegionLatch.countDown();
            DiskStoreImpl diskStoreImpl = getDiskStore(region);
            region.close();
            diskStoreImpl.close();
          }));

          // wait for th to call afterSignallingCompactor
          awaitLatch(compactorSignalledLatch);
        } catch (AssertionError | Exception e) {
          errorCollector.addError(e);
        }
      }

      @Override
      public void afterSignallingCompactor() {
        try {
          compactorSignalledLatch.countDown();
        } catch (AssertionError | Exception e) {
          errorCollector.addError(e);
        }
      }

      @Override
      public void afterStoppingCompactor() {
        try {
          awaitLatch(compactorCompletedLatch);
        } catch (AssertionError | Exception e) {
          errorCollector.addError(e);
        }
      }

      @Override
      public void afterHavingCompacted() {
        try {
          DiskRegion diskRegion = getDiskRegion(region);
          assertThat(diskRegion.getOplogIdToOplog()).hasSize(oplogSizeBeforeRolling);
        } catch (AssertionError | Exception e) {
          errorCollector.addError(e);
        } finally {
          compactorCompletedLatch.countDown();
        }
      }
    });

    // create some string entries
    for (int i = 0; i < 100; ++i) {
      region.put(String.valueOf(i), String.valueOf(i));
    }

    allowCompactorLatch.countDown();
    awaitLatch(closingRegionLatch);
    awaitFuture(closeRegionFuture);
  }
If IOException occurs while initializing a region, then the cache servers should not be
stopped
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionJUnitTest.java