示例#1
0
        /// <exception cref="System.Exception"/>
        protected override void ServiceInit(Configuration conf)
        {
            conf = conf is YarnConfiguration ? conf : new YarnConfiguration(conf);
            string zkQuorum = conf.Get(YarnConfiguration.RmZkAddress);

            if (zkQuorum == null)
            {
                throw new YarnRuntimeException("Embedded automatic failover " + "is enabled, but "
                                               + YarnConfiguration.RmZkAddress + " is not set");
            }
            string rmId      = HAUtil.GetRMHAId(conf);
            string clusterId = YarnConfiguration.GetClusterId(conf);

            localActiveNodeInfo = CreateActiveNodeInfo(clusterId, rmId);
            string zkBasePath = conf.Get(YarnConfiguration.AutoFailoverZkBasePath, YarnConfiguration
                                         .DefaultAutoFailoverZkBasePath);
            string electionZNode    = zkBasePath + "/" + clusterId;
            long   zkSessionTimeout = conf.GetLong(YarnConfiguration.RmZkTimeoutMs, YarnConfiguration
                                                   .DefaultRmZkTimeoutMs);
            IList <ACL> zkAcls = RMZKUtils.GetZKAcls(conf);
            IList <ZKUtil.ZKAuthInfo> zkAuths = RMZKUtils.GetZKAuths(conf);
            int maxRetryNum = conf.GetInt(CommonConfigurationKeys.HaFcElectorZkOpRetriesKey,
                                          CommonConfigurationKeys.HaFcElectorZkOpRetriesDefault);

            elector = new ActiveStandbyElector(zkQuorum, (int)zkSessionTimeout, electionZNode
                                               , zkAcls, zkAuths, this, maxRetryNum);
            elector.EnsureParentZNode();
            if (!IsParentZnodeSafe(clusterId))
            {
                NotifyFatalError(electionZNode + " znode has invalid data! " + "Might need formatting!"
                                 );
            }
            base.ServiceInit(conf);
        }