public Map<String, String> getConfigs() { if (real == null) { return configs; } else { return real.getConfigs(); } }
configSize += size; if (configSize > JobHistoryEventUtils.ATS_CONFIG_PUBLISH_SIZE_BYTES) { if (jobEntityForConfigs.getConfigs().size() > 0) { timelineV2Client.putEntities(jobEntityForConfigs); timelineV2Client.putEntities(appEntityForConfigs);
@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 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 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 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 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 { // 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()); }
storeEvents(rowKey, te.getEvents(), ApplicationColumnPrefix.EVENT, applicationTable); storeConfig(rowKey, te.getConfigs(), ApplicationColumnPrefix.CONFIG, applicationTable); storeRelations(rowKey, te.getIsRelatedToEntities(), storeEvents(rowKey, te.getEvents(), EntityColumnPrefix.EVENT, entityTable); storeConfig(rowKey, te.getConfigs(), EntityColumnPrefix.CONFIG, entityTable); storeRelations(rowKey, te.getIsRelatedToEntities(), storeEvents(rowKey, te.getEvents(), SubApplicationColumnPrefix.EVENT, subApplicationTable); storeConfig(rowKey, te.getConfigs(), SubApplicationColumnPrefix.CONFIG, subApplicationTable); storeRelations(rowKey, te.getIsRelatedToEntities(),