private ContainerReport ConvertToContainerReport(ContainerHistoryData containerHistory
                                                         , string user)
        {
            // If the container has the aggregated log, add the server root url
            string logUrl = WebAppUtils.GetAggregatedLogURL(serverHttpAddress, containerHistory
                                                            .GetAssignedNode().ToString(), containerHistory.GetContainerId().ToString(), containerHistory
                                                            .GetContainerId().ToString(), user);

            return(ContainerReport.NewInstance(containerHistory.GetContainerId(), containerHistory
                                               .GetAllocatedResource(), containerHistory.GetAssignedNode(), containerHistory.GetPriority
                                                   (), containerHistory.GetStartTime(), containerHistory.GetFinishTime(), containerHistory
                                               .GetDiagnosticsInfo(), logUrl, containerHistory.GetContainerExitStatus(), containerHistory
                                               .GetContainerState(), null));
        }
예제 #2
0
        public virtual ContainerReport CreateContainerReport()
        {
            this.readLock.Lock();
            ContainerReport containerReport = null;

            try
            {
                containerReport = ContainerReport.NewInstance(this.GetContainerId(), this.GetAllocatedResource
                                                                  (), this.GetAllocatedNode(), this.GetAllocatedPriority(), this.GetCreationTime()
                                                              , this.GetFinishTime(), this.GetDiagnosticsInfo(), this.GetLogURL(), this.GetContainerExitStatus
                                                                  (), this.GetContainerState(), this.GetNodeHttpAddress());
            }
            finally
            {
                this.readLock.Unlock();
            }
            return(containerReport);
        }
        private static ContainerReport ConvertToContainerReport(TimelineEntity entity, string
                                                                serverHttpAddress, string user)
        {
            int            allocatedMem             = 0;
            int            allocatedVcore           = 0;
            string         allocatedHost            = null;
            int            allocatedPort            = -1;
            int            allocatedPriority        = 0;
            long           createdTime              = 0;
            long           finishedTime             = 0;
            string         diagnosticsInfo          = null;
            int            exitStatus               = ContainerExitStatus.Invalid;
            ContainerState state                    = null;
            string         nodeHttpAddress          = null;
            IDictionary <string, object> entityInfo = entity.GetOtherInfo();

            if (entityInfo != null)
            {
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedMemoryEntityInfo))
                {
                    allocatedMem = (int)entityInfo[ContainerMetricsConstants.AllocatedMemoryEntityInfo
                                   ];
                }
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedVcoreEntityInfo))
                {
                    allocatedVcore = (int)entityInfo[ContainerMetricsConstants.AllocatedVcoreEntityInfo
                                     ];
                }
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedHostEntityInfo))
                {
                    allocatedHost = entityInfo[ContainerMetricsConstants.AllocatedHostEntityInfo].ToString
                                        ();
                }
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedPortEntityInfo))
                {
                    allocatedPort = (int)entityInfo[ContainerMetricsConstants.AllocatedPortEntityInfo
                                    ];
                }
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedPriorityEntityInfo))
                {
                    allocatedPriority = (int)entityInfo[ContainerMetricsConstants.AllocatedPriorityEntityInfo
                                        ];
                }
                if (entityInfo.Contains(ContainerMetricsConstants.AllocatedHostHttpAddressEntityInfo
                                        ))
                {
                    nodeHttpAddress = (string)entityInfo[ContainerMetricsConstants.AllocatedHostHttpAddressEntityInfo
                                      ];
                }
            }
            IList <TimelineEvent> events = entity.GetEvents();

            if (events != null)
            {
                foreach (TimelineEvent @event in events)
                {
                    if (@event.GetEventType().Equals(ContainerMetricsConstants.CreatedEventType))
                    {
                        createdTime = @event.GetTimestamp();
                    }
                    else
                    {
                        if (@event.GetEventType().Equals(ContainerMetricsConstants.FinishedEventType))
                        {
                            finishedTime = @event.GetTimestamp();
                            IDictionary <string, object> eventInfo = @event.GetEventInfo();
                            if (eventInfo == null)
                            {
                                continue;
                            }
                            if (eventInfo.Contains(ContainerMetricsConstants.DiagnosticsInfoEventInfo))
                            {
                                diagnosticsInfo = eventInfo[ContainerMetricsConstants.DiagnosticsInfoEventInfo].ToString
                                                      ();
                            }
                            if (eventInfo.Contains(ContainerMetricsConstants.ExitStatusEventInfo))
                            {
                                exitStatus = (int)eventInfo[ContainerMetricsConstants.ExitStatusEventInfo];
                            }
                            if (eventInfo.Contains(ContainerMetricsConstants.StateEventInfo))
                            {
                                state = ContainerState.ValueOf(eventInfo[ContainerMetricsConstants.StateEventInfo
                                                               ].ToString());
                            }
                        }
                    }
                }
            }
            NodeId      allocatedNode = NodeId.NewInstance(allocatedHost, allocatedPort);
            ContainerId containerId   = ConverterUtils.ToContainerId(entity.GetEntityId());
            string      logUrl        = WebAppUtils.GetAggregatedLogURL(serverHttpAddress, allocatedNode.
                                                                        ToString(), containerId.ToString(), containerId.ToString(), user);

            return(ContainerReport.NewInstance(ConverterUtils.ToContainerId(entity.GetEntityId
                                                                                ()), Resource.NewInstance(allocatedMem, allocatedVcore), NodeId.NewInstance(allocatedHost
                                                                                                                                                            , allocatedPort), Priority.NewInstance(allocatedPriority), createdTime, finishedTime
                                               , diagnosticsInfo, logUrl, exitStatus, state, nodeHttpAddress));
        }
예제 #4
0
 public virtual ContainerReport CreateFakeContainerReport()
 {
     return(ContainerReport.NewInstance(this.CreateFakeContainerId(), null, NodeId.NewInstance
                                            ("localhost", 0), null, 1000l, 1200l, string.Empty, string.Empty, 0, ContainerState
                                        .Complete, "http://" + NodeId.NewInstance("localhost", 0).ToString()));
 }
예제 #5
0
            private void CreateAppReports()
            {
                ApplicationId     applicationId        = ApplicationId.NewInstance(1234, 5);
                ApplicationReport newApplicationReport = ApplicationReport.NewInstance(applicationId
                                                                                       , ApplicationAttemptId.NewInstance(applicationId, 1), "user", "queue", "appname"
                                                                                       , "host", 124, null, YarnApplicationState.Running, "diagnostics", "url", 0, 0, FinalApplicationStatus
                                                                                       .Succeeded, null, "N/A", 0.53789f, "YARN", null);
                IList <ApplicationReport> applicationReports = new AList <ApplicationReport>();

                applicationReports.AddItem(newApplicationReport);
                IList <ApplicationAttemptReport> appAttempts = new AList <ApplicationAttemptReport>
                                                                   ();
                ApplicationAttemptReport attempt = ApplicationAttemptReport.NewInstance(ApplicationAttemptId
                                                                                        .NewInstance(applicationId, 1), "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState
                                                                                        .Finished, ContainerId.NewContainerId(newApplicationReport.GetCurrentApplicationAttemptId
                                                                                                                                  (), 1));

                appAttempts.AddItem(attempt);
                ApplicationAttemptReport attempt1 = ApplicationAttemptReport.NewInstance(ApplicationAttemptId
                                                                                         .NewInstance(applicationId, 2), "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState
                                                                                         .Finished, ContainerId.NewContainerId(newApplicationReport.GetCurrentApplicationAttemptId
                                                                                                                                   (), 2));

                appAttempts.AddItem(attempt1);
                attempts[applicationId] = appAttempts;
                IList <ContainerReport> containerReports = new AList <ContainerReport>();
                ContainerReport         container        = ContainerReport.NewInstance(ContainerId.NewContainerId
                                                                                           (attempt.GetApplicationAttemptId(), 1), null, NodeId.NewInstance("host", 1234),
                                                                                       Priority.Undefined, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.Complete
                                                                                       , "http://" + NodeId.NewInstance("host", 2345).ToString());

                containerReports.AddItem(container);
                ContainerReport container1 = ContainerReport.NewInstance(ContainerId.NewContainerId
                                                                             (attempt.GetApplicationAttemptId(), 2), null, NodeId.NewInstance("host", 1234),
                                                                         Priority.Undefined, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.Complete
                                                                         , "http://" + NodeId.NewInstance("host", 2345).ToString());

                containerReports.AddItem(container1);
                containers[attempt.GetApplicationAttemptId()] = containerReports;
                ApplicationId     applicationId2        = ApplicationId.NewInstance(1234, 6);
                ApplicationReport newApplicationReport2 = ApplicationReport.NewInstance(applicationId2
                                                                                        , ApplicationAttemptId.NewInstance(applicationId2, 2), "user2", "queue2", "appname2"
                                                                                        , "host2", 125, null, YarnApplicationState.Finished, "diagnostics2", "url2", 2,
                                                                                        2, FinalApplicationStatus.Succeeded, null, "N/A", 0.63789f, "NON-YARN", null);

                applicationReports.AddItem(newApplicationReport2);
                ApplicationId     applicationId3        = ApplicationId.NewInstance(1234, 7);
                ApplicationReport newApplicationReport3 = ApplicationReport.NewInstance(applicationId3
                                                                                        , ApplicationAttemptId.NewInstance(applicationId3, 3), "user3", "queue3", "appname3"
                                                                                        , "host3", 126, null, YarnApplicationState.Running, "diagnostics3", "url3", 3, 3
                                                                                        , FinalApplicationStatus.Succeeded, null, "N/A", 0.73789f, "MAPREDUCE", null);

                applicationReports.AddItem(newApplicationReport3);
                ApplicationId     applicationId4        = ApplicationId.NewInstance(1234, 8);
                ApplicationReport newApplicationReport4 = ApplicationReport.NewInstance(applicationId4
                                                                                        , ApplicationAttemptId.NewInstance(applicationId4, 4), "user4", "queue4", "appname4"
                                                                                        , "host4", 127, null, YarnApplicationState.Failed, "diagnostics4", "url4", 4, 4,
                                                                                        FinalApplicationStatus.Succeeded, null, "N/A", 0.83789f, "NON-MAPREDUCE", null);

                applicationReports.AddItem(newApplicationReport4);
                reports = applicationReports;
            }