@XmlElement(name = "events") public NavigableSet<TimelineEvent> getEvents() { if (real == null) { return events; } else { return real.getEvents(); } }
/** * @param te TimelineEntity object. * @param eventId event with this id needs to be fetched * @return TimelineEvent if TimelineEntity contains the desired event. */ public static TimelineEvent getApplicationEvent(TimelineEntity te, String eventId) { if (isApplicationEntity(te)) { for (TimelineEvent event : te.getEvents()) { if (event.getId().equals(eventId)) { return event; } } } return null; } }
metricsCount = entity.getMetrics().size(); assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) { if (event.getId().equals(eventForCreatedTime)) { assertTrue(entity.getCreatedTime() > 0);
metricsCount = entity.getMetrics().size(); assertEquals(idPrefix, entity.getIdPrefix()); for (TimelineEvent event : entity.getEvents()) { if (event.getId().equals(eventForCreatedTime)) { assertTrue(entity.getCreatedTime() > 0);
@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()); }
@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(); } }
entity.getEvents().clear();
entity.getEvents().clear();
entity.getEvents().clear();
storeMetrics(rowKey, te.getMetrics(), ApplicationColumnPrefix.METRIC, applicationTable); storeEvents(rowKey, te.getEvents(), ApplicationColumnPrefix.EVENT, applicationTable); storeConfig(rowKey, te.getConfigs(), ApplicationColumnPrefix.CONFIG, storeMetrics(rowKey, te.getMetrics(), EntityColumnPrefix.METRIC, entityTable); storeEvents(rowKey, te.getEvents(), EntityColumnPrefix.EVENT, entityTable); storeConfig(rowKey, te.getConfigs(), EntityColumnPrefix.CONFIG, storeMetrics(rowKey, te.getMetrics(), SubApplicationColumnPrefix.METRIC, subApplicationTable); storeEvents(rowKey, te.getEvents(), SubApplicationColumnPrefix.EVENT, subApplicationTable); storeConfig(rowKey, te.getConfigs(), SubApplicationColumnPrefix.CONFIG,