Exemplo n.º 1
0
            /// <exception cref="System.Exception"/>
            protected override void ServiceStart()
            {
                Configuration conf        = this.GetConfig();
                string        bindAddress = conf.Get(YarnConfiguration.ProxyAddress);

                bindAddress = StringUtils.Split(bindAddress, ':')[0];
                AccessControlList acl = new AccessControlList(conf.Get(YarnConfiguration.YarnAdminAcl
                                                                       , YarnConfiguration.DefaultYarnAdminAcl));

                this.proxyServer = new HttpServer2.Builder().SetName("proxy").AddEndpoint(URI.Create
                                                                                              (WebAppUtils.GetHttpSchemePrefix(conf) + bindAddress + ":0")).SetFindPort(true).
                                   SetConf(conf).SetACL(acl).Build();
                this.proxyServer.AddServlet(ProxyUriUtils.ProxyServletName, ProxyUriUtils.ProxyPathSpec
                                            , typeof(WebAppProxyServlet));
                this.appReportFetcher = new TestWebAppProxyServlet.AppReportFetcherForTest(this,
                                                                                           conf);
                this.proxyServer.SetAttribute(WebAppProxy.FetcherAttribute, this.appReportFetcher
                                              );
                this.proxyServer.SetAttribute(WebAppProxy.IsSecurityEnabledAttribute, true);
                string proxy = WebAppUtils.GetProxyHostAndPort(conf);

                string[] proxyParts = proxy.Split(":");
                string   proxyHost  = proxyParts[0];

                this.proxyServer.SetAttribute(WebAppProxy.ProxyHostAttribute, proxyHost);
                this.proxyServer.Start();
                TestWebAppProxyServlet.Log.Info("Proxy server is started at port {}", this.proxyServer
                                                .GetConnectorAddress(0).Port);
            }
Exemplo n.º 2
0
        /// <exception cref="System.Exception"/>
        protected override void ServiceInit(Configuration conf)
        {
            string auth = conf.Get(CommonConfigurationKeys.HadoopSecurityAuthentication);

            if (auth == null || "simple".Equals(auth))
            {
                isSecurityEnabled = false;
            }
            else
            {
                if ("kerberos".Equals(auth))
                {
                    isSecurityEnabled = true;
                }
                else
                {
                    Log.Warn("Unrecongized attribute value for " + CommonConfigurationKeys.HadoopSecurityAuthentication
                             + " of " + auth);
                }
            }
            string proxy = WebAppUtils.GetProxyHostAndPort(conf);

            string[] proxyParts = proxy.Split(":");
            proxyHost   = proxyParts[0];
            fetcher     = new AppReportFetcher(conf);
            bindAddress = conf.Get(YarnConfiguration.ProxyAddress);
            if (bindAddress == null || bindAddress.IsEmpty())
            {
                throw new YarnRuntimeException(YarnConfiguration.ProxyAddress + " is not set so the proxy will not run."
                                               );
            }
            Log.Info("Instantiating Proxy at " + bindAddress);
            string[] parts = StringUtils.Split(bindAddress, ':');
            port = 0;
            if (parts.Length == 2)
            {
                bindAddress = parts[0];
                port        = System.Convert.ToInt32(parts[1]);
            }
            acl = new AccessControlList(conf.Get(YarnConfiguration.YarnAdminAcl, YarnConfiguration
                                                 .DefaultYarnAdminAcl));
            base.ServiceInit(conf);
        }