private MasterKey GetMasterKey() { MasterKey key = recordFactory.NewRecordInstance <MasterKey>(); key.SetBytes(ByteBuffer.Allocate(0)); key.SetKeyId(1); return(key); }
/// <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(); } }
public virtual void TestRoundTrip() { RegisterNodeManagerResponse resp = recordFactory.NewRecordInstance <RegisterNodeManagerResponse >(); byte[] b = new byte[] { 0, 1, 2, 3, 4, 5 }; MasterKey containerTokenMK = recordFactory.NewRecordInstance <MasterKey>(); containerTokenMK.SetKeyId(54321); containerTokenMK.SetBytes(ByteBuffer.Wrap(b)); resp.SetContainerTokenMasterKey(containerTokenMK); MasterKey nmTokenMK = recordFactory.NewRecordInstance <MasterKey>(); nmTokenMK.SetKeyId(12345); nmTokenMK.SetBytes(ByteBuffer.Wrap(b)); resp.SetNMTokenMasterKey(nmTokenMK); resp.SetNodeAction(NodeAction.Normal); NUnit.Framework.Assert.AreEqual(NodeAction.Normal, resp.GetNodeAction()); // Verifying containerTokenMasterKey NUnit.Framework.Assert.IsNotNull(resp.GetContainerTokenMasterKey()); NUnit.Framework.Assert.AreEqual(54321, resp.GetContainerTokenMasterKey().GetKeyId ()); Assert.AssertArrayEquals(b, ((byte[])resp.GetContainerTokenMasterKey().GetBytes() .Array())); RegisterNodeManagerResponse respCopy = SerDe(resp); NUnit.Framework.Assert.AreEqual(NodeAction.Normal, respCopy.GetNodeAction()); NUnit.Framework.Assert.IsNotNull(respCopy.GetContainerTokenMasterKey()); NUnit.Framework.Assert.AreEqual(54321, respCopy.GetContainerTokenMasterKey().GetKeyId ()); Assert.AssertArrayEquals(b, ((byte[])respCopy.GetContainerTokenMasterKey().GetBytes ().Array())); // Verifying nmTokenMasterKey NUnit.Framework.Assert.IsNotNull(resp.GetNMTokenMasterKey()); NUnit.Framework.Assert.AreEqual(12345, resp.GetNMTokenMasterKey().GetKeyId()); Assert.AssertArrayEquals(b, ((byte[])resp.GetNMTokenMasterKey().GetBytes().Array( ))); respCopy = SerDe(resp); NUnit.Framework.Assert.AreEqual(NodeAction.Normal, respCopy.GetNodeAction()); NUnit.Framework.Assert.IsNotNull(respCopy.GetNMTokenMasterKey()); NUnit.Framework.Assert.AreEqual(12345, respCopy.GetNMTokenMasterKey().GetKeyId()); Assert.AssertArrayEquals(b, ((byte[])respCopy.GetNMTokenMasterKey().GetBytes().Array ())); }