Search in sources :

Example 16 with TimelineMetric

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

the class TestTimelineReaderWebServicesHBaseStorage method newMetric.

private static TimelineMetric newMetric(TimelineMetric.Type type, String id, long t, Number value) {
    TimelineMetric metric = new TimelineMetric(type);
    metric.setId(id);
    metric.addValue(t, value);
    return metric;
}
Also used : TimelineMetric(org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric)

Example 17 with TimelineMetric

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

the class TestTimelineReaderWebServicesHBaseStorage method testGetEntityDataToRetrieve.

/**
   * Tests if specific configs and metrics are retrieve for getEntity call.
   */
@Test
public void testGetEntityDataToRetrieve() throws Exception {
    Client client = createClient();
    try {
        URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/application_1111111111_1111/" + "entities/type1/entity2?confstoretrieve=cfg_,configuration_");
        ClientResponse resp = getResponse(client, uri);
        TimelineEntity entity = resp.getEntity(TimelineEntity.class);
        assertNotNull(entity);
        assertEquals("entity2", entity.getId());
        assertEquals("type1", entity.getType());
        assertEquals(2, entity.getConfigs().size());
        for (String configKey : entity.getConfigs().keySet()) {
            assertTrue(configKey.startsWith("configuration_") || configKey.startsWith("cfg_"));
        }
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/application_1111111111_1111/" + "entities/type1/entity2?confstoretrieve=!(cfg_,configuration_)");
        resp = getResponse(client, uri);
        entity = resp.getEntity(TimelineEntity.class);
        assertNotNull(entity);
        assertEquals("entity2", entity.getId());
        assertEquals("type1", entity.getType());
        assertEquals(1, entity.getConfigs().size());
        for (String configKey : entity.getConfigs().keySet()) {
            assertTrue(configKey.startsWith("config_"));
        }
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/application_1111111111_1111/" + "entities/type1/entity2?metricstoretrieve=MAP1_,HDFS_");
        resp = getResponse(client, uri);
        entity = resp.getEntity(TimelineEntity.class);
        assertNotNull(entity);
        assertEquals("entity2", entity.getId());
        assertEquals("type1", entity.getType());
        assertEquals(2, entity.getMetrics().size());
        for (TimelineMetric metric : entity.getMetrics()) {
            assertTrue(metric.getId().startsWith("MAP1_") || metric.getId().startsWith("HDFS_"));
        }
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/application_1111111111_1111/" + "entities/type1/entity2?metricstoretrieve=!(MAP1_,HDFS_)");
        resp = getResponse(client, uri);
        entity = resp.getEntity(TimelineEntity.class);
        assertNotNull(entity);
        assertEquals("entity2", entity.getId());
        assertEquals("type1", entity.getType());
        assertEquals(1, entity.getMetrics().size());
        for (TimelineMetric metric : entity.getMetrics()) {
            assertTrue(metric.getId().startsWith("MAP11_"));
            assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
            assertEquals(1, metric.getValues().size());
        }
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/application_1111111111_1111/" + "entities/type1/entity2?metricstoretrieve=!(MAP1_,HDFS_)&" + "metricslimit=5");
        resp = getResponse(client, uri);
        entity = resp.getEntity(TimelineEntity.class);
        assertNotNull(entity);
        assertEquals("entity2", entity.getId());
        assertEquals("type1", entity.getType());
        assertEquals(1, entity.getMetrics().size());
        for (TimelineMetric metric : entity.getMetrics()) {
            assertTrue(metric.getId().startsWith("MAP11_"));
            assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
        }
    } finally {
        client.destroy();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TimelineMetric(org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric) 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 18 with TimelineMetric

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

the class TestTimelineReaderWebServicesHBaseStorage method testGetFlowRunsMetricsToRetrieve.

@Test
public void testGetFlowRunsMetricsToRetrieve() throws Exception {
    Client client = createClient();
    try {
        URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/users/user1/flows/flow_name/runs?" + "metricstoretrieve=MAP_,HDFS_");
        ClientResponse resp = getResponse(client, uri);
        Set<FlowRunEntity> entities = resp.getEntity(new GenericType<Set<FlowRunEntity>>() {
        });
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; charset=utf-8", resp.getType().toString());
        assertNotNull(entities);
        assertEquals(2, entities.size());
        int metricCnt = 0;
        for (FlowRunEntity entity : entities) {
            metricCnt += entity.getMetrics().size();
            for (TimelineMetric metric : entity.getMetrics()) {
                assertTrue(metric.getId().startsWith("MAP_") || metric.getId().startsWith("HDFS_"));
            }
        }
        assertEquals(3, metricCnt);
        uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/users/user1/flows/flow_name/runs?" + "metricstoretrieve=!(MAP_,HDFS_)");
        resp = getResponse(client, uri);
        entities = resp.getEntity(new GenericType<Set<FlowRunEntity>>() {
        });
        assertEquals(MediaType.APPLICATION_JSON_TYPE + "; charset=utf-8", resp.getType().toString());
        assertNotNull(entities);
        assertEquals(2, entities.size());
        metricCnt = 0;
        for (FlowRunEntity entity : entities) {
            metricCnt += entity.getMetrics().size();
            for (TimelineMetric metric : entity.getMetrics()) {
                assertTrue(metric.getId().startsWith("MAP1_"));
            }
        }
        assertEquals(1, metricCnt);
    } finally {
        client.destroy();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TimelineMetric(org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric) GenericType(com.sun.jersey.api.client.GenericType) Set(java.util.Set) HashSet(java.util.HashSet) FlowRunEntity(org.apache.hadoop.yarn.api.records.timelineservice.FlowRunEntity) Client(com.sun.jersey.api.client.Client) URI(java.net.URI) Test(org.junit.Test)

Example 19 with TimelineMetric

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

the class TimelineEntityConverterV2 method addMetrics.

private void addMetrics(TimelineEntity entity, Counters counters) {
    for (CounterGroup g : counters) {
        String groupName = g.getName();
        for (Counter c : g) {
            String name = groupName + ":" + c.getName();
            TimelineMetric metric = new TimelineMetric();
            metric.setId(name);
            metric.addValue(System.currentTimeMillis(), c.getValue());
            entity.addMetric(metric);
        }
    }
}
Also used : TimelineMetric(org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric)

Example 20 with TimelineMetric

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

the class HBaseTimelineWriterImpl method storeAppFinishedInFlowRunTable.

/*
   * Update the {@link FlowRunTable} with Application Finished information
   */
private void storeAppFinishedInFlowRunTable(FlowRunRowKey flowRunRowKey, String appId, TimelineEntity te, long appFinishedTimeStamp) throws IOException {
    byte[] rowKey = flowRunRowKey.getRowKey();
    Attribute attributeAppId = AggregationCompactionDimension.APPLICATION_ID.getAttribute(appId);
    FlowRunColumn.MAX_END_TIME.store(rowKey, flowRunTable, null, appFinishedTimeStamp, attributeAppId);
    // store the final value of metrics since application has finished
    Set<TimelineMetric> metrics = te.getMetrics();
    if (metrics != null) {
        storeFlowMetrics(rowKey, metrics, attributeAppId, AggregationOperation.SUM_FINAL.getAttribute());
    }
}
Also used : TimelineMetric(org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric) Attribute(org.apache.hadoop.yarn.server.timelineservice.storage.flow.Attribute)

Aggregations

TimelineMetric (org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric)47 TimelineEntity (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity)33 Test (org.junit.Test)22 HashSet (java.util.HashSet)21 HashMap (java.util.HashMap)17 TimelineEntities (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities)13 TimelineEvent (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent)12 Set (java.util.Set)11 Client (com.sun.jersey.api.client.Client)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)9 URI (java.net.URI)9 Configuration (org.apache.hadoop.conf.Configuration)9 TimelineDataToRetrieve (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve)9 TimelineReaderContext (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext)9 TimelineEntityFilters (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineEntityFilters)7 GenericType (com.sun.jersey.api.client.GenericType)5 Map (java.util.Map)5 TimelineFilterList (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)5 TimelinePrefixFilter (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelinePrefixFilter)5 IOException (java.io.IOException)4