コード例 #1
0
ファイル: HAUtil.cs プロジェクト: orf53975/hadoop.net
 public static void VerifyAndSetAllServiceAddresses(Configuration conf)
 {
     foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         VerifyAndSetConfValue(confKey, conf);
     }
 }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
 public virtual void SetUp()
 {
     conf = new Configuration();
     conf.Set(YarnConfiguration.RmHaIds, RmNodeIdsUntrimmed);
     conf.Set(YarnConfiguration.RmHaId, Rm1NodeIdUntrimmed);
     foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         // configuration key itself cannot contains space/tab/return chars.
         conf.Set(HAUtil.AddSuffix(confKey, Rm1NodeId), Rm1AddressUntrimmed);
         conf.Set(HAUtil.AddSuffix(confKey, Rm2NodeId), Rm2Address);
     }
 }
コード例 #4
0
ファイル: HAUtil.cs プロジェクト: orf53975/hadoop.net
 internal static string GetConfKeyForRMInstance(string prefix, Configuration conf)
 {
     if (!YarnConfiguration.GetServiceAddressConfKeys(conf).Contains(prefix))
     {
         return(prefix);
     }
     else
     {
         string RMId = GetRMHAId(conf);
         CheckAndSetRMRPCAddress(prefix, RMId, conf);
         return(AddSuffix(prefix, RMId));
     }
 }
コード例 #5
0
ファイル: TestRMHA.cs プロジェクト: orf53975/hadoop.net
 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();
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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");
        }
コード例 #8
0
ファイル: HAUtil.cs プロジェクト: orf53975/hadoop.net
        /// <summary>
        /// Verify configuration that there are at least two RM-ids
        /// and RPC addresses are specified for each RM-id.
        /// </summary>
        /// <remarks>
        /// Verify configuration that there are at least two RM-ids
        /// and RPC addresses are specified for each RM-id.
        /// Then set the RM-ids.
        /// </remarks>
        private static void VerifyAndSetRMHAIdsList(Configuration conf)
        {
            ICollection <string> ids = conf.GetTrimmedStringCollection(YarnConfiguration.RmHaIds
                                                                       );

            if (ids.Count < 2)
            {
                ThrowBadConfigurationException(GetInvalidValueMessage(YarnConfiguration.RmHaIds,
                                                                      conf.Get(YarnConfiguration.RmHaIds) + "\nHA mode requires atleast two RMs"));
            }
            StringBuilder setValue = new StringBuilder();

            foreach (string id in ids)
            {
                // verify the RM service addresses configurations for every RMIds
                foreach (string prefix in YarnConfiguration.GetServiceAddressConfKeys(conf))
                {
                    CheckAndSetRMRPCAddress(prefix, id, conf);
                }
                setValue.Append(id);
                setValue.Append(",");
            }
            conf.Set(YarnConfiguration.RmHaIds, setValue.Substring(0, setValue.Length - 1));
        }
コード例 #9
0
 public virtual void TestVerifyAndSetConfiguration()
 {
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
     }
     catch (YarnRuntimeException)
     {
         NUnit.Framework.Assert.Fail("Should not throw any exceptions.");
     }
     NUnit.Framework.Assert.AreEqual("Should be saved as Trimmed collection", StringUtils
                                     .GetStringCollection(RmNodeIds), HAUtil.GetRMHAIds(conf));
     NUnit.Framework.Assert.AreEqual("Should be saved as Trimmed string", Rm1NodeId, HAUtil
                                     .GetRMHAId(conf));
     foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         NUnit.Framework.Assert.AreEqual("RPC address not set for " + confKey, Rm1Address,
                                         conf.Get(confKey));
     }
     conf.Clear();
     conf.Set(YarnConfiguration.RmHaIds, Rm1NodeId);
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
     }
     catch (YarnRuntimeException e)
     {
         NUnit.Framework.Assert.AreEqual("YarnRuntimeException by verifyAndSetRMHAIds()",
                                         HAUtil.BadConfigMessagePrefix + HAUtil.GetInvalidValueMessage(YarnConfiguration.
                                                                                                       RmHaIds, conf.Get(YarnConfiguration.RmHaIds) + "\nHA mode requires atleast two RMs"
                                                                                                       ), e.Message);
     }
     conf.Clear();
     // simulate the case YarnConfiguration.RM_HA_ID is not set
     conf.Set(YarnConfiguration.RmHaIds, Rm1NodeId + "," + Rm2NodeId);
     foreach (string confKey_1 in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         conf.Set(HAUtil.AddSuffix(confKey_1, Rm1NodeId), Rm1Address);
         conf.Set(HAUtil.AddSuffix(confKey_1, Rm2NodeId), Rm2Address);
     }
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
     }
     catch (YarnRuntimeException e)
     {
         NUnit.Framework.Assert.AreEqual("YarnRuntimeException by getRMId()", HAUtil.BadConfigMessagePrefix
                                         + HAUtil.GetNeedToSetValueMessage(YarnConfiguration.RmHaId), e.Message);
     }
     conf.Clear();
     conf.Set(YarnConfiguration.RmHaId, RmInvalidNodeId);
     conf.Set(YarnConfiguration.RmHaIds, RmInvalidNodeId + "," + Rm1NodeId);
     foreach (string confKey_2 in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         // simulate xml with invalid node id
         conf.Set(confKey_2 + RmInvalidNodeId, RmInvalidNodeId);
     }
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
     }
     catch (YarnRuntimeException e)
     {
         NUnit.Framework.Assert.AreEqual("YarnRuntimeException by addSuffix()", HAUtil.BadConfigMessagePrefix
                                         + HAUtil.GetInvalidValueMessage(YarnConfiguration.RmHaId, RmInvalidNodeId), e.Message
                                         );
     }
     conf.Clear();
     // simulate the case HAUtil.RM_RPC_ADDRESS_CONF_KEYS are not set
     conf.Set(YarnConfiguration.RmHaId, Rm1NodeId);
     conf.Set(YarnConfiguration.RmHaIds, Rm1NodeId + "," + Rm2NodeId);
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
         NUnit.Framework.Assert.Fail("Should throw YarnRuntimeException. by Configuration#set()"
                                     );
     }
     catch (YarnRuntimeException e)
     {
         string confKey_3 = HAUtil.AddSuffix(YarnConfiguration.RmAddress, Rm1NodeId);
         NUnit.Framework.Assert.AreEqual("YarnRuntimeException by Configuration#set()", HAUtil
                                         .BadConfigMessagePrefix + HAUtil.GetNeedToSetValueMessage(HAUtil.AddSuffix(YarnConfiguration
                                                                                                                    .RmHostname, Rm1NodeId) + " or " + confKey_3), e.Message);
     }
     // simulate the case YarnConfiguration.RM_HA_IDS doesn't contain
     // the value of YarnConfiguration.RM_HA_ID
     conf.Clear();
     conf.Set(YarnConfiguration.RmHaIds, Rm2NodeId + "," + Rm3NodeId);
     conf.Set(YarnConfiguration.RmHaId, Rm1NodeIdUntrimmed);
     foreach (string confKey_4 in YarnConfiguration.GetServiceAddressConfKeys(conf))
     {
         conf.Set(HAUtil.AddSuffix(confKey_4, Rm1NodeId), Rm1AddressUntrimmed);
         conf.Set(HAUtil.AddSuffix(confKey_4, Rm2NodeId), Rm2Address);
         conf.Set(HAUtil.AddSuffix(confKey_4, Rm3NodeId), Rm3Address);
     }
     try
     {
         HAUtil.VerifyAndSetConfiguration(conf);
     }
     catch (YarnRuntimeException e)
     {
         NUnit.Framework.Assert.AreEqual("YarnRuntimeException by getRMId()'s validation",
                                         HAUtil.BadConfigMessagePrefix + HAUtil.GetRMHAIdNeedToBeIncludedMessage("[rm2, rm3]"
                                                                                                                 , Rm1NodeId), e.Message);
     }
 }
コード例 #10
0
ファイル: TestRMHA.cs プロジェクト: orf53975/hadoop.net
 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.");
     }
 }
コード例 #11
0
        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();
                }
            }
        }