AbstractFileSystemService implements FileSystemService { private FileStatus[] collectFileStatuses(FileSystem fileSystem, Path path, Pattern pattern) throws IOException { List<FileStatus> result = new ArrayList<FileStatus>(1000); collectFileStatuses(fileSystem, path, pattern, result); return result.toArray(new FileStatus[result.size()]); } AbstractFileSystemService(JobClientsMap jobClientsMap); @Override String[] globPaths(String username, List<String> pathPatterns); @Override FileStatus[] globFiles(String username, List<String> pathPatterns); @Override String getQualifiedPath(String username, String path); @Override OutputStream addFile(String username, String path); @Override boolean removeFile(String username, String path); @Override boolean removeDirectory(String username, String path); @Override boolean pathExists(String path, String username); @Override InputStream openFile(String username, String path); @Deprecated FileStatus[] globFileStatuses(List<String> pathPatterns, Configuration conf); RemoteIterator<LocatedFileStatus> globFileStatusIterator(List<String> pathPatterns, Configuration conf, FileSystemPathIteratorFactory.FileStatusFilter extraFilter, boolean withDirs, boolean doLocate); Path makeQualified(FileSystem fileSystem, String child); FileSystem getFileSystem(String username); static String getCommonPathPrefix(List<String> strings); static String getUserGlob(String userName, String dirPath); static String getUserPath(String userName, String dirPath); JobClientsMap getJobClientsMap();  }
@Ignore @Test public void testCollectFileStatuses() throws Exception { System.setProperty("calvalus.accesscontrol.external", "true"); String user = "boe"; JobConf jobConf = new JobConf(); UserGroupInformation remoteUser = UserGroupInformation.createRemoteUser(user); FileStatus[] fileStatuses = remoteUser.doAs((PrivilegedExceptionAction<FileStatus[]>) () -> { jobConf.set("calvalus.accesscontrol.external", "true"); JobClientsMap jobClientsMap = new JobClientsMap(jobConf); jobClientsMap.getJobClient(user); FileSystem fileSystem = jobClientsMap.getFileSystem(user); HdfsFileSystemService fsService = new HdfsFileSystemService(jobClientsMap); List<String> patterns = new ArrayList<>(); patterns.add("/calvalus/testdir/t.*"); return fsService.globFileStatuses(patterns, jobConf); }); assertEquals("number of entries", 2, fileStatuses.length); }