@Override
  public void seek(long pos) throws IOException {
    Preconditions.checkArgument(pos >= 0, "Seek position is negative: %s", pos);
    Preconditions.checkArgument(pos <= mLength,
        "Seek position (%s) exceeds the length of the file (%s)", pos, mLength);
    if (mPosition == pos) {
      return;
    }
    if (!mUfsInStream.isPresent()) {
      mPosition = pos;
      return;
    }
    if (mUfsInStream.get() instanceof Seekable) {
      ((Seekable) mUfsInStream.get()).seek(pos);
    } else if (mPosition < pos) {
      long skipped = 0;
      do {
        skipped = mUfsInStream.get().skip(pos - mPosition);
        if (skipped > 0) {
          mPosition += skipped;
        }
      } while (mPosition < pos && skipped > 0);
      if (mPosition != pos) {
        throw new InternalRuntimeException(String.format(
            "Failed to use skip to seek to pos %s, current position %s", pos, mPosition));
      }
    } else {
      close();
    }
    mPosition = pos;
  }
@Test
  public void seekNegative() throws IOException, AlluxioException {
    AlluxioURI ufsPath = getUfsPath();
    createFile(ufsPath, CHUNK_SIZE);
    try (FileInStream inStream = getStream(ufsPath)) {
      assertThrows(IllegalArgumentException.class, () -> inStream.seek(-1));
    }
  }