コード例 #1
0
 /// <exception cref="System.IO.IOException"/>
 public virtual ApplicationHistoryData GetApplication(ApplicationId appId)
 {
     FileSystemApplicationHistoryStore.HistoryFileReader hfReader = GetHistoryFileReader
                                                                        (appId);
     try
     {
         bool readStartData  = false;
         bool readFinishData = false;
         ApplicationHistoryData historyData = ApplicationHistoryData.NewInstance(appId, null
                                                                                 , null, null, null, long.MinValue, long.MinValue, long.MaxValue, null, FinalApplicationStatus
                                                                                 .Undefined, null);
         while ((!readStartData || !readFinishData) && hfReader.HasNext())
         {
             FileSystemApplicationHistoryStore.HistoryFileReader.Entry entry = hfReader.Next();
             if (entry.key.id.Equals(appId.ToString()))
             {
                 if (entry.key.suffix.Equals(StartDataSuffix))
                 {
                     ApplicationStartData startData = ParseApplicationStartData(entry.value);
                     MergeApplicationHistoryData(historyData, startData);
                     readStartData = true;
                 }
                 else
                 {
                     if (entry.key.suffix.Equals(FinishDataSuffix))
                     {
                         ApplicationFinishData finishData = ParseApplicationFinishData(entry.value);
                         MergeApplicationHistoryData(historyData, finishData);
                         readFinishData = true;
                     }
                 }
             }
         }
         if (!readStartData && !readFinishData)
         {
             return(null);
         }
         if (!readStartData)
         {
             Log.Warn("Start information is missing for application " + appId);
         }
         if (!readFinishData)
         {
             Log.Warn("Finish information is missing for application " + appId);
         }
         Log.Info("Completed reading history information of application " + appId);
         return(historyData);
     }
     catch (IOException e)
     {
         Log.Error("Error when reading history file of application " + appId, e);
         throw;
     }
     finally
     {
         hfReader.Close();
     }
 }
コード例 #2
0
 /// <exception cref="System.IO.IOException"/>
 public virtual ContainerHistoryData GetContainer(ContainerId containerId)
 {
     FileSystemApplicationHistoryStore.HistoryFileReader hfReader = GetHistoryFileReader
                                                                        (containerId.GetApplicationAttemptId().GetApplicationId());
     try
     {
         bool readStartData  = false;
         bool readFinishData = false;
         ContainerHistoryData historyData = ContainerHistoryData.NewInstance(containerId,
                                                                             null, null, null, long.MinValue, long.MaxValue, null, int.MaxValue, null);
         while ((!readStartData || !readFinishData) && hfReader.HasNext())
         {
             FileSystemApplicationHistoryStore.HistoryFileReader.Entry entry = hfReader.Next();
             if (entry.key.id.Equals(containerId.ToString()))
             {
                 if (entry.key.suffix.Equals(StartDataSuffix))
                 {
                     ContainerStartData startData = ParseContainerStartData(entry.value);
                     MergeContainerHistoryData(historyData, startData);
                     readStartData = true;
                 }
                 else
                 {
                     if (entry.key.suffix.Equals(FinishDataSuffix))
                     {
                         ContainerFinishData finishData = ParseContainerFinishData(entry.value);
                         MergeContainerHistoryData(historyData, finishData);
                         readFinishData = true;
                     }
                 }
             }
         }
         if (!readStartData && !readFinishData)
         {
             return(null);
         }
         if (!readStartData)
         {
             Log.Warn("Start information is missing for container " + containerId);
         }
         if (!readFinishData)
         {
             Log.Warn("Finish information is missing for container " + containerId);
         }
         Log.Info("Completed reading history information of container " + containerId);
         return(historyData);
     }
     catch (IOException e)
     {
         Log.Error("Error when reading history file of container " + containerId, e);
         throw;
     }
     finally
     {
         hfReader.Close();
     }
 }
コード例 #3
0
        /// <exception cref="System.IO.IOException"/>
        public virtual IDictionary <ApplicationAttemptId, ApplicationAttemptHistoryData> GetApplicationAttempts
            (ApplicationId appId)
        {
            IDictionary <ApplicationAttemptId, ApplicationAttemptHistoryData> historyDataMap =
                new Dictionary <ApplicationAttemptId, ApplicationAttemptHistoryData>();

            FileSystemApplicationHistoryStore.HistoryFileReader hfReader = GetHistoryFileReader
                                                                               (appId);
            try
            {
                while (hfReader.HasNext())
                {
                    FileSystemApplicationHistoryStore.HistoryFileReader.Entry entry = hfReader.Next();
                    if (entry.key.id.StartsWith(ConverterUtils.ApplicationAttemptPrefix))
                    {
                        ApplicationAttemptId appAttemptId = ConverterUtils.ToApplicationAttemptId(entry.key
                                                                                                  .id);
                        if (appAttemptId.GetApplicationId().Equals(appId))
                        {
                            ApplicationAttemptHistoryData historyData = historyDataMap[appAttemptId];
                            if (historyData == null)
                            {
                                historyData = ApplicationAttemptHistoryData.NewInstance(appAttemptId, null, -1, null
                                                                                        , null, null, FinalApplicationStatus.Undefined, null);
                                historyDataMap[appAttemptId] = historyData;
                            }
                            if (entry.key.suffix.Equals(StartDataSuffix))
                            {
                                MergeApplicationAttemptHistoryData(historyData, ParseApplicationAttemptStartData(
                                                                       entry.value));
                            }
                            else
                            {
                                if (entry.key.suffix.Equals(FinishDataSuffix))
                                {
                                    MergeApplicationAttemptHistoryData(historyData, ParseApplicationAttemptFinishData
                                                                           (entry.value));
                                }
                            }
                        }
                    }
                }
                Log.Info("Completed reading history information of all application" + " attempts of application "
                         + appId);
            }
            catch (IOException)
            {
                Log.Info("Error when reading history information of some application" + " attempts of application "
                         + appId);
            }
            finally
            {
                hfReader.Close();
            }
            return(historyDataMap);
        }
コード例 #4
0
        /// <exception cref="System.IO.IOException"/>
        public virtual IDictionary <ContainerId, ContainerHistoryData> GetContainers(ApplicationAttemptId
                                                                                     appAttemptId)
        {
            IDictionary <ContainerId, ContainerHistoryData> historyDataMap = new Dictionary <ContainerId
                                                                                             , ContainerHistoryData>();

            FileSystemApplicationHistoryStore.HistoryFileReader hfReader = GetHistoryFileReader
                                                                               (appAttemptId.GetApplicationId());
            try
            {
                while (hfReader.HasNext())
                {
                    FileSystemApplicationHistoryStore.HistoryFileReader.Entry entry = hfReader.Next();
                    if (entry.key.id.StartsWith(ConverterUtils.ContainerPrefix))
                    {
                        ContainerId containerId = ConverterUtils.ToContainerId(entry.key.id);
                        if (containerId.GetApplicationAttemptId().Equals(appAttemptId))
                        {
                            ContainerHistoryData historyData = historyDataMap[containerId];
                            if (historyData == null)
                            {
                                historyData = ContainerHistoryData.NewInstance(containerId, null, null, null, long.MinValue
                                                                               , long.MaxValue, null, int.MaxValue, null);
                                historyDataMap[containerId] = historyData;
                            }
                            if (entry.key.suffix.Equals(StartDataSuffix))
                            {
                                MergeContainerHistoryData(historyData, ParseContainerStartData(entry.value));
                            }
                            else
                            {
                                if (entry.key.suffix.Equals(FinishDataSuffix))
                                {
                                    MergeContainerHistoryData(historyData, ParseContainerFinishData(entry.value));
                                }
                            }
                        }
                    }
                }
                Log.Info("Completed reading history information of all conatiners" + " of application attempt "
                         + appAttemptId);
            }
            catch (IOException)
            {
                Log.Info("Error when reading history information of some containers" + " of application attempt "
                         + appAttemptId);
            }
            finally
            {
                hfReader.Close();
            }
            return(historyDataMap);
        }