/// <exception cref="Javax.Servlet.ServletException"/> protected internal virtual string FindRedirectUrl() { string addr; if (proxyUriBases.Count == 1) { // external proxy or not RM HA addr = proxyUriBases.Values.GetEnumerator().Next(); } else { // RM HA YarnConfiguration conf = new YarnConfiguration(); string activeRMId = RMHAUtils.FindActiveRMHAId(conf); string addressPropertyPrefix = YarnConfiguration.UseHttps(conf) ? YarnConfiguration .RmWebappHttpsAddress : YarnConfiguration.RmWebappAddress; string host = conf.Get(HAUtil.AddSuffix(addressPropertyPrefix, activeRMId)); addr = proxyUriBases[host]; } if (addr == null) { throw new ServletException("Could not determine the proxy server for redirection" ); } return(addr); }
public static string GetResolvedRemoteRMWebAppURLWithoutScheme(Configuration conf , HttpConfig.Policy httpPolicy) { IPEndPoint address = null; string rmId = null; if (HAUtil.IsHAEnabled(conf)) { // If HA enabled, pick one of the RM-IDs and rely on redirect to go to // the Active RM rmId = (string)Sharpen.Collections.ToArray(HAUtil.GetRMHAIds(conf))[0]; } if (httpPolicy == HttpConfig.Policy.HttpsOnly) { address = conf.GetSocketAddr(rmId == null ? YarnConfiguration.RmWebappHttpsAddress : HAUtil.AddSuffix(YarnConfiguration.RmWebappHttpsAddress, rmId), YarnConfiguration .DefaultRmWebappHttpsAddress, YarnConfiguration.DefaultRmWebappHttpsPort); } else { address = conf.GetSocketAddr(rmId == null ? YarnConfiguration.RmWebappAddress : HAUtil .AddSuffix(YarnConfiguration.RmWebappAddress, rmId), YarnConfiguration.DefaultRmWebappAddress , YarnConfiguration.DefaultRmWebappPort); } return(GetResolvedAddress(address)); }
public virtual void TestGetRMDelegationTokenService() { string defaultRMAddress = YarnConfiguration.DefaultRmAddress; YarnConfiguration conf = new YarnConfiguration(); // HA is not enabled Text tokenService = ClientRMProxy.GetRMDelegationTokenService(conf); string[] services = tokenService.ToString().Split(","); NUnit.Framework.Assert.AreEqual(1, services.Length); foreach (string service in services) { NUnit.Framework.Assert.IsTrue("Incorrect token service name", service.Contains(defaultRMAddress )); } // HA is enabled conf.SetBoolean(YarnConfiguration.RmHaEnabled, true); conf.Set(YarnConfiguration.RmHaIds, "rm1,rm2"); conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm1"), "0.0.0.0"); conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, "rm2"), "0.0.0.0"); tokenService = ClientRMProxy.GetRMDelegationTokenService(conf); services = tokenService.ToString().Split(","); NUnit.Framework.Assert.AreEqual(2, services.Length); foreach (string service_1 in services) { NUnit.Framework.Assert.IsTrue("Incorrect token service name", service_1.Contains( defaultRMAddress)); } }
private void SetHARMConfigurationWithEphemeralPorts(int index, Configuration conf ) { string hostname = Org.Apache.Hadoop.Yarn.Server.MiniYARNCluster.GetHostname(); foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(conf)) { conf.Set(HAUtil.AddSuffix(confKey, rmIds[index]), hostname + ":0"); } }
public virtual void SetUp() { configuration = new Configuration(); UserGroupInformation.SetConfiguration(configuration); configuration.SetBoolean(YarnConfiguration.RmHaEnabled, true); configuration.Set(YarnConfiguration.RmHaIds, Rm1NodeId + "," + Rm2NodeId); foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(configuration )) { configuration.Set(HAUtil.AddSuffix(confKey, Rm1NodeId), Rm1Address); configuration.Set(HAUtil.AddSuffix(confKey, Rm2NodeId), Rm2Address); configuration.Set(HAUtil.AddSuffix(confKey, Rm3NodeId), Rm3Address); } // Enable webapp to test web-services also configuration.SetBoolean(MockRM.EnableWebapp, true); configuration.SetBoolean(YarnConfiguration.YarnAclEnable, true); ClusterMetrics.Destroy(); QueueMetrics.ClearQueueMetrics(); DefaultMetricsSystem.Shutdown(); }
private Configuration CreateHARMConf(string rmIds, string rmId, int adminPort) { Configuration conf = new YarnConfiguration(); conf.SetBoolean(YarnConfiguration.RmHaEnabled, true); conf.Set(YarnConfiguration.RmHaIds, rmIds); conf.SetBoolean(YarnConfiguration.RecoveryEnabled, true); conf.Set(YarnConfiguration.RmStore, typeof(ZKRMStateStore).FullName); conf.Set(YarnConfiguration.RmZkAddress, hostPort); conf.SetInt(YarnConfiguration.RmZkTimeoutMs, ZkTimeoutMs); conf.Set(YarnConfiguration.RmHaId, rmId); conf.Set(YarnConfiguration.RmWebappAddress, "localhost:0"); foreach (string rpcAddress in YarnConfiguration.GetServiceAddressConfKeys(conf)) { foreach (string id in HAUtil.GetRMHAIds(conf)) { conf.Set(HAUtil.AddSuffix(rpcAddress, id), "localhost:0"); } } conf.Set(HAUtil.AddSuffix(YarnConfiguration.RmAdminAddress, rmId), "localhost:" + adminPort); return(conf); }
public virtual void Setup() { configuration.SetBoolean(YarnConfiguration.RmHaEnabled, true); configuration.Set(YarnConfiguration.RmHaIds, "rm1,rm2"); configuration.SetBoolean(YarnConfiguration.RecoveryEnabled, true); configuration.Set(YarnConfiguration.RmStore, typeof(ZKRMStateStore).FullName); configuration.Set(YarnConfiguration.RmZkAddress, hostPort); configuration.SetInt(YarnConfiguration.RmZkTimeoutMs, ZkTimeoutMs); configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); configuration.Set(YarnConfiguration.RmClusterId, "test-yarn-cluster"); int @base = 100; foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(configuration )) { configuration.Set(HAUtil.AddSuffix(confKey, "rm1"), "0.0.0.0:" + (@base + 20)); configuration.Set(HAUtil.AddSuffix(confKey, "rm2"), "0.0.0.0:" + (@base + 40)); @base = @base * 2; } confForRM1 = new Configuration(configuration); confForRM1.Set(YarnConfiguration.RmHaId, "rm1"); confForRM2 = new Configuration(configuration); confForRM2.Set(YarnConfiguration.RmHaId, "rm2"); }
private void SetConfForRM(string rmId, string prefix, string value) { conf.Set(HAUtil.AddSuffix(prefix, rmId), value); }
public virtual void InnerTestHAWithRMHostName(bool includeBindHost) { //this is run two times, with and without a bind host configured if (includeBindHost) { configuration.Set(YarnConfiguration.RmBindHost, "9.9.9.9"); } //test if both RM_HOSTBANE_{rm_id} and RM_RPCADDRESS_{rm_id} are set //We should only read rpc addresses from RM_RPCADDRESS_{rm_id} configuration configuration.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, Rm1NodeId), "1.1.1.1" ); configuration.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, Rm2NodeId), "0.0.0.0" ); configuration.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, Rm3NodeId), "2.2.2.2" ); try { Configuration conf = new YarnConfiguration(configuration); rm = new MockRM(conf); rm.Init(conf); foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(conf)) { NUnit.Framework.Assert.AreEqual("RPC address not set for " + confKey, Rm1Address, conf.Get(HAUtil.AddSuffix(confKey, Rm1NodeId))); NUnit.Framework.Assert.AreEqual("RPC address not set for " + confKey, Rm2Address, conf.Get(HAUtil.AddSuffix(confKey, Rm2NodeId))); NUnit.Framework.Assert.AreEqual("RPC address not set for " + confKey, Rm3Address, conf.Get(HAUtil.AddSuffix(confKey, Rm3NodeId))); if (includeBindHost) { NUnit.Framework.Assert.AreEqual("Web address misconfigured WITH bind-host", Sharpen.Runtime.Substring (rm.webAppAddress, 0, 7), "9.9.9.9"); } else { //YarnConfiguration tries to figure out which rm host it's on by binding to it, //which doesn't happen for any of these fake addresses, so we end up with 0.0.0.0 NUnit.Framework.Assert.AreEqual("Web address misconfigured WITHOUT bind-host", Sharpen.Runtime.Substring (rm.webAppAddress, 0, 7), "0.0.0.0"); } } } catch (YarnRuntimeException) { NUnit.Framework.Assert.Fail("Should not throw any exceptions."); } //test if only RM_HOSTBANE_{rm_id} is set configuration.Clear(); configuration.SetBoolean(YarnConfiguration.RmHaEnabled, true); configuration.Set(YarnConfiguration.RmHaIds, Rm1NodeId + "," + Rm2NodeId); configuration.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, Rm1NodeId), "1.1.1.1" ); configuration.Set(HAUtil.AddSuffix(YarnConfiguration.RmHostname, Rm2NodeId), "0.0.0.0" ); try { Configuration conf = new YarnConfiguration(configuration); rm = new MockRM(conf); rm.Init(conf); NUnit.Framework.Assert.AreEqual("RPC address not set for " + YarnConfiguration.RmAddress , "1.1.1.1:8032", conf.Get(HAUtil.AddSuffix(YarnConfiguration.RmAddress, Rm1NodeId ))); NUnit.Framework.Assert.AreEqual("RPC address not set for " + YarnConfiguration.RmAddress , "0.0.0.0:8032", conf.Get(HAUtil.AddSuffix(YarnConfiguration.RmAddress, Rm2NodeId ))); } catch (YarnRuntimeException) { NUnit.Framework.Assert.Fail("Should not throw any exceptions."); } }
public virtual void TestRMHAWithFileSystemBasedConfiguration() { HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); configuration.Set(YarnConfiguration.RmConfigurationProviderClass, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider" ); configuration.SetBoolean(YarnConfiguration.RmHaEnabled, true); configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); configuration.Set(YarnConfiguration.RmHaIds, "rm1,rm2"); int @base = 100; foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(configuration )) { configuration.Set(HAUtil.AddSuffix(confKey, "rm1"), "0.0.0.0:" + (@base + 20)); configuration.Set(HAUtil.AddSuffix(confKey, "rm2"), "0.0.0.0:" + (@base + 40)); @base = @base * 2; } Configuration conf1 = new Configuration(configuration); conf1.Set(YarnConfiguration.RmHaId, "rm1"); Configuration conf2 = new Configuration(configuration); conf2.Set(YarnConfiguration.RmHaId, "rm2"); // upload default configurations UploadDefaultConfiguration(); MockRM rm1 = null; MockRM rm2 = null; try { rm1 = new MockRM(conf1); rm1.Init(conf1); rm1.Start(); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); rm2 = new MockRM(conf2); rm2.Init(conf1); rm2.Start(); NUnit.Framework.Assert.IsTrue(rm2.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); rm1.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Active); CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); csConf.Set("yarn.scheduler.capacity.maximum-applications", "5000"); UploadConfiguration(csConf, "capacity-scheduler.xml"); rm1.adminService.RefreshQueues(RefreshQueuesRequest.NewInstance()); int maxApps = ((CapacityScheduler)rm1.GetRMContext().GetScheduler()).GetConfiguration ().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxApps, 5000); // Before failover happens, the maxApps is // still the default value on the standby rm : rm2 int maxAppsBeforeFailOver = ((CapacityScheduler)rm2.GetRMContext().GetScheduler() ).GetConfiguration().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxAppsBeforeFailOver, 10000); // Do the failover rm1.adminService.TransitionToStandby(requestInfo); rm2.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); NUnit.Framework.Assert.IsTrue(rm2.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Active); int maxAppsAfter = ((CapacityScheduler)rm2.GetRMContext().GetScheduler()).GetConfiguration ().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxAppsAfter, 5000); } finally { if (rm1 != null) { rm1.Stop(); } if (rm2 != null) { rm2.Stop(); } } }