/// <exception cref="System.Exception"/> private void WaitForLaunchedState(RMAppAttempt attempt) { int waitCount = 0; while (attempt.GetAppAttemptState() != RMAppAttemptState.Launched && waitCount++ < 20) { Log.Info("Waiting for AppAttempt to reach LAUNCHED state. " + "Current state is " + attempt.GetAppAttemptState()); Sharpen.Thread.Sleep(1000); } NUnit.Framework.Assert.AreEqual(attempt.GetAppAttemptState(), RMAppAttemptState.Launched ); }
// This is to test fetching AM container will be retried, if AM container is // not fetchable since DNS is unavailable causing container token/NMtoken // creation failure. /// <exception cref="System.Exception"/> public virtual void TestAMContainerAllocationWhenDNSUnavailable() { MockRM rm1 = new _MockRM_303(this, conf); rm1.Start(); MockNM nm1 = rm1.RegisterNode("unknownhost:1234", 8000); SecurityUtilTestHelper.SetTokenServiceUseIp(true); RMApp app1 = rm1.SubmitApp(200); RMAppAttempt attempt = app1.GetCurrentAppAttempt(); nm1.NodeHeartbeat(true); // fetching am container will fail, keep retrying 5 times. while (numRetries <= 5) { nm1.NodeHeartbeat(true); Sharpen.Thread.Sleep(1000); NUnit.Framework.Assert.AreEqual(RMAppAttemptState.Scheduled, attempt.GetAppAttemptState ()); System.Console.Out.WriteLine("Waiting for am container to be allocated."); } SecurityUtilTestHelper.SetTokenServiceUseIp(false); rm1.WaitForState(attempt.GetAppAttemptId(), RMAppAttemptState.Allocated); MockRM.LaunchAndRegisterAM(app1, rm1, nm1); }
/// <exception cref="System.Exception"/> public virtual void WaitForState(RMAppAttemptState finalState) { RMApp app = context.GetRMApps()[attemptId.GetApplicationId()]; RMAppAttempt attempt = app.GetRMAppAttempt(attemptId); int timeoutSecs = 0; while (!finalState.Equals(attempt.GetAppAttemptState()) && timeoutSecs++ < 40) { System.Console.Out.WriteLine("AppAttempt : " + attemptId + " State is : " + attempt .GetAppAttemptState() + " Waiting for state : " + finalState); Sharpen.Thread.Sleep(1000); } System.Console.Out.WriteLine("AppAttempt State is : " + attempt.GetAppAttemptState ()); NUnit.Framework.Assert.AreEqual("AppAttempt state is not correct (timedout)", finalState , attempt.GetAppAttemptState()); }
protected override void CreateAttemptHeadRoomTable(HtmlBlock.Block html) { RMAppAttempt attempt = GetRMAppAttempt(); if (attempt != null) { if (!IsApplicationInFinalState(YarnApplicationAttemptState.ValueOf(attempt.GetAppAttemptState ().ToString()))) { RMAppAttemptMetrics metrics = attempt.GetRMAppAttemptMetrics(); Hamlet.DIV <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> pdiv = html.(typeof(InfoBlock )).Div(JQueryUI.InfoWrap); Info("Application Attempt Overview").Clear(); Info("Application Attempt Metrics").("Application Attempt Headroom : ", metrics == null ? "N/A" : metrics.GetApplicationAttemptHeadroom()); pdiv.(); } } }
public virtual void Setup() { // start minicluster conf = new YarnConfiguration(); yarnCluster = new MiniYARNCluster(typeof(TestAMRMClient).FullName, nodeCount, 1, 1); yarnCluster.Init(conf); yarnCluster.Start(); NUnit.Framework.Assert.IsNotNull(yarnCluster); NUnit.Framework.Assert.AreEqual(Service.STATE.Started, yarnCluster.GetServiceState ()); // start rm client yarnClient = (YarnClientImpl)YarnClient.CreateYarnClient(); yarnClient.Init(conf); yarnClient.Start(); NUnit.Framework.Assert.IsNotNull(yarnClient); NUnit.Framework.Assert.AreEqual(Service.STATE.Started, yarnClient.GetServiceState ()); // get node info nodeReports = yarnClient.GetNodeReports(NodeState.Running); // submit new app ApplicationSubmissionContext appContext = yarnClient.CreateApplication().GetApplicationSubmissionContext (); ApplicationId appId = appContext.GetApplicationId(); // set the application name appContext.SetApplicationName("Test"); // Set the priority for the application master Priority pri = Priority.NewInstance(0); appContext.SetPriority(pri); // Set the queue to which this application is to be submitted in the RM appContext.SetQueue("default"); // Set up the container launch context for the application master ContainerLaunchContext amContainer = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <ContainerLaunchContext>(); appContext.SetAMContainerSpec(amContainer); // unmanaged AM appContext.SetUnmanagedAM(true); // Create the request to send to the applications manager SubmitApplicationRequest appRequest = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <SubmitApplicationRequest>(); appRequest.SetApplicationSubmissionContext(appContext); // Submit the application to the applications manager yarnClient.SubmitApplication(appContext); // wait for app to start int iterationsLeft = 30; RMAppAttempt appAttempt = null; while (iterationsLeft > 0) { ApplicationReport appReport = yarnClient.GetApplicationReport(appId); if (appReport.GetYarnApplicationState() == YarnApplicationState.Accepted) { attemptId = appReport.GetCurrentApplicationAttemptId(); appAttempt = yarnCluster.GetResourceManager().GetRMContext().GetRMApps()[attemptId .GetApplicationId()].GetCurrentAppAttempt(); while (true) { if (appAttempt.GetAppAttemptState() == RMAppAttemptState.Launched) { break; } } break; } Sleep(1000); --iterationsLeft; } if (iterationsLeft == 0) { NUnit.Framework.Assert.Fail("Application hasn't bee started"); } // Just dig into the ResourceManager and get the AMRMToken just for the sake // of testing. UserGroupInformation.SetLoginUser(UserGroupInformation.CreateRemoteUser(UserGroupInformation .GetCurrentUser().GetUserName())); UserGroupInformation.GetCurrentUser().AddToken(appAttempt.GetAMRMToken()); //creating an instance NMTokenCase nmTokenCache = new NMTokenCache(); // start am rm client rmClient = (AMRMClientImpl <AMRMClient.ContainerRequest>)AMRMClient.CreateAMRMClient <AMRMClient.ContainerRequest>(); //setting an instance NMTokenCase rmClient.SetNMTokenCache(nmTokenCache); rmClient.Init(conf); rmClient.Start(); NUnit.Framework.Assert.IsNotNull(rmClient); NUnit.Framework.Assert.AreEqual(Service.STATE.Started, rmClient.GetServiceState() ); // start am nm client nmClient = (NMClientImpl)NMClient.CreateNMClient(); //propagating the AMRMClient NMTokenCache instance nmClient.SetNMTokenCache(rmClient.GetNMTokenCache()); nmClient.Init(conf); nmClient.Start(); NUnit.Framework.Assert.IsNotNull(nmClient); NUnit.Framework.Assert.AreEqual(Service.STATE.Started, nmClient.GetServiceState() ); }