Пример #1
0
 /**
  * Returns ACLs for the application. An empty map is returned if no ACLs are found.
  *
  * @return a map of the Application ACLs.
  * @throws IOException
  */
 public Map<ApplicationAccessType, String> getApplicationAcls() throws IOException {
   // TODO Seek directly to the key once a comparator is specified.
   TFile.Reader.Scanner aclScanner = reader.createScanner();
   LogKey key = new LogKey();
   Map<ApplicationAccessType, String> acls = new HashMap<ApplicationAccessType, String>();
   while (!aclScanner.atEnd()) {
     TFile.Reader.Scanner.Entry entry = aclScanner.entry();
     key.readFields(entry.getKeyStream());
     if (key.toString().equals(APPLICATION_ACL_KEY.toString())) {
       DataInputStream valueStream = entry.getValueStream();
       while (true) {
         String appAccessOp = null;
         String aclString = null;
         try {
           appAccessOp = valueStream.readUTF();
         } catch (EOFException e) {
           // Valid end of stream.
           break;
         }
         try {
           aclString = valueStream.readUTF();
         } catch (EOFException e) {
           throw new YarnRuntimeException("Error reading ACLs", e);
         }
         acls.put(ApplicationAccessType.valueOf(appAccessOp), aclString);
       }
     }
     aclScanner.advance();
   }
   return acls;
 }
Пример #2
0
 public LogReader(Configuration conf, Path remoteAppLogFile) throws IOException {
   FileContext fileContext = FileContext.getFileContext(conf);
   this.fsDataIStream = fileContext.open(remoteAppLogFile);
   reader =
       new TFile.Reader(
           this.fsDataIStream, fileContext.getFileStatus(remoteAppLogFile).getLen(), conf);
   this.scanner = reader.createScanner();
 }
Пример #3
0
 /**
  * Returns the owner of the application.
  *
  * @return the application owner.
  * @throws IOException
  */
 public String getApplicationOwner() throws IOException {
   TFile.Reader.Scanner ownerScanner = reader.createScanner();
   LogKey key = new LogKey();
   while (!ownerScanner.atEnd()) {
     TFile.Reader.Scanner.Entry entry = ownerScanner.entry();
     key.readFields(entry.getKeyStream());
     if (key.toString().equals(APPLICATION_OWNER_KEY.toString())) {
       DataInputStream valueStream = entry.getValueStream();
       return valueStream.readUTF();
     }
     ownerScanner.advance();
   }
   return null;
 }