Exemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        protected override void ServiceStart()
        {
            string bindAddress = WebAppUtils.GetWebAppBindURL(GetConfig(), YarnConfiguration.
                                                              NmBindHost, WebAppUtils.GetNMWebAppURLWithoutScheme(GetConfig()));
            bool enableCors = GetConfig().GetBoolean(YarnConfiguration.NmWebappEnableCorsFilter
                                                     , YarnConfiguration.DefaultNmWebappEnableCorsFilter);

            if (enableCors)
            {
                GetConfig().SetBoolean(HttpCrossOriginFilterInitializer.Prefix + HttpCrossOriginFilterInitializer
                                       .EnabledSuffix, true);
            }
            Log.Info("Instantiating NMWebApp at " + bindAddress);
            try
            {
                this.webApp = WebApps.$for <Context>("node", this.nmContext, "ws").At(bindAddress)
                              .With(GetConfig()).WithHttpSpnegoPrincipalKey(YarnConfiguration.NmWebappSpnegoUserNameKey
                                                                            ).WithHttpSpnegoKeytabKey(YarnConfiguration.NmWebappSpnegoKeytabFileKey).Start(this
                                                                                                                                                           .nmWebApp);
                this.port = this.webApp.HttpServer().GetConnectorAddress(0).Port;
            }
            catch (Exception e)
            {
                string msg = "NMWebapps failed to start.";
                Log.Error(msg, e);
                throw new YarnRuntimeException(msg, e);
            }
            base.ServiceStart();
        }