예제 #1
0
            public virtual ICollection <Path> DoContainerLogAggregation(AggregatedLogFormat.LogWriter
                                                                        writer, bool appFinished)
            {
                AppLogAggregatorImpl.Log.Info("Uploading logs for container " + this.containerId
                                              + ". Current good log dirs are " + StringUtils.Join(",", this._enclosing.dirsHandler
                                                                                                  .GetLogDirsForRead()));
                AggregatedLogFormat.LogKey logKey = new AggregatedLogFormat.LogKey(this.containerId
                                                                                   );
                AggregatedLogFormat.LogValue logValue = new AggregatedLogFormat.LogValue(this._enclosing
                                                                                         .dirsHandler.GetLogDirsForRead(), this.containerId, this._enclosing.userUgi.GetShortUserName
                                                                                             (), this._enclosing.logAggregationContext, this.uploadedFileMeta, appFinished);
                try
                {
                    writer.Append(logKey, logValue);
                }
                catch (Exception e)
                {
                    AppLogAggregatorImpl.Log.Error("Couldn't upload logs for " + this.containerId + ". Skipping this container."
                                                   , e);
                    return(new HashSet <Path>());
                }
                Sharpen.Collections.AddAll(this.uploadedFileMeta, logValue.GetCurrentUpLoadedFileMeta
                                               ());
                // if any of the previous uploaded logs have been deleted,
                // we need to remove them from alreadyUploadedLogs
                IEnumerable <string> mask = Iterables.Filter(this.uploadedFileMeta, new _Predicate_581
                                                                 (logValue));

                this.uploadedFileMeta = Sets.NewHashSet(mask);
                return(logValue.GetCurrentUpLoadedFilesPath());
            }
예제 #2
0
        /// <exception cref="System.Exception"/>
        private static void UploadContainerLogIntoRemoteDir(UserGroupInformation ugi, Configuration
                                                            configuration, IList <string> rootLogDirs, NodeId nodeId, ContainerId containerId
                                                            , Path appDir, FileSystem fs)
        {
            Path path = new Path(appDir, LogAggregationUtils.GetNodeString(nodeId) + Runtime.
                                 CurrentTimeMillis());

            AggregatedLogFormat.LogWriter writer = new AggregatedLogFormat.LogWriter(configuration
                                                                                     , path, ugi);
            writer.WriteApplicationOwner(ugi.GetUserName());
            IDictionary <ApplicationAccessType, string> appAcls = new Dictionary <ApplicationAccessType
                                                                                  , string>();

            appAcls[ApplicationAccessType.ViewApp] = ugi.GetUserName();
            writer.WriteApplicationACLs(appAcls);
            writer.Append(new AggregatedLogFormat.LogKey(containerId), new AggregatedLogFormat.LogValue
                              (rootLogDirs, containerId, UserGroupInformation.GetCurrentUser().GetShortUserName
                                  ()));
            writer.Close();
        }