Пример #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
 /**
  * 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;
 }
Пример #3
0
    /**
     * Get a ContainerLogsReader to read the logs for the specified container.
     *
     * @param containerId
     * @return object to read the container's logs or null if the logs could not be found
     * @throws IOException
     */
    @Private
    public ContainerLogsReader getContainerLogsReader(ContainerId containerId) throws IOException {
      ContainerLogsReader logReader = null;

      final LogKey containerKey = new LogKey(containerId);
      LogKey key = new LogKey();
      DataInputStream valueStream = next(key);
      while (valueStream != null && !key.equals(containerKey)) {
        valueStream = next(key);
      }

      if (valueStream != null) {
        logReader = new ContainerLogsReader(valueStream);
      }

      return logReader;
    }
Пример #4
0
 public void append(LogKey logKey, LogValue logValue) throws IOException {
   DataOutputStream out = this.writer.prepareAppendKey(-1);
   logKey.write(out);
   out.close();
   out = this.writer.prepareAppendValue(-1);
   logValue.write(out);
   out.close();
 }
Пример #5
0
 public void writeApplicationOwner(String user) throws IOException {
   DataOutputStream out = this.writer.prepareAppendKey(-1);
   APPLICATION_OWNER_KEY.write(out);
   out.close();
   out = this.writer.prepareAppendValue(-1);
   out.writeUTF(user);
   out.close();
 }
Пример #6
0
 private void writeVersion() throws IOException {
   DataOutputStream out = this.writer.prepareAppendKey(-1);
   VERSION_KEY.write(out);
   out.close();
   out = this.writer.prepareAppendValue(-1);
   out.writeInt(VERSION);
   out.close();
 }
Пример #7
0
 /**
  * Read the next key and return the value-stream.
  *
  * @param key
  * @return the valueStream if there are more keys or null otherwise.
  * @throws IOException
  */
 public DataInputStream next(LogKey key) throws IOException {
   if (!this.atBeginning) {
     this.scanner.advance();
   } else {
     this.atBeginning = false;
   }
   if (this.scanner.atEnd()) {
     return null;
   }
   TFile.Reader.Scanner.Entry entry = this.scanner.entry();
   key.readFields(entry.getKeyStream());
   // Skip META keys
   if (RESERVED_KEYS.containsKey(key.toString())) {
     return next(key);
   }
   DataInputStream valueStream = entry.getValueStream();
   return valueStream;
 }
Пример #8
0
 public void writeApplicationACLs(Map<ApplicationAccessType, String> appAcls)
     throws IOException {
   DataOutputStream out = this.writer.prepareAppendKey(-1);
   APPLICATION_ACL_KEY.write(out);
   out.close();
   out = this.writer.prepareAppendValue(-1);
   for (Entry<ApplicationAccessType, String> entry : appAcls.entrySet()) {
     out.writeUTF(entry.getKey().toString());
     out.writeUTF(entry.getValue());
   }
   out.close();
 }
Пример #9
0
 static {
   RESERVED_KEYS = new HashMap<String, AggregatedLogFormat.LogKey>();
   RESERVED_KEYS.put(APPLICATION_ACL_KEY.toString(), APPLICATION_ACL_KEY);
   RESERVED_KEYS.put(APPLICATION_OWNER_KEY.toString(), APPLICATION_OWNER_KEY);
   RESERVED_KEYS.put(VERSION_KEY.toString(), VERSION_KEY);
 }