/// <exception cref="System.Exception"/> private LogAggregationContext GetLogAggregationContextFromContainerToken(MockRM rm1 , MockNM nm1, LogAggregationContext logAggregationContext) { RMApp app2 = rm1.SubmitApp(200, logAggregationContext); MockAM am2 = MockRM.LaunchAndRegisterAM(app2, rm1, nm1); nm1.NodeHeartbeat(true); // request a container. am2.Allocate("127.0.0.1", 512, 1, new AList <ContainerId>()); ContainerId containerId = ContainerId.NewContainerId(am2.GetApplicationAttemptId( ), 2); rm1.WaitForState(nm1, containerId, RMContainerState.Allocated); // acquire the container. IList <Container> containers = am2.Allocate(new AList <ResourceRequest>(), new AList <ContainerId>()).GetAllocatedContainers(); NUnit.Framework.Assert.AreEqual(containerId, containers[0].GetId()); // container token is generated. NUnit.Framework.Assert.IsNotNull(containers[0].GetContainerToken()); ContainerTokenIdentifier token = BuilderUtils.NewContainerTokenIdentifier(containers [0].GetContainerToken()); return(token.GetLogAggregationContext()); }
public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier, string message) { YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto.Builder builder = YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto.NewBuilder(); ContainerIdPBImpl containerID = (ContainerIdPBImpl)identifier.GetContainerID(); if (containerID != null) { builder.SetContainerId(containerID.GetProto()); } builder.SetNmHostAddr(identifier.GetNmHostAddress()); builder.SetAppSubmitter(identifier.GetApplicationSubmitter()); ResourcePBImpl resource = (ResourcePBImpl)identifier.GetResource(); if (resource != null) { builder.SetResource(resource.GetProto()); } builder.SetExpiryTimeStamp(identifier.GetExpiryTimeStamp()); builder.SetMasterKeyId(identifier.GetMasterKeyId()); builder.SetRmIdentifier(identifier.GetRMIdentifier()); PriorityPBImpl priority = (PriorityPBImpl)identifier.GetPriority(); if (priority != null) { builder.SetPriority(priority.GetProto()); } builder.SetCreationTime(identifier.GetCreationTime()); builder.SetMessage(message); LogAggregationContextPBImpl logAggregationContext = (LogAggregationContextPBImpl) identifier.GetLogAggregationContext(); if (logAggregationContext != null) { builder.SetLogAggregationContext(logAggregationContext.GetProto()); } proto = ((YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto)builder .Build()); }