コード例 #1
0
        public static ClientRMService MockClientRMService(RMContext rmContext)
        {
            ClientRMService           clientRMService = Org.Mockito.Mockito.Mock <ClientRMService>();
            IList <ApplicationReport> appReports      = new AList <ApplicationReport>();

            foreach (RMApp app in rmContext.GetRMApps().Values)
            {
                ApplicationReport appReport = ApplicationReport.NewInstance(app.GetApplicationId(
                                                                                ), (ApplicationAttemptId)null, app.GetUser(), app.GetQueue(), app.GetName(), (string
                                                                                                                                                              )null, 0, (Token)null, app.CreateApplicationState(), app.GetDiagnostics().ToString
                                                                                (), (string)null, app.GetStartTime(), app.GetFinishTime(), app.GetFinalApplicationStatus
                                                                                (), (ApplicationResourceUsageReport)null, app.GetTrackingUrl(), app.GetProgress(
                                                                                ), app.GetApplicationType(), (Token)null);
                appReports.AddItem(appReport);
            }
            GetApplicationsResponse response = Org.Mockito.Mockito.Mock <GetApplicationsResponse
                                                                         >();

            Org.Mockito.Mockito.When(response.GetApplicationList()).ThenReturn(appReports);
            try
            {
                Org.Mockito.Mockito.When(clientRMService.GetApplications(Matchers.Any <GetApplicationsRequest
                                                                                       >())).ThenReturn(response);
            }
            catch (YarnException)
            {
                NUnit.Framework.Assert.Fail("Exception is not expteced.");
            }
            return(clientRMService);
        }
コード例 #2
0
        private ApplicationReport GetRunningApplicationReport(string host, int port)
        {
            ApplicationId        appId     = ApplicationId.NewInstance(1234, 5);
            ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(appId, 0);

            return(ApplicationReport.NewInstance(appId, attemptId, "user", "queue", "appname"
                                                 , host, port, null, YarnApplicationState.Running, "diagnostics", "url", 0, 0, FinalApplicationStatus
                                                 .Undefined, null, "N/A", 0.0f, YarnConfiguration.DefaultApplicationType, null));
        }
コード例 #3
0
        private ApplicationReport GetFinishedApplicationReport()
        {
            ApplicationId        appId     = ApplicationId.NewInstance(1234, 5);
            ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(appId, 0);

            return(ApplicationReport.NewInstance(appId, attemptId, "user", "queue", "appname"
                                                 , "host", 124, null, YarnApplicationState.Finished, "diagnostics", "url", 0, 0,
                                                 FinalApplicationStatus.Succeeded, null, "N/A", 0.0f, YarnConfiguration.DefaultApplicationType
                                                 , null));
        }
コード例 #4
0
            public virtual ApplicationReport CreateFakeAppReport()
            {
                ApplicationId        appId     = ApplicationId.NewInstance(1000l, 1);
                ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(appId, 1);
                // create a fake application report
                ApplicationReport report = ApplicationReport.NewInstance(appId, attemptId, "fakeUser"
                                                                         , "fakeQueue", "fakeApplicationName", "localhost", 0, null, YarnApplicationState
                                                                         .Finished, "fake an application report", string.Empty, 1000l, 1200l, FinalApplicationStatus
                                                                         .Failed, null, string.Empty, 50f, "fakeApplicationType", null);

                return(report);
            }
コード例 #5
0
        private ApplicationReport GetUnknownApplicationReport()
        {
            ApplicationId        unknownAppId     = recordFactory.NewRecordInstance <ApplicationId>();
            ApplicationAttemptId unknownAttemptId = recordFactory.NewRecordInstance <ApplicationAttemptId
                                                                                     >();

            // Setting AppState to NEW and finalStatus to UNDEFINED as they are never
            // used for a non running job
            return(ApplicationReport.NewInstance(unknownAppId, unknownAttemptId, "N/A", "N/A"
                                                 , "N/A", "N/A", 0, null, YarnApplicationState.New, "N/A", "N/A", 0, 0, FinalApplicationStatus
                                                 .Undefined, null, "N/A", 0.0f, YarnConfiguration.DefaultApplicationType, null));
        }
コード例 #6
0
        protected internal static ApplicationReport CreateApplicationReport(int appIdInt,
                                                                            int appAttemptIdInt, long timestamp)
        {
            ApplicationId        appId        = ApplicationId.NewInstance(timestamp, appIdInt);
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, appAttemptIdInt
                                                                                 );
            ApplicationReport appReport = ApplicationReport.NewInstance(appId, appAttemptId,
                                                                        "user", "queue", "appname", "host", 124, null, YarnApplicationState.Finished, "diagnostics"
                                                                        , "url", 0, 0, FinalApplicationStatus.Succeeded, null, "N/A", 0.53789f, YarnConfiguration
                                                                        .DefaultApplicationType, null);

            return(appReport);
        }
コード例 #7
0
ファイル: MockAsm.cs プロジェクト: orf53975/hadoop.net
            public override ApplicationReport CreateAndGetApplicationReport(string clientUserName
                                                                            , bool allowAccess)
            {
                ApplicationResourceUsageReport usageReport = ApplicationResourceUsageReport.NewInstance
                                                                 (0, 0, null, null, null, 0, 0);
                ApplicationReport report = ApplicationReport.NewInstance(this.GetApplicationId(),
                                                                         appAttemptId, this.GetUser(), this.GetQueue(), this.GetName(), null, 0, null, null
                                                                         , this.GetDiagnostics().ToString(), this.GetTrackingUrl(), this.GetStartTime(),
                                                                         this.GetFinishTime(), this.GetFinalApplicationStatus(), usageReport, null, this.
                                                                         GetProgress(), type, null);

                return(report);
            }
コード例 #8
0
        /// <exception cref="System.IO.IOException"/>
        private ApplicationReport ConvertToApplicationReport(ApplicationHistoryData appHistory
                                                             )
        {
            ApplicationAttemptId currentApplicationAttemptId = null;
            string trackingUrl = Unavailable;
            string host        = Unavailable;
            int    rpcPort     = -1;
            ApplicationAttemptHistoryData lastAttempt = GetLastAttempt(appHistory.GetApplicationId
                                                                           ());

            if (lastAttempt != null)
            {
                currentApplicationAttemptId = lastAttempt.GetApplicationAttemptId();
                trackingUrl = lastAttempt.GetTrackingURL();
                host        = lastAttempt.GetHost();
                rpcPort     = lastAttempt.GetRPCPort();
            }
            return(ApplicationReport.NewInstance(appHistory.GetApplicationId(), currentApplicationAttemptId
                                                 , appHistory.GetUser(), appHistory.GetQueue(), appHistory.GetApplicationName(),
                                                 host, rpcPort, null, appHistory.GetYarnApplicationState(), appHistory.GetDiagnosticsInfo
                                                     (), trackingUrl, appHistory.GetStartTime(), appHistory.GetFinishTime(), appHistory
                                                 .GetFinalApplicationStatus(), null, string.Empty, 100, appHistory.GetApplicationType
                                                     (), null));
        }
コード例 #9
0
 /// <exception cref="System.Exception"/>
 public virtual void TestJobKill()
 {
     clientDelegate = Org.Mockito.Mockito.Mock <ClientServiceDelegate>();
     Org.Mockito.Mockito.When(clientDelegate.GetJobStatus(Matchers.Any <JobID>())).ThenReturn
         (new JobStatus(jobId, 0f, 0f, 0f, 0f, JobStatus.State.Prep, JobPriority.High, "tmp"
                        , "tmp", "tmp", "tmp"));
     Org.Mockito.Mockito.When(clientDelegate.KillJob(Matchers.Any <JobID>())).ThenReturn
         (true);
     Org.Mockito.Mockito.DoAnswer(new _Answer_177(this)).When(clientCache).GetClient(Matchers.Any
                                                                                     <JobID>());
     yarnRunner.KillJob(jobId);
     Org.Mockito.Mockito.Verify(resourceMgrDelegate).KillApplication(appId);
     Org.Mockito.Mockito.When(clientDelegate.GetJobStatus(Matchers.Any <JobID>())).ThenReturn
         (new JobStatus(jobId, 0f, 0f, 0f, 0f, JobStatus.State.Running, JobPriority.High,
                        "tmp", "tmp", "tmp", "tmp"));
     yarnRunner.KillJob(jobId);
     Org.Mockito.Mockito.Verify(clientDelegate).KillJob(jobId);
     Org.Mockito.Mockito.When(clientDelegate.GetJobStatus(Matchers.Any <JobID>())).ThenReturn
         (null);
     Org.Mockito.Mockito.When(resourceMgrDelegate.GetApplicationReport(Matchers.Any <ApplicationId
                                                                                     >())).ThenReturn(ApplicationReport.NewInstance(appId, null, "tmp", "tmp", "tmp",
                                                                                                                                    "tmp", 0, null, YarnApplicationState.Finished, "tmp", "tmp", 0l, 0l, FinalApplicationStatus
                                                                                                                                    .Succeeded, null, null, 0f, "tmp", null));
     yarnRunner.KillJob(jobId);
     Org.Mockito.Mockito.Verify(clientDelegate).KillJob(jobId);
 }
コード例 #10
0
        private static ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt ConvertToApplicationReport
            (TimelineEntity entity, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField
            field)
        {
            string user         = null;
            string queue        = null;
            string name         = null;
            string type         = null;
            long   createdTime  = 0;
            long   finishedTime = 0;
            ApplicationAttemptId latestApplicationAttemptId = null;
            string diagnosticsInfo = null;
            FinalApplicationStatus         finalStatus              = FinalApplicationStatus.Undefined;
            YarnApplicationState           state                    = null;
            ApplicationResourceUsageReport appResources             = null;
            IDictionary <ApplicationAccessType, string> appViewACLs = new Dictionary <ApplicationAccessType
                                                                                      , string>();
            IDictionary <string, object> entityInfo = entity.GetOtherInfo();

            if (entityInfo != null)
            {
                if (entityInfo.Contains(ApplicationMetricsConstants.UserEntityInfo))
                {
                    user = entityInfo[ApplicationMetricsConstants.UserEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.AppViewAclsEntityInfo))
                {
                    string appViewACLsStr = entityInfo[ApplicationMetricsConstants.AppViewAclsEntityInfo
                                            ].ToString();
                    if (appViewACLsStr.Length > 0)
                    {
                        appViewACLs[ApplicationAccessType.ViewApp] = appViewACLsStr;
                    }
                }
                if (field == ApplicationHistoryManagerOnTimelineStore.ApplicationReportField.UserAndAcls)
                {
                    return(new ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt(ApplicationReport
                                                                                             .NewInstance(ConverterUtils.ToApplicationId(entity.GetEntityId()), latestApplicationAttemptId
                                                                                                          , user, queue, name, null, -1, null, state, diagnosticsInfo, null, createdTime,
                                                                                                          finishedTime, finalStatus, null, null, 1.0F, type, null), appViewACLs));
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.QueueEntityInfo))
                {
                    queue = entityInfo[ApplicationMetricsConstants.QueueEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.NameEntityInfo))
                {
                    name = entityInfo[ApplicationMetricsConstants.NameEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.TypeEntityInfo))
                {
                    type = entityInfo[ApplicationMetricsConstants.TypeEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.AppCpuMetrics))
                {
                    long vcoreSeconds = long.Parse(entityInfo[ApplicationMetricsConstants.AppCpuMetrics
                                                   ].ToString());
                    long memorySeconds = long.Parse(entityInfo[ApplicationMetricsConstants.AppMemMetrics
                                                    ].ToString());
                    appResources = ApplicationResourceUsageReport.NewInstance(0, 0, null, null, null,
                                                                              memorySeconds, vcoreSeconds);
                }
            }
            IList <TimelineEvent> events = entity.GetEvents();

            if (events != null)
            {
                foreach (TimelineEvent @event in events)
                {
                    if (@event.GetEventType().Equals(ApplicationMetricsConstants.CreatedEventType))
                    {
                        createdTime = @event.GetTimestamp();
                    }
                    else
                    {
                        if (@event.GetEventType().Equals(ApplicationMetricsConstants.FinishedEventType))
                        {
                            finishedTime = @event.GetTimestamp();
                            IDictionary <string, object> eventInfo = @event.GetEventInfo();
                            if (eventInfo == null)
                            {
                                continue;
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.LatestAppAttemptEventInfo))
                            {
                                latestApplicationAttemptId = ConverterUtils.ToApplicationAttemptId(eventInfo[ApplicationMetricsConstants
                                                                                                             .LatestAppAttemptEventInfo].ToString());
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.DiagnosticsInfoEventInfo))
                            {
                                diagnosticsInfo = eventInfo[ApplicationMetricsConstants.DiagnosticsInfoEventInfo]
                                                  .ToString();
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.FinalStatusEventInfo))
                            {
                                finalStatus = FinalApplicationStatus.ValueOf(eventInfo[ApplicationMetricsConstants
                                                                                       .FinalStatusEventInfo].ToString());
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.StateEventInfo))
                            {
                                state = YarnApplicationState.ValueOf(eventInfo[ApplicationMetricsConstants.StateEventInfo
                                                                     ].ToString());
                            }
                        }
                    }
                }
            }
            return(new ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt(ApplicationReport
                                                                                     .NewInstance(ConverterUtils.ToApplicationId(entity.GetEntityId()), latestApplicationAttemptId
                                                                                                  , user, queue, name, null, -1, null, state, diagnosticsInfo, null, createdTime,
                                                                                                  finishedTime, finalStatus, appResources, null, 1.0F, type, null), appViewACLs));
        }
コード例 #11
0
ファイル: TestAHSClient.cs プロジェクト: orf53975/hadoop.net
            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;
            }