@Override
  public void allocateFile(String path, String storeId) throws IOException {
    String targetPath = updatePathWithResetCompactionIndex(path);

    try {
      // Verify service is running.
      validateIfFileStoreIsRunning();

      // Validate inputs.
      Objects.requireNonNull(path, "path must not be null");
      Objects.requireNonNull(storeId, "storeId must not be null");
      // throw error if the file exists
      File file = new File(targetPath);
      if (file.exists()) {
        throw new IOException("File already exists in " + targetPath);
      }

      // Allocate space for the file
      synchronized (storeWriteLock) {
        diskSpaceAllocator.allocate(file, segmentSize, storeId, false);
      }
    } catch (Exception e) {
      logger.error("Unexpected error while allocating file in path {} for store {}", targetPath, storeId, e);
      throw new FileStoreException("Error while allocating file in path " + targetPath + " for store: " + storeId,
          FileStoreErrorCode.FileStoreFileAllocationFailed);
    }

    logger.info("Disk Space Allocator has allocated space for file in {}", targetPath);
  }
Allocates a file in the specified path.
@param path The path where the file should be allocated
@param storeId The store ID for which the file is requested
@throws IOException if an I/O error occurs during the allocation
ambry-store/src/main/java/com/github/ambry/store/FileStore.java