class ChunkUtils {

  public static void readData(File file, ByteBuffer buf,
      long offset, long len, VolumeIOStats volumeIOStats)
      throws StorageContainerException {

    final Path path = file.toPath();
    final long startTime = Time.monotonicNow();
    final long bytesRead;

    try {
      bytesRead = processFileExclusively(path, () -> {
        try (FileChannel channel = open(path, READ_OPTIONS, NO_ATTRIBUTES);
             FileLock ignored = channel.lock(offset, len, true)) {

          return channel.read(buf, offset);
        } catch (IOException e) {
          throw new UncheckedIOException(e);
        }
      });
    } catch (UncheckedIOException e) {
      throw wrapInStorageContainerException(e.getCause());
    }

    // Increment volumeIO stats here.
    long endTime = Time.monotonicNow();
    volumeIOStats.incReadTime(endTime - startTime);
    volumeIOStats.incReadOpCount();
    volumeIOStats.incReadBytes(bytesRead);

    LOG.debug("Read {} bytes starting at offset {} from {}",
        bytesRead, offset, file);

    validateReadSize(len, bytesRead);

    buf.flip();
  }

  private  ChunkUtils();

}