예제 #1
0
		/// <exception cref="System.Exception"/>
		public virtual void TestSlowNM()
		{
			conf = new Configuration();
			int maxAttempts = 1;
			conf.SetInt(MRJobConfig.MapMaxAttempts, maxAttempts);
			conf.SetBoolean(MRJobConfig.JobUbertaskEnable, false);
			// set timeout low for the test
			conf.SetInt("yarn.rpc.nm-command-timeout", 3000);
			conf.Set(YarnConfiguration.IpcRpcImpl, typeof(HadoopYarnProtoRPC).FullName);
			YarnRPC rpc = YarnRPC.Create(conf);
			string bindAddr = "localhost:0";
			IPEndPoint addr = NetUtils.CreateSocketAddr(bindAddr);
			NMTokenSecretManagerInNM tokenSecretManager = new NMTokenSecretManagerInNM();
			MasterKey masterKey = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord<MasterKey>();
			masterKey.SetBytes(ByteBuffer.Wrap(Sharpen.Runtime.GetBytesForString("key")));
			tokenSecretManager.SetMasterKey(masterKey);
			conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "token");
			server = rpc.GetServer(typeof(ContainerManagementProtocol), new TestContainerLauncher.DummyContainerManager
				(this), addr, conf, tokenSecretManager, 1);
			server.Start();
			MRApp app = new TestContainerLauncher.MRAppWithSlowNM(this, tokenSecretManager);
			try
			{
				Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf);
				app.WaitForState(job, JobState.Running);
				IDictionary<TaskId, Task> tasks = job.GetTasks();
				NUnit.Framework.Assert.AreEqual("Num tasks is not correct", 1, tasks.Count);
				Task task = tasks.Values.GetEnumerator().Next();
				app.WaitForState(task, TaskState.Scheduled);
				IDictionary<TaskAttemptId, TaskAttempt> attempts = tasks.Values.GetEnumerator().Next
					().GetAttempts();
				NUnit.Framework.Assert.AreEqual("Num attempts is not correct", maxAttempts, attempts
					.Count);
				TaskAttempt attempt = attempts.Values.GetEnumerator().Next();
				app.WaitForInternalState((TaskAttemptImpl)attempt, TaskAttemptStateInternal.Assigned
					);
				app.WaitForState(job, JobState.Failed);
				string diagnostics = attempt.GetDiagnostics().ToString();
				Log.Info("attempt.getDiagnostics: " + diagnostics);
				NUnit.Framework.Assert.IsTrue(diagnostics.Contains("Container launch failed for "
					 + "container_0_0000_01_000000 : "));
				NUnit.Framework.Assert.IsTrue(diagnostics.Contains("java.net.SocketTimeoutException: 3000 millis timeout while waiting for channel"
					));
			}
			finally
			{
				server.Stop();
				app.Stop();
			}
		}
예제 #2
0
        public virtual void VerifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype, string
                                                     id, string state, string type, string rack, string nodeHttpAddress, string diagnostics
                                                     , string assignedContainerId, long startTime, long finishTime, long elapsedTime,
                                                     float progress)
        {
            TaskAttemptId attid     = ta.GetID();
            string        attemptId = MRApps.ToString(attid);

            WebServicesTestUtils.CheckStringMatch("id", attemptId, id);
            WebServicesTestUtils.CheckStringMatch("type", ttype.ToString(), type);
            WebServicesTestUtils.CheckStringMatch("state", ta.GetState().ToString(), state);
            WebServicesTestUtils.CheckStringMatch("rack", ta.GetNodeRackName(), rack);
            WebServicesTestUtils.CheckStringMatch("nodeHttpAddress", ta.GetNodeHttpAddress(),
                                                  nodeHttpAddress);
            string         expectDiag      = string.Empty;
            IList <string> diagnosticsList = ta.GetDiagnostics();

            if (diagnosticsList != null && !diagnostics.IsEmpty())
            {
                StringBuilder b = new StringBuilder();
                foreach (string diag in diagnosticsList)
                {
                    b.Append(diag);
                }
                expectDiag = b.ToString();
            }
            WebServicesTestUtils.CheckStringMatch("diagnostics", expectDiag, diagnostics);
            WebServicesTestUtils.CheckStringMatch("assignedContainerId", ConverterUtils.ToString
                                                      (ta.GetAssignedContainerID()), assignedContainerId);
            NUnit.Framework.Assert.AreEqual("startTime wrong", ta.GetLaunchTime(), startTime);
            NUnit.Framework.Assert.AreEqual("finishTime wrong", ta.GetFinishTime(), finishTime
                                            );
            NUnit.Framework.Assert.AreEqual("elapsedTime wrong", finishTime - startTime, elapsedTime
                                            );
            NUnit.Framework.Assert.AreEqual("progress wrong", ta.GetProgress() * 100, progress
                                            , 1e-3f);
        }