@XmlElement(name = "metrics") public Set<TimelineMetric> getMetrics() { if (real == null) { return metrics; } else { return real.getMetrics(); } }
private void storeFlowMetricsAppRunning(FlowRunRowKey flowRunRowKey, String appId, TimelineEntity te) throws IOException { Set<TimelineMetric> metrics = te.getMetrics(); if (metrics != null) { byte[] rowKey = flowRunRowKey.getRowKey(); storeFlowMetrics(rowKey, metrics, AggregationCompactionDimension.APPLICATION_ID.getAttribute(appId), AggregationOperation.SUM.getAttribute()); } }
private void storeAppFinishedInFlowRunTable(FlowRunRowKey flowRunRowKey, String appId, TimelineEntity te, long appFinishedTimeStamp) throws IOException { byte[] rowKey = flowRunRowKey.getRowKey(); Attribute attributeAppId = AggregationCompactionDimension.APPLICATION_ID.getAttribute(appId); ColumnRWHelper.store(rowKey, flowRunTable, FlowRunColumn.MAX_END_TIME, 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()); } }
TimelineEntity entity = FileSystemTimelineReaderImpl. getTimelineRecordFromJSON(strLine.trim(), TimelineEntity.class); metricsCount = entity.getMetrics().size(); assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) {
.getTimelineRecordFromJSON(strLine.trim(), org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity.class); metricsCount = entity.getMetrics().size(); assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) {
TimelineEntity resultEntity = TimelineCollector.aggregateEntities( testEntities, "test_result", "TEST_AGGR", true); assertEquals(resultEntity.getMetrics().size(), groups * 3); Set<TimelineMetric> metrics = resultEntity.getMetrics(); for (TimelineMetric m : metrics) { if (m.getId().startsWith("HDFS_BYTES_WRITE")) { TimelineEntity resultEntity1 = TimelineCollector.aggregateEntities( testEntities1, "test_result", "TEST_AGGR", false); assertEquals(resultEntity1.getMetrics().size(), 3); Set<TimelineMetric> metrics = resultEntity1.getMetrics(); for (TimelineMetric m : metrics) { if (m.getId().equals("HDFS_BYTES_WRITE")) {
@Test public void testGetEntityAllFields() throws Exception { // All fields of TimelineEntity will be returned. TimelineEntity result = reader.getEntity( new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", "id_1"), new TimelineDataToRetrieve(null, null, EnumSet.of(Field.ALL), null, null, null)); Assert.assertEquals( (new TimelineEntity.Identifier("app", "id_1")).toString(), result.getIdentifier().toString()); Assert.assertEquals((Long)1425016502000L, result.getCreatedTime()); Assert.assertEquals(3, result.getConfigs().size()); Assert.assertEquals(3, result.getMetrics().size()); // All fields including events will be returned. Assert.assertEquals(2, result.getEvents().size()); }
@Test public void testGetEntityCustomFields() throws Exception { // Specified fields in addition to default view will be returned. TimelineEntity result = reader.getEntity( new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", "id_1"), new TimelineDataToRetrieve(null, null, EnumSet.of(Field.INFO, Field.CONFIGS, Field.METRICS), null, null, null)); Assert.assertEquals( (new TimelineEntity.Identifier("app", "id_1")).toString(), result.getIdentifier().toString()); Assert.assertEquals((Long)1425016502000L, result.getCreatedTime()); Assert.assertEquals(3, result.getConfigs().size()); Assert.assertEquals(3, result.getMetrics().size()); Assert.assertEquals(2, result.getInfo().size()); // No events will be returned Assert.assertEquals(0, result.getEvents().size()); }
TimelineEntityType.YARN_APPLICATION.toString()); TimelineMetric aggregatedMetric = aggregatedEntity.getMetrics().iterator().next(); assertEquals(750L, aggregatedMetric.getValues().values().iterator().next()); assertEquals(TimelineMetricOperation.SUM, aggregateWithoutGroupId(aggregationGroups, currContext.getAppId(), TimelineEntityType.YARN_APPLICATION.toString()); aggregatedMetric = aggregatedEntity.getMetrics().iterator().next(); TimelineEntityType.YARN_APPLICATION.toString()); aggregatedMetric = aggregatedEntity.getMetrics().iterator().next(); assertEquals(150L, aggregatedMetric.getValues().values().iterator().next()); assertEquals(TimelineMetricOperation.SUM,
@Test public void testGetEntityCustomFields() throws Exception { Client client = createClient(); try { // Fields are case insensitive. URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app/id_1?" + "fields=CONFIGS,Metrics,info"); 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(3, entity.getConfigs().size()); assertEquals(3, entity.getMetrics().size()); assertTrue("UID should be present", entity.getInfo().containsKey(TimelineReaderUtils.UID_KEY)); // Includes UID. assertEquals(3, entity.getInfo().size()); // No events will be returned as events are not part of fields. assertEquals(0, entity.getEvents().size()); } finally { client.destroy(); } }
@Test public void testGetEntityAllFields() throws Exception { Client client = createClient(); try { URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app/id_1?" + "fields=ALL"); 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(3, entity.getConfigs().size()); assertEquals(3, entity.getMetrics().size()); assertTrue("UID should be present", entity.getInfo().containsKey(TimelineReaderUtils.UID_KEY)); // Includes UID. assertEquals(3, entity.getInfo().size()); assertEquals(2, entity.getEvents().size()); } finally { client.destroy(); } }
@Test public void testGetEntityByClusterAndApp() throws Exception { // Cluster and AppId should be enough to get an entity. TimelineEntity result = reader.getEntity( new TimelineReaderContext("cluster1", null, null, null, "app1", "app", "id_1"), new TimelineDataToRetrieve(null, null, null, null, null, null)); Assert.assertEquals( (new TimelineEntity.Identifier("app", "id_1")).toString(), result.getIdentifier().toString()); Assert.assertEquals((Long)1425016502000L, result.getCreatedTime()); Assert.assertEquals(0, result.getConfigs().size()); Assert.assertEquals(0, result.getMetrics().size()); }
@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(); } }
@Test public void testGetEntityDefaultView() throws Exception { // If no fields are specified, entity is returned with default view i.e. // only the id, type and created time. TimelineEntity result = reader.getEntity( new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", "id_1"), new TimelineDataToRetrieve(null, null, null, null, null, null)); Assert.assertEquals( (new TimelineEntity.Identifier("app", "id_1")).toString(), result.getIdentifier().toString()); Assert.assertEquals((Long)1425016502000L, result.getCreatedTime()); Assert.assertEquals(0, result.getConfigs().size()); Assert.assertEquals(0, result.getMetrics().size()); }
storeInfo(rowKey, te.getInfo(), flowVersion, ApplicationColumnPrefix.INFO, applicationTable); storeMetrics(rowKey, te.getMetrics(), ApplicationColumnPrefix.METRIC, applicationTable); storeEvents(rowKey, te.getEvents(), ApplicationColumnPrefix.EVENT, storeInfo(rowKey, te.getInfo(), flowVersion, EntityColumnPrefix.INFO, entityTable); storeMetrics(rowKey, te.getMetrics(), EntityColumnPrefix.METRIC, entityTable); storeEvents(rowKey, te.getEvents(), EntityColumnPrefix.EVENT, storeInfo(rowKey, te.getInfo(), flowVersion, SubApplicationColumnPrefix.INFO, subApplicationTable); storeMetrics(rowKey, te.getMetrics(), SubApplicationColumnPrefix.METRIC, subApplicationTable); storeEvents(rowKey, te.getEvents(), SubApplicationColumnPrefix.EVENT,