/// <summary>Read the next key and return the value-stream.</summary> /// <param name="key"/> /// <returns>the valueStream if there are more keys or null otherwise.</returns> /// <exception cref="System.IO.IOException"/> public virtual DataInputStream Next(AggregatedLogFormat.LogKey key) { 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 (ReservedKeys.Contains(key.ToString())) { return(Next(key)); } DataInputStream valueStream = entry.GetValueStream(); return(valueStream); }
/// <exception cref="System.IO.IOException"/> public virtual FileSystemApplicationHistoryStore.HistoryFileReader.Entry Next() { TFile.Reader.Scanner.Entry entry = this.scanner.Entry(); DataInputStream dis = entry.GetKeyStream(); FileSystemApplicationHistoryStore.HistoryDataKey key = new FileSystemApplicationHistoryStore.HistoryDataKey (); key.ReadFields(dis); dis = entry.GetValueStream(); byte[] value = new byte[entry.GetValueLength()]; dis.Read(value); this.scanner.Advance(); return(new FileSystemApplicationHistoryStore.HistoryFileReader.Entry(this, key, value )); }
/// <summary>Returns the owner of the application.</summary> /// <returns>the application owner.</returns> /// <exception cref="System.IO.IOException"/> public virtual string GetApplicationOwner() { TFile.Reader.Scanner ownerScanner = reader.CreateScanner(); AggregatedLogFormat.LogKey key = new AggregatedLogFormat.LogKey(); while (!ownerScanner.AtEnd()) { TFile.Reader.Scanner.Entry entry = ownerScanner.Entry(); key.ReadFields(entry.GetKeyStream()); if (key.ToString().Equals(ApplicationOwnerKey.ToString())) { DataInputStream valueStream = entry.GetValueStream(); return(valueStream.ReadUTF()); } ownerScanner.Advance(); } return(null); }
/// <summary>Returns ACLs for the application.</summary> /// <remarks> /// Returns ACLs for the application. An empty map is returned if no ACLs are /// found. /// </remarks> /// <returns>a map of the Application ACLs.</returns> /// <exception cref="System.IO.IOException"/> public virtual IDictionary <ApplicationAccessType, string> GetApplicationAcls() { // TODO Seek directly to the key once a comparator is specified. TFile.Reader.Scanner aclScanner = reader.CreateScanner(); AggregatedLogFormat.LogKey key = new AggregatedLogFormat.LogKey(); IDictionary <ApplicationAccessType, string> acls = new Dictionary <ApplicationAccessType , string>(); while (!aclScanner.AtEnd()) { TFile.Reader.Scanner.Entry entry = aclScanner.Entry(); key.ReadFields(entry.GetKeyStream()); if (key.ToString().Equals(ApplicationAclKey.ToString())) { DataInputStream valueStream = entry.GetValueStream(); while (true) { string appAccessOp = null; string aclString = null; try { appAccessOp = valueStream.ReadUTF(); } catch (EOFException) { // Valid end of stream. break; } try { aclString = valueStream.ReadUTF(); } catch (EOFException e) { throw new YarnRuntimeException("Error reading ACLs", e); } acls[ApplicationAccessType.ValueOf(appAccessOp)] = aclString; } } aclScanner.Advance(); } return(acls); }