Exemplo n.º 1
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"));
        }
Exemplo n.º 2
0
        public virtual ClientResponse DoPostingObject(object @object, string path)
        {
            WebResource webResource = client.Resource(resURI);

            if (path == null)
            {
                return(webResource.Accept(MediaType.ApplicationJson).Type(MediaType.ApplicationJson
                                                                          ).Post <ClientResponse>(@object));
            }
            else
            {
                if (path.Equals("domain"))
                {
                    return(webResource.Path(path).Accept(MediaType.ApplicationJson).Type(MediaType.ApplicationJson
                                                                                         ).Put <ClientResponse>(@object));
                }
                else
                {
                    throw new YarnRuntimeException("Unknown resource type");
                }
            }
        }