Search in sources :

Example 26 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class EntityLineageJerseyResourceIT method testInputLineageInfo.

@Test
public void testInputLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, INPUT_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
    Assert.assertNotNull(response);
    System.out.println("input lineage info = " + response);
    AtlasLineageInfo inputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
    Map<String, AtlasEntityHeader> entities = inputLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);
    Set<AtlasLineageInfo.LineageRelation> relations = inputLineageInfo.getRelations();
    Assert.assertNotNull(relations);
    Assert.assertEquals(entities.size(), 6);
    Assert.assertEquals(relations.size(), 5);
    Assert.assertEquals(inputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.INPUT);
    Assert.assertEquals(inputLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(inputLineageInfo.getBaseEntityGuid(), tableId);
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) JSONObject(org.codehaus.jettison.json.JSONObject) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 27 with MultivaluedMapImpl

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

the class TestRMWebServicesSchedulerActivities method testWrongNodeId.

@Test
public void testWrongNodeId() 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(1024, "app1", "user1", null, "b1");
        MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
        am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
        //Get JSON
        WebResource r = resource();
        MultivaluedMapImpl params = new MultivaluedMapImpl();
        params.add("nodeId", "127.0.0.0");
        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, 0);
    } 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) MockAM(org.apache.hadoop.yarn.server.resourcemanager.MockAM) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 28 with MultivaluedMapImpl

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

the class TestRMWebServicesSchedulerActivities method testAppActivityJSON.

@Test
public void testAppActivityJSON() 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("appId", app1.getApplicationId().toString());
        ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/app-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(5000);
        //Get JSON
        response = r.path("ws").path("v1").path("cluster").path("scheduler/app-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, "allocationState", "ACCEPTED");
        verifyNumberOfAllocationAttempts(allocations, 1);
    } 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 29 with MultivaluedMapImpl

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

the class TestRMWebServicesSchedulerActivities method testAssignMultipleContainersPerNodeHeartbeat.

@Test
public void testAssignMultipleContainersPerNodeHeartbeat() 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");
        MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
        am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
        //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);
        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, 11);
        JSONArray allocations = json.getJSONArray("allocations");
        for (int i = 0; i < allocations.length(); i++) {
            if (i != allocations.length() - 1) {
                verifyStateOfAllocations(allocations.getJSONObject(i), "finalAllocationState", "ALLOCATED");
                verifyQueueOrder(allocations.getJSONObject(i), "root-a-b-b2-b3-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) JSONArray(org.codehaus.jettison.json.JSONArray) MockAM(org.apache.hadoop.yarn.server.resourcemanager.MockAM) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.junit.Test)

Example 30 with MultivaluedMapImpl

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

the class TestRMWebServicesSchedulerActivities method testAppAssignMultipleContainersPerNodeHeartbeat.

@Test
public void testAppAssignMultipleContainersPerNodeHeartbeat() 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(1024, "app1", "user1", null, "b1");
        MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm);
        am1.allocate(Arrays.asList(ResourceRequest.newInstance(Priority.UNDEFINED, "127.0.0.1", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "/default-rack", Resources.createResource(1024), 10), ResourceRequest.newInstance(Priority.UNDEFINED, "*", Resources.createResource(1024), 10)), null);
        //Get JSON
        WebResource r = resource();
        MultivaluedMapImpl params = new MultivaluedMapImpl();
        params.add("appId", app1.getApplicationId().toString());
        ClientResponse response = r.path("ws").path("v1").path("cluster").path("scheduler/app-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(5000);
        //Get JSON
        response = r.path("ws").path("v1").path("cluster").path("scheduler/app-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, 10);
        JSONArray allocations = json.getJSONArray("allocations");
        for (int i = 0; i < allocations.length(); i++) {
            verifyStateOfAllocations(allocations.getJSONObject(i), "allocationState", "ACCEPTED");
        }
    } 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) JSONArray(org.codehaus.jettison.json.JSONArray) MockAM(org.apache.hadoop.yarn.server.resourcemanager.MockAM) 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)69 JSONObject (org.codehaus.jettison.json.JSONObject)33 Test (org.junit.Test)31 ClientResponse (com.sun.jersey.api.client.ClientResponse)27 WebResource (com.sun.jersey.api.client.WebResource)19 Test (org.testng.annotations.Test)19 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 JSONArray (org.codehaus.jettison.json.JSONArray)9 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)7 Response (javax.ws.rs.core.Response)6 BridgePort (org.midonet.client.resource.BridgePort)5 Router (org.midonet.client.resource.Router)5 Bridge (org.midonet.client.resource.Bridge)4 Route (org.midonet.client.resource.Route)4 RouterPort (org.midonet.client.resource.RouterPort)4 OAuthServiceException (com.sun.identity.oauth.service.OAuthServiceException)3 Client (com.sun.jersey.api.client.Client)3 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)3