private void putEntity(TimelineEntity entity, ApplicationId appId) { try { if (LOG.isDebugEnabled()) { LOG.debug("Publishing the entity " + entity + ", JSON-style content: " + TimelineUtils.dumpTimelineRecordtoJSON(entity)); } TimelineV2Client timelineClient = getTimelineClient(appId); if (timelineClient != null) { timelineClient.putEntities(entity); } else { LOG.error("Seems like client has been removed before the entity " + "could be published for " + entity); } } catch (IOException e) { LOG.error("Error when publishing entity " + entity); if (LOG.isDebugEnabled()) { LOG.debug("Error when publishing entity " + entity, e); } } catch (YarnException e) { LOG.error("Error when publishing entity " + entity, e.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug("Error when publishing entity " + entity, e); } } }
private void publishAndVerifyEntity(ApplicationId appId, File entityTypeDir, String entityType, int numEntities) throws Exception { TimelineV2Client client = createTimelineClientForUGI(appId); try { // Sync call. Results available immediately. client.putEntities(createEntity("entity1", entityType)); assertEquals(numEntities, entityTypeDir.listFiles().length); verifyEntity(entityTypeDir, "entity1", entityType); // Async call. client.putEntitiesAsync(createEntity("entity2", entityType)); } finally { client.stop(); } }
@Test public void testPutEntities() throws Exception { TimelineV2Client client = TimelineV2Client.createTimelineClient(ApplicationId.newInstance(0, 1)); try { // Set the timeline service address manually. client.setTimelineCollectorInfo(CollectorInfo.newInstance( collectorManager.getRestServerBindAddress())); client.init(conf); client.start(); TimelineEntity entity = new TimelineEntity(); entity.setType("test entity type"); entity.setId("test entity id"); TimelineMetric metric = new TimelineMetric(TimelineMetric.Type.TIME_SERIES); metric.setId("test metric id"); metric.addValue(1L, 1.0D); metric.addValue(2L, 2.0D); entity.addMetric(metric); client.putEntities(entity); client.putEntitiesAsync(entity); } finally { client.stop(); } }
if (configSize > JobHistoryEventUtils.ATS_CONFIG_PUBLISH_SIZE_BYTES) { if (jobEntityForConfigs.getConfigs().size() > 0) { timelineV2Client.putEntities(jobEntityForConfigs); timelineV2Client.putEntities(appEntityForConfigs); jobEntityForConfigs = createJobEntity(jobId); appEntityForConfigs = new ApplicationEntity(); timelineV2Client.putEntities(jobEntityForConfigs); timelineV2Client.putEntities(appEntityForConfigs);
QueueEntity queue = new QueueEntity(); queue.setId("default_queue"); client.putEntities(cluster, flow, app, appAttempt, container, user, queue); client.putEntitiesAsync(cluster, flow, app, appAttempt, container, user,
timelineV2Client.putEntitiesAsync(tEntity); } else { timelineV2Client.putEntities(tEntity, appEntityWithJobMetrics);