use of org.codehaus.jettison.json.JSONObject in project hadoop by apache.
the class TestRMWebServicesForCSWithPartitions method testSchedulerPartitionsSlash.
@Test
public void testSchedulerPartitionsSlash() throws JSONException, Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
verifySchedulerInfoJson(json);
}
use of org.codehaus.jettison.json.JSONObject in project hadoop by apache.
the class TestRMWebServicesNodeLabels method validateJsonExceptionContent.
private void validateJsonExceptionContent(ClientResponse response, String expectedmessage) throws JSONException {
Assert.assertEquals(BAD_REQUEST_CODE, response.getStatus());
JSONObject msg = response.getEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
String message = exception.getString("message");
assertEquals("incorrect number of elements", 3, exception.length());
String type = exception.getString("exception");
String classname = exception.getString("javaClassName");
WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
WebServicesTestUtils.checkStringMatch("exception classname", "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
WebServicesTestUtils.checkStringContains("exception message", expectedmessage, message);
}
use of org.codehaus.jettison.json.JSONObject in project hadoop by apache.
the class TestRMWebServicesNodes method testNodesResourceUtilization.
@Test
public void testNodesResourceUtilization() throws JSONException, Exception {
WebResource r = resource();
RMNode rmnode1 = getRunningRMNode("h1", 1234, 5120);
NodeId nodeId1 = rmnode1.getNodeID();
RMNodeImpl node = (RMNodeImpl) rm.getRMContext().getRMNodes().get(nodeId1);
NodeHealthStatus nodeHealth = NodeHealthStatus.newInstance(true, "test health report", System.currentTimeMillis());
ResourceUtilization nodeResource = ResourceUtilization.newInstance(4096, 0, (float) 10.5);
ResourceUtilization containerResource = ResourceUtilization.newInstance(2048, 0, (float) 5.05);
NodeStatus nodeStatus = NodeStatus.newInstance(nodeId1, 0, new ArrayList<ContainerStatus>(), null, nodeHealth, containerResource, nodeResource, null);
node.handle(new RMNodeStatusEvent(nodeId1, nodeStatus, null));
rm.waitForState(nodeId1, NodeState.RUNNING);
ClientResponse response = r.path("ws").path("v1").path("cluster").path("nodes").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject nodes = json.getJSONObject("nodes");
assertEquals("incorrect number of elements", 1, nodes.length());
JSONArray nodeArray = nodes.getJSONArray("node");
assertEquals("incorrect number of elements", 1, nodeArray.length());
JSONObject info = nodeArray.getJSONObject(0);
// verify the resource utilization
verifyNodeInfo(info, rmnode1);
}
use of org.codehaus.jettison.json.JSONObject in project hadoop by apache.
the class TestRMWebServicesApps method verifyResourceRequests.
public void verifyResourceRequests(JSONArray resourceRequest, RMApp app) throws JSONException {
JSONObject requestInfo = resourceRequest.getJSONObject(0);
verifyResourceRequestsGeneric(app, requestInfo.getString("nodeLabelExpression"), requestInfo.getInt("numContainers"), requestInfo.getBoolean("relaxLocality"), requestInfo.getInt("priority"), requestInfo.getString("resourceName"), requestInfo.getJSONObject("capability").getLong("memory"), requestInfo.getJSONObject("capability").getLong("vCores"), requestInfo.getJSONObject("executionTypeRequest").getString("executionType"), requestInfo.getJSONObject("executionTypeRequest").getBoolean("enforceExecutionType"));
}
use of org.codehaus.jettison.json.JSONObject in project hadoop by apache.
the class TestRMWebServicesApps method testAppsQueryStateNone.
@Test
public void testAppsQueryStateNone() throws JSONException, Exception {
rm.start();
MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
rm.submitApp(CONTAINER_MB);
amNodeManager.nodeHeartbeat(true);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("apps").queryParam("state", YarnApplicationState.RUNNING.toString()).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
JSONObject json = response.getEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
assertEquals("apps is not empty", new JSONObject().toString(), json.get("apps").toString());
rm.stop();
}
Aggregations