public Map<String, Object> getInfo() { if (real == null) { return info; } else { return real.getInfo(); } }
Set<TimelineEntity> createEntities(int noOfUsers, String userKey) { Set<TimelineEntity> entities = new LinkedHashSet<>(); for (int i = 0; i < noOfUsers; i++) { TimelineEntity e = new TimelineEntity(); e.setType("user" + i); e.setId("user" + i); e.getInfo().put(userKey, "user" + i); entities.add(e); } return entities; }
@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 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()); }
entity.getInfo().put(TimelineReaderUtils.FROMID_KEY, parseRowKey.getRowKeyAsString()); return entity;
entity.getInfo().put(TimelineReaderUtils.FROMID_KEY, parseRowKey.getRowKeyAsString()); return entity;
entity.getInfo().put(TimelineReaderUtils.FROMID_KEY, rowKey.getRowKeyAsString()); return entity;
entity.addInfo("test info key 3", true); Assert.assertTrue( entity.getInfo().get("test info key 3") instanceof Boolean); entity.addConfig("test config key 1", "test config value 1"); entity.addConfig("test config key 2", "test config value 2");
ColumnRWHelper.store(rowKey, applicationTable, ApplicationColumn.FLOW_VERSION, null, flowVersion); storeInfo(rowKey, te.getInfo(), flowVersion, ApplicationColumnPrefix.INFO, applicationTable); storeMetrics(rowKey, te.getMetrics(), ApplicationColumnPrefix.METRIC, ColumnRWHelper.store(rowKey, entityTable, EntityColumn.FLOW_VERSION, null, flowVersion); storeInfo(rowKey, te.getInfo(), flowVersion, EntityColumnPrefix.INFO, entityTable); storeMetrics(rowKey, te.getMetrics(), EntityColumnPrefix.METRIC, ColumnRWHelper.store(rowKey, subApplicationTable, SubApplicationColumn.FLOW_VERSION, null, flowVersion); storeInfo(rowKey, te.getInfo(), flowVersion, SubApplicationColumnPrefix.INFO, subApplicationTable); storeMetrics(rowKey, te.getMetrics(), SubApplicationColumnPrefix.METRIC,