Search in sources :

Example 61 with TimelineEntity

use of org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity in project hadoop by apache.

the class TestFileSystemTimelineReaderImpl method testGetAllEntities.

@Test
public void testGetAllEntities() throws Exception {
    Set<TimelineEntity> result = reader.getEntities(new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", null), new TimelineEntityFilters(), new TimelineDataToRetrieve(null, null, EnumSet.of(Field.ALL), null));
    // All 4 entities will be returned
    Assert.assertEquals(4, result.size());
}
Also used : TimelineReaderContext(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext) TimelineEntityFilters(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineEntityFilters) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) TimelineDataToRetrieve(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve) Test(org.junit.Test)

Example 62 with TimelineEntity

use of org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity in project hadoop by apache.

the class FileSystemTimelineReaderImpl method createEntityToBeReturned.

private static TimelineEntity createEntityToBeReturned(TimelineEntity entity, EnumSet<Field> fieldsToRetrieve) {
    TimelineEntity entityToBeReturned = new TimelineEntity();
    entityToBeReturned.setIdentifier(entity.getIdentifier());
    entityToBeReturned.setCreatedTime(entity.getCreatedTime());
    if (fieldsToRetrieve != null) {
        fillFields(entityToBeReturned, entity, fieldsToRetrieve);
    }
    return entityToBeReturned;
}
Also used : TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity)

Example 63 with TimelineEntity

use of org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity in project hadoop by apache.

the class TestTimelineReaderWebServices method testGetEntityDefaultView.

@Test
public void testGetEntityDefaultView() throws Exception {
    Client client = createClient();
    try {
        URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/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());
        assertEquals((Long) 1425016502000L, entity.getCreatedTime());
        // Default view i.e. when no fields are specified, entity contains only
        // entity id, entity type and created time.
        assertEquals(0, entity.getConfigs().size());
        assertEquals(0, entity.getMetrics().size());
    } finally {
        client.destroy();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Client(com.sun.jersey.api.client.Client) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) URI(java.net.URI) Test(org.junit.Test)

Example 64 with TimelineEntity

use of org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity in project hadoop by apache.

the class TestTimelineReaderWebServices method testGetEntitiesWithLimit.

@Test
public void testGetEntitiesWithLimit() throws Exception {
    Client client = createClient();
    try {
        URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app?limit=2");
        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());
        // Entities returned are based on most recent created time.
        assertTrue("Entities with id_1 and id_4 should have been present " + "in response based on entity created time.", entities.contains(newEntity("app", "id_1")) && entities.contains(newEntity("app", "id_4")));
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/timeline/" + "clusters/cluster1/apps/app1/entities/app?limit=3");
        resp = getResponse(client, uri);
        entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
        });
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
        assertNotNull(entities);
        // Even though 2 entities out of 4 have same created time, one entity
        // is left out due to limit
        assertEquals(3, entities.size());
    } finally {
        client.destroy();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) GenericType(com.sun.jersey.api.client.GenericType) Set(java.util.Set) Client(com.sun.jersey.api.client.Client) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) URI(java.net.URI) Test(org.junit.Test)

Example 65 with TimelineEntity

use of org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity in project hadoop by apache.

the class TestTimelineReaderWebServices method testGetEntitiesByRelations.

@Test
public void testGetEntitiesByRelations() throws Exception {
    Client client = createClient();
    try {
        URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app?relatesto=" + "flow:flow1");
        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(1, entities.size());
        assertTrue("Entity with id_1 should have been present in response.", entities.contains(newEntity("app", "id_1")));
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/timeline/" + "clusters/cluster1/apps/app1/entities/app?isrelatedto=" + "type1:tid1_2,type2:tid2_1%60");
        resp = getResponse(client, uri);
        entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
        });
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
        assertNotNull(entities);
        assertEquals(1, entities.size());
        assertTrue("Entity with id_1 should have been present in response.", entities.contains(newEntity("app", "id_1")));
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/timeline/" + "clusters/cluster1/apps/app1/entities/app?isrelatedto=" + "type1:tid1_1:tid1_2,type2:tid2_1%60");
        resp = getResponse(client, uri);
        entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
        });
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
        assertNotNull(entities);
        assertEquals(1, entities.size());
        assertTrue("Entity with id_1 should have been present in response.", entities.contains(newEntity("app", "id_1")));
    } finally {
        client.destroy();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) GenericType(com.sun.jersey.api.client.GenericType) Set(java.util.Set) Client(com.sun.jersey.api.client.Client) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) URI(java.net.URI) Test(org.junit.Test)

Aggregations

TimelineEntity (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity)155 Test (org.junit.Test)98 TimelineDataToRetrieve (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve)54 TimelineReaderContext (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext)54 TimelineEntityFilters (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineEntityFilters)46 HashSet (java.util.HashSet)37 Client (com.sun.jersey.api.client.Client)36 ClientResponse (com.sun.jersey.api.client.ClientResponse)36 URI (java.net.URI)36 TimelineMetric (org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric)33 Set (java.util.Set)32 TimelineEntities (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities)27 TimelineEvent (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent)26 TimelineFilterList (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)26 HashMap (java.util.HashMap)23 Configuration (org.apache.hadoop.conf.Configuration)21 GenericType (com.sun.jersey.api.client.GenericType)14 HBaseTimelineWriterImpl (org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriterImpl)12 TimelinePrefixFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter)10 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)9