@Test public void listStatus() throws Exception { FileInfo fileInfo1 = new FileInfo() .setLastModificationTimeMs(111L) .setLastAccessTimeMs(123L) .setFolder(false) .setOwner("user1") .setGroup("group1") .setMode(00755); FileInfo fileInfo2 = new FileInfo() .setLastModificationTimeMs(222L) .setLastAccessTimeMs(234L) .setFolder(true) .setOwner("user2") .setGroup("group2") .setMode(00644); Path path = new Path("/dir"); alluxio.client.file.FileSystem alluxioFs = mock(alluxio.client.file.FileSystem.class); when(alluxioFs.listStatus(new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)))) .thenReturn(Lists.newArrayList(new URIStatus(fileInfo1), new URIStatus(fileInfo2))); FileSystem alluxioHadoopFs = new FileSystem(alluxioFs); FileStatus[] fileStatuses = alluxioHadoopFs.listStatus(path); assertFileInfoEqualsFileStatus(fileInfo1, fileStatuses[0]); assertFileInfoEqualsFileStatus(fileInfo2, fileStatuses[1]); alluxioHadoopFs.close(); }
@Override public FileStatus[] listStatus(Path path) throws IOException { LOG.debug("listStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = getAlluxioPath(path); List<URIStatus> statuses; try { statuses = mFileSystem.listStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(getAlluxioPath(path).toString()); } catch (AlluxioException e) { throw new IOException(e); } FileStatus[] ret = new FileStatus[statuses.size()]; for (int k = 0; k < statuses.size(); k++) { URIStatus status = statuses.get(k); ret[k] = new FileStatus(status.getLength(), status.isFolder(), getReplica(status), status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getLastAccessTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), getFsPath(mAlluxioHeader, status)); } return ret; }
AbstractFileSystem extends org.apache.hadoop.fs.FileSystem { @Override public FileStatus[] listStatus(Path path) throws IOException { LOG.debug("listStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = getAlluxioPath(path); List<URIStatus> statuses; try { statuses = mFileSystem.listStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(getAlluxioPath(path).toString()); } catch (AlluxioException e) { throw new IOException(e); } FileStatus[] ret = new FileStatus[statuses.size()]; for (int k = 0; k < statuses.size(); k++) { URIStatus status = statuses.get(k); ret[k] = new FileStatus(status.getLength(), status.isFolder(), getReplica(status), status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getLastAccessTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), getFsPath(mAlluxioHeader, status)); } return ret; } }
AbstractFileSystem extends org.apache.hadoop.fs.FileSystem { @Override public FileStatus[] listStatus(Path path) throws IOException { LOG.debug("listStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = getAlluxioPath(path); List<URIStatus> statuses; try { statuses = mFileSystem.listStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(getAlluxioPath(path).toString()); } catch (AlluxioException e) { throw new IOException(e); } FileStatus[] ret = new FileStatus[statuses.size()]; for (int k = 0; k < statuses.size(); k++) { URIStatus status = statuses.get(k); ret[k] = new FileStatus(status.getLength(), status.isFolder(), getReplica(status), status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getLastAccessTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), getFsPath(mAlluxioHeader, status)); } return ret; } protected  AbstractFileSystem(FileSystem fileSystem); protected  AbstractFileSystem(); }
AbstractFileSystem extends org.apache.hadoop.fs.FileSystem { @Override public FileStatus[] listStatus(Path path) throws IOException { LOG.debug("listStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = getAlluxioPath(path); List<URIStatus> statuses; try { statuses = mFileSystem.listStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(getAlluxioPath(path).toString()); } catch (AlluxioException e) { throw new IOException(e); } FileStatus[] ret = new FileStatus[statuses.size()]; for (int k = 0; k < statuses.size(); k++) { URIStatus status = statuses.get(k); ret[k] = new FileStatus(status.getLength(), status.isFolder(), getReplica(status), status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getLastAccessTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), getFsPath(mAlluxioHeader, status)); } return ret; } protected  AbstractFileSystem(FileSystem fileSystem); protected  AbstractFileSystem(); @Override FSDataOutputStream append(Path path, int bufferSize, Progressable progress); @Override void close(); @Override FSDataOutputStream create(Path path, FsPermission permission, boolean overwrite,
      int bufferSize, short replication, long blockSize, Progressable progress); @Override @Deprecated FSDataOutputStream createNonRecursive(Path path, FsPermission permission,
      boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress); @Override @Deprecated boolean delete(Path path); @Override boolean delete(Path path, boolean recursive); @Override long getDefaultBlockSize(); @Nullable @Override BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len); @Override short getDefaultReplication(); @Override boolean setReplication(Path path, short replication); @Override FileStatus getFileStatus(Path path); @Override void setOwner(Path path, final String username, final String groupname); @Override void setPermission(Path path, FsPermission permission); abstract String getScheme(); @Override URI getUri(); @Override Path getWorkingDirectory(); @Override synchronized void initialize(URI uri, org.apache.hadoop.conf.Configuration conf); @VisibleForTesting synchronized void initialize(URI uri, org.apache.hadoop.conf.Configuration conf,
      @Nullable AlluxioConfiguration alluxioConfiguration); @Override FileStatus[] listStatus(Path path); @Override boolean mkdirs(Path path, FsPermission permission); @Override FSDataInputStream open(Path path, int bufferSize); @Override boolean rename(Path src, Path dst); @Override void setWorkingDirectory(Path path); }
AbstractFileSystem extends org.apache.hadoop.fs.FileSystem { @Override public FileStatus[] listStatus(Path path) throws IOException { LOG.debug("listStatus({})", path); if (mStatistics != null) { mStatistics.incrementReadOps(1); } AlluxioURI uri = getAlluxioPath(path); List<URIStatus> statuses; try { statuses = mFileSystem.listStatus(uri); } catch (FileDoesNotExistException e) { throw new FileNotFoundException(getAlluxioPath(path).toString()); } catch (AlluxioException e) { throw new IOException(e); } FileStatus[] ret = new FileStatus[statuses.size()]; for (int k = 0; k < statuses.size(); k++) { URIStatus status = statuses.get(k); ret[k] = new FileStatus(status.getLength(), status.isFolder(), getReplica(status), status.getBlockSizeBytes(), status.getLastModificationTimeMs(), status.getLastAccessTimeMs(), new FsPermission((short) status.getMode()), status.getOwner(), status.getGroup(), getFsPath(mAlluxioHeader, status)); } return ret; } protected  AbstractFileSystem(FileSystem fileSystem); protected  AbstractFileSystem(); @Override FSDataOutputStream append(Path path, int bufferSize, Progressable progress); @Override void close(); @Override FSDataOutputStream create(Path path, FsPermission permission, boolean overwrite,
      int bufferSize, short replication, long blockSize, Progressable progress); @Override @Deprecated FSDataOutputStream createNonRecursive(Path path, FsPermission permission,
      boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress); @Override @Deprecated boolean delete(Path path); @Override boolean delete(Path path, boolean recursive); @Override long getDefaultBlockSize(); @Nullable @Override BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len); @Override short getDefaultReplication(); @Override boolean setReplication(Path path, short replication); @Override FileStatus getFileStatus(Path path); @Override void setOwner(Path path, final String username, final String groupname); @Override void setPermission(Path path, FsPermission permission); abstract String getScheme(); @Override URI getUri(); @Override Path getWorkingDirectory(); @Override synchronized void initialize(URI uri, org.apache.hadoop.conf.Configuration conf); @VisibleForTesting synchronized void initialize(URI uri, org.apache.hadoop.conf.Configuration conf,
      @Nullable AlluxioConfiguration alluxioConfiguration); @Override FileStatus[] listStatus(Path path); @Override boolean mkdirs(Path path, FsPermission permission); @Override FSDataInputStream open(Path path, int bufferSize); @Override boolean rename(Path src, Path dst); @Override void setWorkingDirectory(Path path); static final String FIRST_COM_PATH; }