Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
0
  @Override
  public void initialize(InputSplit split, TaskAttemptContext context)
      throws IOException, InterruptedException {
    FileSplit fileSplit = (FileSplit) split;
    LOG.info("Initializing TFileRecordReader : " + fileSplit.getPath().toString());
    start = fileSplit.getStart();
    end = start + fileSplit.getLength();

    FileSystem fs = fileSplit.getPath().getFileSystem(context.getConfiguration());
    splitPath = fileSplit.getPath();
    fin = fs.open(splitPath);
    reader =
        new TFile.Reader(fin, fs.getFileStatus(splitPath).getLen(), context.getConfiguration());
    scanner = reader.createScannerByByteRange(start, fileSplit.getLength());
  }