@Override
  public int read() throws IOException {
    if (mPosition == mLength) { // at end of file
      return -1;
    }
    updateStreamIfNeeded();
    int res = mUfsInStream.get().read();
    if (res == -1) {
      return -1;
    }
    mPosition++;
    Metrics.BYTES_READ_FROM_UFS.inc(1);
    return res;
  }
@Test
  public void readAllByteBuffer() throws IOException, AlluxioException {
    int len = CHUNK_SIZE * 5;
    int start = 0;
    AlluxioURI ufsPath = getUfsPath();
    createFile(ufsPath, CHUNK_SIZE * 5);
    ByteBuffer buffer = ByteBuffer.allocate(CHUNK_SIZE);
    try (FileInStream inStream = getStream(ufsPath)) {
      while (start < len) {
        assertEquals(CHUNK_SIZE, inStream.read(buffer));
        assertTrue(BufferUtils.equalIncreasingByteBuffer(start, CHUNK_SIZE, buffer));
        start += CHUNK_SIZE;
        buffer.clear();
      }
    }
  }