use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServicesHBaseStorage method testGetFlowRunNotPresent.
@Test
public void testGetFlowRunNotPresent() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/users/user1/flows/flow_name/runs/" + "1002345678929");
verifyHttpResponse(client, uri, Status.NOT_FOUND);
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testQueryWithoutCluster.
@Test
public void testQueryWithoutCluster() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/apps/app1/entities/app/id_1");
ClientResponse resp = getResponse(client, uri);
TimelineEntity entity = resp.getEntity(TimelineEntity.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entity);
assertEquals("id_1", entity.getId());
assertEquals("app", entity.getType());
uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/apps/app1/entities/app");
resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(4, entities.size());
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetContainers.
@Test
public void testGetContainers() throws Exception {
Client client = createClient();
try {
// total 3 containers in a application.
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/YARN_CONTAINER");
ClientResponse resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
int totalEntities = entities.size();
assertEquals(3, totalEntities);
assertTrue("Entity with container_1_1 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_1_1")));
assertTrue("Entity with container_2_1 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_2_1")));
assertTrue("Entity with container_2_2 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_2_2")));
// for app-attempt1 1 container has run
uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/" + "appattempts/app-attempt-1/containers");
resp = getResponse(client, uri);
entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType());
assertNotNull(entities);
int retrievedEntity = entities.size();
assertEquals(1, retrievedEntity);
assertTrue("Entity with container_1_1 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_1_1")));
// for app-attempt2 2 containers has run
uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/" + "appattempts/app-attempt-2/containers");
resp = getResponse(client, uri);
entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType());
assertNotNull(entities);
retrievedEntity += entities.size();
assertEquals(2, entities.size());
assertTrue("Entity with container_2_1 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_2_1")));
assertTrue("Entity with container_2_2 should have been present in response.", entities.contains(newEntity(TimelineEntityType.YARN_CONTAINER.toString(), "container_2_2")));
assertEquals(totalEntities, retrievedEntity);
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetEntitiesByMetricFilters.
@Test
public void testGetEntitiesByMetricFilters() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app?" + "metricfilters=metric3%20ge%200");
ClientResponse resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(2, entities.size());
assertTrue("Entities with id_1 and id_2 should have been present" + " in response.", entities.contains(newEntity("app", "id_1")) && entities.contains(newEntity("app", "id_2")));
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetEntities.
@Test
public void testGetEntities() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app");
ClientResponse resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(4, entities.size());
assertTrue("Entities id_1, id_2, id_3 and id_4 should have been" + " present in response", entities.contains(newEntity("app", "id_1")) && entities.contains(newEntity("app", "id_2")) && entities.contains(newEntity("app", "id_3")) && entities.contains(newEntity("app", "id_4")));
} finally {
client.destroy();
}
}
Aggregations