DirectoryHolder getNextDir(long minAvailableSpace, boolean checkForWarning) {
    if (minAvailableSpace < parent.getMaxOplogSizeInBytes()
        && !DiskStoreImpl.SET_IGNORE_PREALLOCATE) {
      minAvailableSpace = parent.getMaxOplogSizeInBytes();
    }

    DirectoryHolder selectedHolder = null;
    synchronized (parent.getDirectoryHolders()) {
      for (int i = 0; i < parent.dirLength; ++i) {
        DirectoryHolder dirHolder = parent.directories[dirCounter];

        // Increment the directory counter to next position so that next time when this operation
        // is invoked, it checks for the Directory Space in a cyclical fashion.
        dirCounter = ++dirCounter % parent.dirLength;

        // if the current directory has some space, then quit and return the dir
        if (dirHolder.getAvailableSpace() >= minAvailableSpace) {
          if (checkForWarning && !parent.isDirectoryUsageNormal(dirHolder)) {
            if (logger.isDebugEnabled()) {
              logger.debug("Ignoring directory {} due to insufficient disk space", dirHolder);
            }
          } else {
            selectedHolder = dirHolder;
            break;
          }
        }
      }

      if (selectedHolder == null) {
        // we didn't find a warning-free directory, try again ignoring the check
        if (checkForWarning) {
          return getNextDir(minAvailableSpace, false);
        }

        if (parent.isCompactionEnabled()) {
          selectedHolder = parent.directories[dirCounter];

          // Increment the directory counter to next position
          dirCounter = ++dirCounter % parent.dirLength;
          if (selectedHolder.getAvailableSpace() < minAvailableSpace) {
            logger.warn(
                "Even though the configured directory size limit has been exceeded a new oplog will be created because compaction is enabled. The configured limit is {}. The current space used in the directory by this disk store is {}.",
                selectedHolder.getUsedSpace(), selectedHolder.getCapacity());
          }
        } else {
          throw new DiskAccessException(
              "Disk is full and compaction is disabled. No space can be created", parent);
        }
      }
    }

    return selectedHolder;
  }
Returns the next available DirectoryHolder which has space. If no dir has space then it will
return one anyway if compaction is enabled.

@param minAvailableSpace the minimum amount of space we need in this directory.
geode-core/src/main/java/org/apache/geode/internal/cache/PersistentOplogSet.java