/// <summary> /// Create a new Connection to the RM/Application History Server /// to fetch Application reports. /// </summary> /// <param name="conf">the conf to use to know where the RM is.</param> public AppReportFetcher(Configuration conf) { if (conf.GetBoolean(YarnConfiguration.ApplicationHistoryEnabled, YarnConfiguration .DefaultApplicationHistoryEnabled)) { isAHSEnabled = true; } this.conf = conf; try { applicationsManager = ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(conf ); if (isAHSEnabled) { historyManager = GetAHSProxy(conf); } else { this.historyManager = null; } } catch (IOException e) { throw new YarnRuntimeException(e); } }
/// <exception cref="System.IO.IOException"/> private static ApplicationClientProtocol GetRmClient <_T0>(Org.Apache.Hadoop.Security.Token.Token <_T0> token, Configuration conf) where _T0 : TokenIdentifier { string[] services = token.GetService().ToString().Split(","); foreach (string service in services) { IPEndPoint addr = NetUtils.CreateSocketAddr(service); if (localSecretManager != null) { // return null if it's our token if (localServiceAddress.Address.IsAnyLocalAddress()) { if (NetUtils.IsLocalAddress(addr.Address) && addr.Port == localServiceAddress.Port) { return(null); } } else { if (addr.Equals(localServiceAddress)) { return(null); } } } } return(ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(conf)); }
/// <exception cref="System.IO.IOException"/> protected internal virtual ResourceManagerAdministrationProtocol CreateAdminProtocol () { // Get the current configuration YarnConfiguration conf = new YarnConfiguration(GetConf()); return(ClientRMProxy.CreateRMProxy <ResourceManagerAdministrationProtocol>(conf)); }
public virtual Text GetRMDelegationTokenService() { if (rmDTService == null) { rmDTService = ClientRMProxy.GetRMDelegationTokenService(conf); } return(rmDTService); }
/// <exception cref="System.IO.IOException"/> private void UpdateAMRMToken(Token token) { Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> amrmToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(((byte[])token.GetIdentifier().Array()), ((byte[])token.GetPassword ().Array()), new Text(token.GetKind()), new Text(token.GetService())); UserGroupInformation currentUGI = UserGroupInformation.GetCurrentUser(); currentUGI.AddToken(amrmToken); amrmToken.SetService(ClientRMProxy.GetAMRMTokenService(GetConfig())); }
protected internal virtual ApplicationMasterProtocol CreateSchedulerProxy() { Configuration conf = GetConfig(); try { return(ClientRMProxy.CreateRMProxy <ApplicationMasterProtocol>(conf)); } catch (IOException e) { throw new YarnRuntimeException(e); } }
/// <exception cref="System.IO.IOException"/> private void UpdateAMRMToken(Token token) { Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> amrmToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(((byte[])token.GetIdentifier().Array()), ((byte[])token.GetPassword ().Array()), new Text(token.GetKind()), new Text(token.GetService())); // Preserve the token service sent by the RM when adding the token // to ensure we replace the previous token setup by the RM. // Afterwards we can update the service address for the RPC layer. UserGroupInformation currentUGI = UserGroupInformation.GetCurrentUser(); currentUGI.AddToken(amrmToken); amrmToken.SetService(ClientRMProxy.GetAMRMTokenService(GetConfig())); }
/// <exception cref="System.Exception"/> protected override void ServiceStart() { YarnConfiguration conf = new YarnConfiguration(GetConfig()); try { rmClient = ClientRMProxy.CreateRMProxy <ApplicationMasterProtocol>(conf); } catch (IOException e) { throw new YarnRuntimeException(e); } base.ServiceStart(); }
// Expected // provide main method so this class can act as AM /// <exception cref="System.Exception"/> public static void Main(string[] args) { if (args[0].Equals("success")) { ApplicationMasterProtocol client = ClientRMProxy.CreateRMProxy <ApplicationMasterProtocol >(conf); client.RegisterApplicationMaster(RegisterApplicationMasterRequest.NewInstance(NetUtils .GetHostname(), -1, string.Empty)); Sharpen.Thread.Sleep(1000); FinishApplicationMasterResponse resp = client.FinishApplicationMaster(FinishApplicationMasterRequest .NewInstance(FinalApplicationStatus.Succeeded, "success", null)); NUnit.Framework.Assert.IsTrue(resp.GetIsUnregistered()); System.Environment.Exit(0); } else { System.Environment.Exit(1); } }
/// <exception cref="System.Exception"/> protected override void ServiceStart() { try { rmClient = ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(GetConfig()); if (historyServiceEnabled) { historyClient.Start(); } if (timelineServiceEnabled) { timelineClient.Start(); } } catch (IOException e) { throw new YarnRuntimeException(e); } base.ServiceStart(); }
public virtual void TestAMRMTokenUpdate() { Configuration conf = new Configuration(); ApplicationAttemptId attemptId = ApplicationAttemptId.NewInstance(ApplicationId.NewInstance (1, 1), 1); AMRMTokenIdentifier oldTokenId = new AMRMTokenIdentifier(attemptId, 1); AMRMTokenIdentifier newTokenId = new AMRMTokenIdentifier(attemptId, 2); Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> oldToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(oldTokenId.GetBytes(), Sharpen.Runtime.GetBytesForString("oldpassword" ), oldTokenId.GetKind(), new Text()); Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier> newToken = new Org.Apache.Hadoop.Security.Token.Token <AMRMTokenIdentifier>(newTokenId.GetBytes(), Sharpen.Runtime.GetBytesForString("newpassword" ), newTokenId.GetKind(), new Text()); TestLocalContainerAllocator.MockScheduler scheduler = new TestLocalContainerAllocator.MockScheduler (); scheduler.amToken = newToken; LocalContainerAllocator lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator (scheduler); lca.Init(conf); lca.Start(); UserGroupInformation testUgi = UserGroupInformation.CreateUserForTesting("someuser" , new string[0]); testUgi.AddToken(oldToken); testUgi.DoAs(new _PrivilegedExceptionAction_144(lca)); lca.Close(); // verify there is only one AMRM token in the UGI and it matches the // updated token from the RM int tokenCount = 0; Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> ugiToken = null; foreach (Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> token in testUgi .GetTokens()) { if (AMRMTokenIdentifier.KindName.Equals(token.GetKind())) { ugiToken = token; ++tokenCount; } } NUnit.Framework.Assert.AreEqual("too many AMRM tokens", 1, tokenCount); Assert.AssertArrayEquals("token identifier not updated", newToken.GetIdentifier() , ugiToken.GetIdentifier()); Assert.AssertArrayEquals("token password not updated", newToken.GetPassword(), ugiToken .GetPassword()); NUnit.Framework.Assert.AreEqual("AMRM token service not updated", new Text(ClientRMProxy .GetAMRMTokenService(conf)), ugiToken.GetService()); }
protected internal virtual ApplicationClientProtocol CreatRMClient() { return(ClientRMProxy.CreateRMProxy <ApplicationClientProtocol>(GetConfig())); }