Search in sources :

Example 66 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.

the class TestRMWebServicesSchedulerActivities method testActivityJSON.

@Test
public void testActivityJSON() throws Exception {
    //Start RM so that it accepts app submissions
    rm.start();
    MockNM nm = new MockNM("127.0.0.1:1234", 24 * 1024, rm.getResourceTrackerService());
    nm.registerNode();
    try {
        RMApp app1 = rm.submitApp(10, "app1", "user1", null, "b1");
        //Get JSON
        WebResource r = resource();
        MultivaluedMapImpl params = new MultivaluedMapImpl();
        params.add("nodeId", "127.0.0.1");
        ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
        JSONObject json = response.getEntity(JSONObject.class);
        nm.nodeHeartbeat(true);
        Thread.sleep(1000);
        //Get JSON
        response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
        json = response.getEntity(JSONObject.class);
        verifyNumberOfAllocations(json, 1);
        JSONObject allocations = json.getJSONObject("allocations");
        verifyStateOfAllocations(allocations, "finalAllocationState", "ALLOCATED");
        verifyNumberOfNodes(allocations, 5);
        verifyQueueOrder(json.getJSONObject("allocations"), "root-b-b1");
    } finally {
        rm.stop();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) JSONObject(org.codehaus.jettison.json.JSONObject) MockNM(org.apache.hadoop.yarn.server.resourcemanager.MockNM) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 67 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.

the class TestRMWebServicesNodeLabels method testLabelInvalidRemove.

@Test
public void testLabelInvalidRemove() throws UniformInterfaceException, Exception {
    WebResource r = resource();
    ClientResponse response;
    MultivaluedMapImpl params = new MultivaluedMapImpl();
    params.add("labels", "irealldontexist");
    response = r.path("ws").path("v1").path("cluster").path("remove-node-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    String expectedmessage = "java.io.IOException: Node label=irealldontexist to be" + " removed doesn't existed in cluster node labels" + " collection.";
    validateJsonExceptionContent(response, expectedmessage);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 68 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.

the class TestRMWebServicesNodeLabels method testLabelInvalidReplace.

@Test
public void testLabelInvalidReplace() throws UniformInterfaceException, Exception {
    WebResource r = resource();
    ClientResponse response;
    // replace label which doesnt exist
    MultivaluedMapImpl params = new MultivaluedMapImpl();
    params.add("labels", "idontexist");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    String expectedmessage = "Not all labels being replaced contained by known label" + " collections, please check, new labels=[idontexist]";
    validateJsonExceptionContent(response, expectedmessage);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 69 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.

the class TestRMWebServicesNodeLabels method testNodeLabels.

@Test
public void testNodeLabels() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response;
    // Add a label
    NodeLabelsInfo nlsifo = new NodeLabelsInfo();
    nlsifo.getNodeLabelsInfo().add(new NodeLabelInfo("a"));
    response = r.path("ws").path("v1").path("cluster").path("add-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(nlsifo, NodeLabelsInfo.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(1, nlsifo.getNodeLabels().size());
    for (NodeLabelInfo nl : nlsifo.getNodeLabelsInfo()) {
        assertEquals("a", nl.getName());
        assertTrue(nl.getExclusivity());
    }
    // Add another
    nlsifo = new NodeLabelsInfo();
    nlsifo.getNodeLabelsInfo().add(new NodeLabelInfo("b", false));
    response = r.path("ws").path("v1").path("cluster").path("add-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(nlsifo, NodeLabelsInfo.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(2, nlsifo.getNodeLabels().size());
    // Verify exclusivity for 'y' as false
    for (NodeLabelInfo nl : nlsifo.getNodeLabelsInfo()) {
        if (nl.getName().equals("b")) {
            assertFalse(nl.getExclusivity());
        }
    }
    // Add labels to a node
    MultivaluedMapImpl params = new MultivaluedMapImpl();
    params.add("labels", "a");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Add labels to another node
    params = new MultivaluedMapImpl();
    params.add("labels", "b");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid1:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Add labels to another node
    params = new MultivaluedMapImpl();
    params.add("labels", "b");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid2:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Verify, using get-labels-to-Nodes
    response = r.path("ws").path("v1").path("cluster").path("label-mappings").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    LabelsToNodesInfo ltni = response.getEntity(LabelsToNodesInfo.class);
    assertEquals(2, ltni.getLabelsToNodes().size());
    NodeIDsInfo nodes = ltni.getLabelsToNodes().get(new NodeLabelInfo("b", false));
    assertTrue(nodes.getNodeIDs().contains("nid2:0"));
    assertTrue(nodes.getNodeIDs().contains("nid1:0"));
    nodes = ltni.getLabelsToNodes().get(new NodeLabelInfo("a"));
    assertTrue(nodes.getNodeIDs().contains("nid:0"));
    // Verify, using get-labels-to-Nodes for specified set of labels
    params = new MultivaluedMapImpl();
    params.add("labels", "a");
    response = r.path("ws").path("v1").path("cluster").path("label-mappings").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    ltni = response.getEntity(LabelsToNodesInfo.class);
    assertEquals(1, ltni.getLabelsToNodes().size());
    nodes = ltni.getLabelsToNodes().get(new NodeLabelInfo("a"));
    assertTrue(nodes.getNodeIDs().contains("nid:0"));
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("get-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().contains(new NodeLabelInfo("a")));
    // Replace
    params = new MultivaluedMapImpl();
    params.add("labels", "b");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("get-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().contains(new NodeLabelInfo("b", false)));
    // Replace labels using node-to-labels
    NodeToLabelsEntryList ntli = new NodeToLabelsEntryList();
    ArrayList<String> labels = new ArrayList<String>();
    labels.add("a");
    NodeToLabelsEntry nli = new NodeToLabelsEntry("nid:0", labels);
    ntli.getNodeToLabels().add(nli);
    response = r.path("ws").path("v1").path("cluster").path("replace-node-to-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(ntli, NodeToLabelsEntryList.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify, using node-to-labels
    response = r.path("ws").path("v1").path("cluster").path("get-node-to-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    NodeToLabelsInfo ntlinfo = response.getEntity(NodeToLabelsInfo.class);
    NodeLabelsInfo nlinfo = ntlinfo.getNodeToLabels().get("nid:0");
    assertEquals(1, nlinfo.getNodeLabels().size());
    assertTrue(nlinfo.getNodeLabelsInfo().contains(new NodeLabelInfo("a")));
    // Remove all
    params = new MultivaluedMapImpl();
    params.add("labels", "");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("get-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().isEmpty());
    // Add a label back for auth tests
    params = new MultivaluedMapImpl();
    params.add("labels", "a");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("get-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().contains(new NodeLabelInfo("a")));
    // Auth fail replace labels on node
    params = new MultivaluedMapImpl();
    params.add("labels", "b");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", notUserName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("get-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().contains(new NodeLabelInfo("a")));
    // Fail to add a label with post
    response = r.path("ws").path("v1").path("cluster").path("add-node-labels").queryParam("user.name", notUserName).accept(MediaType.APPLICATION_JSON).entity("{\"nodeLabels\":\"c\"}", MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(2, nlsifo.getNodeLabels().size());
    // Remove cluster label (succeed, we no longer need it)
    params = new MultivaluedMapImpl();
    params.add("labels", "b");
    response = r.path("ws").path("v1").path("cluster").path("remove-node-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(1, nlsifo.getNodeLabels().size());
    for (NodeLabelInfo nl : nlsifo.getNodeLabelsInfo()) {
        assertEquals("a", nl.getName());
        assertTrue(nl.getExclusivity());
    }
    // Remove cluster label with post
    params = new MultivaluedMapImpl();
    params.add("labels", "a");
    response = r.path("ws").path("v1").path("cluster").path("remove-node-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(0, nlsifo.getNodeLabels().size());
    // Following test cases are to test replace when distributed node label
    // configuration is on
    // Reset for testing : add cluster labels
    nlsifo = new NodeLabelsInfo();
    nlsifo.getNodeLabelsInfo().add(new NodeLabelInfo("x", false));
    nlsifo.getNodeLabelsInfo().add(new NodeLabelInfo("y", false));
    response = r.path("ws").path("v1").path("cluster").path("add-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(nlsifo, NodeLabelsInfo.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Reset for testing : Add labels to a node
    params = new MultivaluedMapImpl();
    params.add("labels", "y");
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    //setting rmWebService for non Centralized NodeLabel Configuration
    rmWebService.isCentralizedNodeLabelConfiguration = false;
    // Case1 : Replace labels using node-to-labels
    ntli = new NodeToLabelsEntryList();
    labels = new ArrayList<String>();
    labels.add("x");
    nli = new NodeToLabelsEntry("nid:0", labels);
    ntli.getNodeToLabels().add(nli);
    response = r.path("ws").path("v1").path("cluster").path("replace-node-to-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(ntli, NodeToLabelsEntryList.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify, using node-to-labels that previous operation has failed
    response = r.path("ws").path("v1").path("cluster").path("get-node-to-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    ntlinfo = response.getEntity(NodeToLabelsInfo.class);
    nlinfo = ntlinfo.getNodeToLabels().get("nid:0");
    assertEquals(1, nlinfo.getNodeLabels().size());
    assertFalse(nlinfo.getNodeLabelsInfo().contains(new NodeLabelInfo("x", false)));
    // Case2 : failure to Replace labels using replace-labels
    response = r.path("ws").path("v1").path("cluster").path("nodes").path("nid:0").path("replace-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity("{\"nodeLabelName\": [\"x\"]}", MediaType.APPLICATION_JSON).post(ClientResponse.class);
    LOG.info("posted node nodelabel");
    // Verify, using node-to-labels that previous operation has failed
    response = r.path("ws").path("v1").path("cluster").path("get-node-to-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    ntlinfo = response.getEntity(NodeToLabelsInfo.class);
    nlinfo = ntlinfo.getNodeToLabels().get("nid:0");
    assertEquals(1, nlinfo.getNodeLabels().size());
    assertFalse(nlinfo.getNodeLabelsInfo().contains(new NodeLabelInfo("x", false)));
    //  Case3 : Remove cluster label should be successful
    params = new MultivaluedMapImpl();
    params.add("labels", "x");
    response = r.path("ws").path("v1").path("cluster").path("remove-node-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals(new NodeLabelInfo("y", false), nlsifo.getNodeLabelsInfo().get(0));
    assertEquals("y", nlsifo.getNodeLabelsInfo().get(0).getName());
    assertFalse(nlsifo.getNodeLabelsInfo().get(0).getExclusivity());
    // Remove y
    params = new MultivaluedMapImpl();
    params.add("labels", "y");
    response = r.path("ws").path("v1").path("cluster").path("remove-node-labels").queryParam("user.name", userName).queryParams(params).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertTrue(nlsifo.getNodeLabelsInfo().isEmpty());
    // add a new nodelabel with exclusity
    nlsifo = new NodeLabelsInfo();
    nlsifo.getNodeLabelsInfo().add(new NodeLabelInfo("z", false));
    response = r.path("ws").path("v1").path("cluster").path("add-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).entity(toJson(nlsifo, NodeLabelsInfo.class), MediaType.APPLICATION_JSON).post(ClientResponse.class);
    // Verify
    response = r.path("ws").path("v1").path("cluster").path("get-node-labels").queryParam("user.name", userName).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
    nlsifo = response.getEntity(NodeLabelsInfo.class);
    assertEquals("z", nlsifo.getNodeLabelsInfo().get(0).getName());
    assertFalse(nlsifo.getNodeLabelsInfo().get(0).getExclusivity());
    assertEquals(1, nlsifo.getNodeLabels().size());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) LabelsToNodesInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo) NodeLabelsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo) ArrayList(java.util.ArrayList) WebResource(com.sun.jersey.api.client.WebResource) NodeToLabelsInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) NodeToLabelsEntry(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsEntry) NodeToLabelsEntryList(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsEntryList) NodeLabelInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelInfo) Test(org.junit.Test)

Example 70 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project hadoop by apache.

the class TestRMWebServicesSchedulerActivities method testNoNM.

@Test
public void testNoNM() throws Exception {
    //Start RM so that it accepts app submissions
    rm.start();
    try {
        //Get JSON
        WebResource r = resource();
        MultivaluedMapImpl params = new MultivaluedMapImpl();
        params.add("nodeId", "127.0.0.1:1234");
        ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
        JSONObject json = response.getEntity(JSONObject.class);
        Thread.sleep(1000);
        //Get JSON
        response = r.path("ws").path("v1").path("cluster").path("scheduler/activities").queryParams(params).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
        json = response.getEntity(JSONObject.class);
        verifyNumberOfAllocations(json, 0);
    } finally {
        rm.stop();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) JSONObject(org.codehaus.jettison.json.JSONObject) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Aggregations

MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)131 Test (org.junit.Test)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)48 WebResource (com.sun.jersey.api.client.WebResource)39 JSONObject (org.codehaus.jettison.json.JSONObject)39 Test (org.testng.annotations.Test)35 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 List (java.util.List)11 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 JSONArray (org.codehaus.jettison.json.JSONArray)9 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 Client (com.sun.jersey.api.client.Client)7 SearchFilter (org.apache.atlas.model.SearchFilter)7 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)7 WebDriverHelper (org.orcid.api.common.WebDriverHelper)7 Response (javax.ws.rs.core.Response)6 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)6 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)6 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)6