コード例 #1
0
 /**
  * list subfiles
  *
  * @param hdfsPath !null path probably exists
  * @return !null list of enclused file names - emptu if file of not exists
  */
 @Override
 public String[] ls(final String hdfsPath) {
   if (isRunningAsUser()) {
     return super.ls(hdfsPath);
   }
   final FileSystem fs = getDFS();
   try {
     FileStatus[] statuses = fs.listStatus(new Path(hdfsPath));
     if (statuses == null) return new String[0];
     List<String> holder = new ArrayList<String>();
     for (int i = 0; i < statuses.length; i++) {
       FileStatus statuse = statuses[i];
       String s = statuse.getPath().getName();
       holder.add(s);
     }
     String[] ret = new String[holder.size()];
     holder.toArray(ret);
     return ret;
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
 static FsPermission checkPermission(FileSystem fs, String path, FsPermission expected)
     throws IOException {
   FileStatus s = fs.getFileStatus(new Path(path));
   LOG.info(
       s.getPath()
           + ": "
           + s.isDirectory()
           + " "
           + s.getPermission()
           + ":"
           + s.getOwner()
           + ":"
           + s.getGroup());
   if (expected != null) {
     assertEquals(expected, s.getPermission());
     assertEquals(expected.toShort(), s.getPermission().toShort());
   }
   return s.getPermission();
 }