@Test public void read() throws Exception { AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar"); setUpOpenMock(expectedPath); FileInStream fakeInStream = mock(FileInStream.class); when(fakeInStream.read(any(byte[].class), anyInt(), anyInt())).then((Answer<Integer>) invocationOnMock -> { byte[] myDest = (byte[]) invocationOnMock.getArguments()[0]; for (byte i = 0; i < 4; i++) { myDest[i] = i; } return 4; }); when(mFileSystem.openFile(expectedPath)).thenReturn(fakeInStream); mFileInfo.flags.set(O_RDONLY.intValue()); Runtime r = Runtime.getSystemRuntime(); Pointer ptr = r.getMemoryManager().allocateTemporary(4, true); mFuseFs.open("/foo/bar", mFileInfo); mFuseFs.read("/foo/bar", ptr, 4, 0, mFileInfo); final byte[] dst = new byte[4]; ptr.get(0, dst, 0, 4); final byte[] expected = new byte[] {0, 1, 2, 3}; assertArrayEquals("Source and dst data should be equal", expected, dst); }
@Override public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi), "read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset); }
AlluxioFuseFileSystem extends FuseStubFS { @Override public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi), "read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset); } }
AlluxioFuseFileSystem extends FuseStubFS { @Override public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi), "read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset); } AlluxioFuseFileSystem(FileSystem fs, AlluxioFuseOptions opts, AlluxioConfiguration conf); }
AlluxioFuseFileSystem extends FuseStubFS { @Override public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi), "read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset); } AlluxioFuseFileSystem(FileSystem fs, AlluxioFuseOptions opts, AlluxioConfiguration conf); @Override int chmod(String path, @mode_t long mode); @Override int chown(String path, @uid_t long uid, @gid_t long gid); @Override int create(String path, @mode_t long mode, FuseFileInfo fi); @Override int flush(String path, FuseFileInfo fi); @Override int getattr(String path, FileStat stat); @Override String getFSName(); @Override int mkdir(String path, @mode_t long mode); @Override int open(String path, FuseFileInfo fi); @Override int read(String path, Pointer buf, @size_t long size, @off_t long offset,
      FuseFileInfo fi); @Override int readdir(String path, Pointer buff, FuseFillDir filter,
      @off_t long offset, FuseFileInfo fi); @Override int release(String path, FuseFileInfo fi); @Override int rename(String oldPath, String newPath); @Override int rmdir(String path); @Override int statfs(String path, Statvfs stbuf); @Override int truncate(String path, long size); @Override int unlink(String path); @Override int utimens(String path, Timespec[] timespec); @Override int write(String path, Pointer buf, @size_t long size, @off_t long offset,
                   FuseFileInfo fi); }
AlluxioFuseFileSystem extends FuseStubFS { @Override public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi), "read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset); } AlluxioFuseFileSystem(FileSystem fs, AlluxioFuseOptions opts, AlluxioConfiguration conf); @Override int chmod(String path, @mode_t long mode); @Override int chown(String path, @uid_t long uid, @gid_t long gid); @Override int create(String path, @mode_t long mode, FuseFileInfo fi); @Override int flush(String path, FuseFileInfo fi); @Override int getattr(String path, FileStat stat); @Override String getFSName(); @Override int mkdir(String path, @mode_t long mode); @Override int open(String path, FuseFileInfo fi); @Override int read(String path, Pointer buf, @size_t long size, @off_t long offset,
      FuseFileInfo fi); @Override int readdir(String path, Pointer buff, FuseFillDir filter,
      @off_t long offset, FuseFileInfo fi); @Override int release(String path, FuseFileInfo fi); @Override int rename(String oldPath, String newPath); @Override int rmdir(String path); @Override int statfs(String path, Statvfs stbuf); @Override int truncate(String path, long size); @Override int unlink(String path); @Override int utimens(String path, Timespec[] timespec); @Override int write(String path, Pointer buf, @size_t long size, @off_t long offset,
                   FuseFileInfo fi); @VisibleForTesting
  static final int UNKNOWN_INODES; @VisibleForTesting
  static final int MAX_NAME_LENGTH; @VisibleForTesting
  static final long ID_NOT_SET_VALUE; @VisibleForTesting
  static final long ID_NOT_SET_VALUE_UNSIGNED; }