Example #1
0
        /// <exception cref="System.Exception"/>
        protected override void ServiceInit(Configuration conf)
        {
            UserGroupInformation ugi     = UserGroupInformation.GetCurrentUser();
            UserGroupInformation realUgi = ugi.GetRealUser();

            if (realUgi != null)
            {
                authUgi  = realUgi;
                doAsUser = ugi.GetShortUserName();
            }
            else
            {
                authUgi  = ugi;
                doAsUser = null;
            }
            ClientConfig cc = new DefaultClientConfig();

            cc.GetClasses().AddItem(typeof(YarnJacksonJaxbJsonProvider));
            connConfigurator = NewConnConfigurator(conf);
            if (UserGroupInformation.IsSecurityEnabled())
            {
                authenticator = new KerberosDelegationTokenAuthenticator();
            }
            else
            {
                authenticator = new PseudoDelegationTokenAuthenticator();
            }
            authenticator.SetConnectionConfigurator(connConfigurator);
            token           = new DelegationTokenAuthenticatedURL.Token();
            connectionRetry = new TimelineClientImpl.TimelineClientConnectionRetry(conf);
            client          = new Com.Sun.Jersey.Api.Client.Client(new URLConnectionClientHandler(new
                                                                                                  TimelineClientImpl.TimelineURLConnectionFactory(this)), cc);
            TimelineClientImpl.TimelineJerseyRetryFilter retryFilter = new TimelineClientImpl.TimelineJerseyRetryFilter
                                                                           (this);
            client.AddFilter(retryFilter);
            if (YarnConfiguration.UseHttps(conf))
            {
                resURI = URI.Create(Joiner.Join("https://", conf.Get(YarnConfiguration.TimelineServiceWebappHttpsAddress
                                                                     , YarnConfiguration.DefaultTimelineServiceWebappHttpsAddress), ResourceUriStr));
            }
            else
            {
                resURI = URI.Create(Joiner.Join("http://", conf.Get(YarnConfiguration.TimelineServiceWebappAddress
                                                                    , YarnConfiguration.DefaultTimelineServiceWebappAddress), ResourceUriStr));
            }
            Log.Info("Timeline service address: " + resURI);
            base.ServiceInit(conf);
        }
Example #2
0
        // Do some sanity testing of the web-services after fail-over.
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        private void CheckActiveRMWebServices()
        {
            // Validate web-service
            Com.Sun.Jersey.Api.Client.Client webServiceClient = Com.Sun.Jersey.Api.Client.Client
                                                                .Create(new DefaultClientConfig());
            IPEndPoint rmWebappAddr = NetUtils.GetConnectAddress(rm.GetWebapp().GetListenerAddress
                                                                     ());
            string         webappURL   = "http://" + rmWebappAddr.GetHostName() + ":" + rmWebappAddr.Port;
            WebResource    webResource = webServiceClient.Resource(webappURL);
            string         path        = app.GetApplicationId().ToString();
            ClientResponse response    = webResource.Path("ws").Path("v1").Path("cluster").Path(
                "apps").Path(path).Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject appJson = json.GetJSONObject("app");

            NUnit.Framework.Assert.AreEqual("ACCEPTED", appJson.GetString("state"));
        }