protected internal virtual ContainerManagementProtocol GetContainerManagementProtocolProxy (YarnRPC rpc, Org.Apache.Hadoop.Yarn.Api.Records.Token nmToken, NodeId nodeId, string user) { ContainerManagementProtocol proxy; UserGroupInformation ugi = UserGroupInformation.CreateRemoteUser(user); IPEndPoint addr = NetUtils.CreateSocketAddr(nodeId.GetHost(), nodeId.GetPort()); if (nmToken != null) { ugi.AddToken(ConverterUtils.ConvertFromYarn(nmToken, addr)); } proxy = NMProxy.CreateNMProxy <ContainerManagementProtocol>(conf, ugi, rpc, addr); return(proxy); }
// Protected. For tests. protected internal virtual ContainerManagementProtocol GetContainerMgrProxy(ContainerId containerId) { NodeId node = masterContainer.GetNodeId(); IPEndPoint containerManagerConnectAddress = NetUtils.CreateSocketAddrForHost(node .GetHost(), node.GetPort()); YarnRPC rpc = GetYarnRPC(); UserGroupInformation currentUser = UserGroupInformation.CreateRemoteUser(containerId .GetApplicationAttemptId().ToString()); string user = rmContext.GetRMApps()[containerId.GetApplicationAttemptId().GetApplicationId ()].GetUser(); Token token = rmContext.GetNMTokenSecretManager().CreateNMToken(containerId.GetApplicationAttemptId (), node, user); currentUser.AddToken(ConverterUtils.ConvertFromYarn(token, containerManagerConnectAddress )); return(NMProxy.CreateNMProxy <ContainerManagementProtocol>(conf, currentUser, rpc, containerManagerConnectAddress)); }
/// <exception cref="System.Exception"/> public virtual void TestNMProxyRetry() { containerManager.Start(); containerManager.SetBlockNewContainerRequests(false); StartContainersRequest allRequests = Records.NewRecord <StartContainersRequest>(); ApplicationId appId = ApplicationId.NewInstance(1, 1); ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(appId, 1); Token nmToken = context.GetNMTokenSecretManager().CreateNMToken(attemptId, context .GetNodeId(), user); IPEndPoint address = conf.GetSocketAddr(YarnConfiguration.NmBindHost, YarnConfiguration .NmAddress, YarnConfiguration.DefaultNmAddress, YarnConfiguration.DefaultNmPort); Org.Apache.Hadoop.Security.Token.Token <NMTokenIdentifier> token = ConverterUtils. ConvertFromYarn(nmToken, SecurityUtil.BuildTokenService(address)); UserGroupInformation ugi = UserGroupInformation.CreateRemoteUser(user); ugi.AddToken(token); ContainerManagementProtocol proxy = NMProxy.CreateNMProxy <ContainerManagementProtocol >(conf, ugi, YarnRPC.Create(conf), address); retryCount = 0; shouldThrowNMNotYetReadyException = false; proxy.StartContainers(allRequests); NUnit.Framework.Assert.AreEqual(5, retryCount); retryCount = 0; shouldThrowNMNotYetReadyException = false; proxy.StopContainers(Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <StopContainersRequest >()); NUnit.Framework.Assert.AreEqual(5, retryCount); retryCount = 0; shouldThrowNMNotYetReadyException = false; proxy.GetContainerStatuses(Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <GetContainerStatusesRequest >()); NUnit.Framework.Assert.AreEqual(5, retryCount); retryCount = 0; shouldThrowNMNotYetReadyException = true; proxy.StartContainers(allRequests); NUnit.Framework.Assert.AreEqual(5, retryCount); }
protected internal virtual ContainerManagementProtocol NewProxy(YarnRPC rpc, string containerManagerBindAddr, ContainerId containerId, Token token) { if (token == null) { throw new SecretManager.InvalidToken("No NMToken sent for " + containerManagerBindAddr ); } IPEndPoint cmAddr = NetUtils.CreateSocketAddr(containerManagerBindAddr); ContainerManagementProtocolProxy.Log.Info("Opening proxy : " + containerManagerBindAddr ); // the user in createRemoteUser in this context has to be ContainerID UserGroupInformation user = UserGroupInformation.CreateRemoteUser(containerId.GetApplicationAttemptId ().ToString()); Org.Apache.Hadoop.Security.Token.Token <NMTokenIdentifier> nmToken = ConverterUtils .ConvertFromYarn(token, cmAddr); user.AddToken(nmToken); return(NMProxy.CreateNMProxy <ContainerManagementProtocol>(this._enclosing.conf, user , rpc, cmAddr)); }