File allocate(String filename, long size, boolean requestSwapSegment) throws StoreException {
    File segmentFile = new File(dataDir, filename);
    if (!segmentFile.exists()) {
      try {
        diskSpaceAllocator.allocate(segmentFile, size, storeId, requestSwapSegment);
      } catch (IOException e) {
        StoreErrorCodes errorCode = StoreException.resolveErrorCode(e);
        throw new StoreException(errorCode.toString() + " while allocating the file", e, errorCode);
      }
    }
    return segmentFile;
  }
Allocates a file named {@code filename} and of capacity {@code size}.
@param filename the intended filename of the file.
@param size the intended size of the file.
@param requestSwapSegment whether swap segment is requested by {@link BlobStoreCompactor}
@return a {@link File} instance that points to the created file named {@code filename} and capacity {@code size}.
@throws StoreException if the there is any store exception while allocating the file.
ambry-store/src/main/java/com/github/ambry/store/Log.java