Пример #1
0
            /// <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);
            }
Пример #2
0
 /// <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);
 }
Пример #3
0
            /// <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);
            }
Пример #4
0
        public virtual int DumpAContainerLogs(string containerIdStr, AggregatedLogFormat.LogReader
                                              reader, TextWriter @out, long logUploadedTime)
        {
            DataInputStream valueStream;

            AggregatedLogFormat.LogKey key = new AggregatedLogFormat.LogKey();
            valueStream = reader.Next(key);
            while (valueStream != null && !key.ToString().Equals(containerIdStr))
            {
                // Next container
                key         = new AggregatedLogFormat.LogKey();
                valueStream = reader.Next(key);
            }
            if (valueStream == null)
            {
                return(-1);
            }
            bool foundContainerLogs = false;

            while (true)
            {
                try
                {
                    AggregatedLogFormat.LogReader.ReadAContainerLogsForALogType(valueStream, @out, logUploadedTime
                                                                                );
                    foundContainerLogs = true;
                }
                catch (EOFException)
                {
                    break;
                }
            }
            if (foundContainerLogs)
            {
                return(0);
            }
            return(-1);
        }