热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.hadoop.yarn.api.records.timeline.TimelineEvent类的使用及代码示例

本文整理了Java中org.apache.hadoop.yarn.api.records.timeline.TimelineEvent类的一些代码示例,展示了

本文整理了Java中org.apache.hadoop.yarn.api.records.timeline.TimelineEvent类的一些代码示例,展示了TimelineEvent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimelineEvent类的具体详情如下:
包路径:org.apache.hadoop.yarn.api.records.timeline.TimelineEvent
类名称:TimelineEvent

TimelineEvent介绍

[英]The class that contains the information of an event that is related to some conceptual entity of an application. Users are free to define what the event means, such as starting an application, getting allocated a container and etc.
[中]包含与应用程序的某个概念实体相关的事件信息的类。用户可以自由定义事件的含义,例如启动应用程序、分配容器等。

代码示例

代码示例来源:origin: alibaba/jstorm

private static void publishContainerStartEvent(
final TimelineClient timelineClient, Container container, String domainId,
UserGroupInformation ugi) {
final TimelineEntity entity = new TimelineEntity();
entity.setEntityId(container.getId().toString());
entity.setEntityType(DSEntity.DS_CONTAINER.toString());
entity.setDomainId(domainId);
entity.addPrimaryFilter(JOYConstants.USER, ugi.getShortUserName());
TimelineEvent event = new TimelineEvent();
event.setTimestamp(System.currentTimeMillis());
event.setEventType(DSEvent.DS_CONTAINER_START.toString());
event.addEventInfo(JOYConstants.NODE, container.getNodeId().toString());
event.addEventInfo(JOYConstants.RESOURCES, container.getResource().toString());
entity.addEvent(event);
try {
ugi.doAs(new PrivilegedExceptionAction() {
@Override
public TimelinePutResponse run() throws Exception {
return timelineClient.putEntities(entity);
}
});
} catch (Exception e) {
LOG.error("Container start event could not be published for "
+ container.getId().toString(),
e instanceof UndeclaredThrowableException ? e.getCause() : e);
}
}

代码示例来源:origin: alibaba/jstorm

private static void publishApplicationAttemptEvent(
final TimelineClient timelineClient, String appAttemptId,
DSEvent appEvent, String domainId, UserGroupInformation ugi) {
final TimelineEntity entity = new TimelineEntity();
entity.setEntityId(appAttemptId);
entity.setEntityType(DSEntity.DS_APP_ATTEMPT.toString());
entity.setDomainId(domainId);
entity.addPrimaryFilter(JOYConstants.USER, ugi.getShortUserName());
TimelineEvent event = new TimelineEvent();
event.setEventType(appEvent.toString());
event.setTimestamp(System.currentTimeMillis());
entity.addEvent(event);
try {
timelineClient.putEntities(entity);
} catch (YarnException e) {
LOG.error("App Attempt "
+ (appEvent.equals(DSEvent.DS_APP_ATTEMPT_START) ? JOYConstants.START : JOYConstants.END)
+ " event could not be published for "
+ appAttemptId.toString(), e);
} catch (IOException e) {
LOG.error("App Attempt "
+ (appEvent.equals(DSEvent.DS_APP_ATTEMPT_START) ? JOYConstants.START : JOYConstants.END)
+ " event could not be published for "
+ appAttemptId.toString(), e);
}
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-timeline-pluginstorage

/**
* Create a test event
*/
static TimelineEvent createEvent(long timestamp, String type, Map Object> info) {
TimelineEvent event = new TimelineEvent();
event.setTimestamp(timestamp);
event.setEventType(type);
event.setEventInfo(info);
return event;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

partEvents.setEntityType("entity type " + j);
for (int i = 0; i <2; ++i) {
TimelineEvent event = new TimelineEvent();
event.setTimestamp(System.currentTimeMillis());
event.setEventType("event type " + i);
event.addEventInfo("key1", "val1");
event.addEventInfo("key2", "val2");
partEvents.addEvent(event);
Assert.assertEquals(2, partEvents1.getEvents().size());
TimelineEvent event11 = partEvents1.getEvents().get(0);
Assert.assertEquals("event type 0", event11.getEventType());
Assert.assertEquals(2, event11.getEventInfo().size());
TimelineEvent event12 = partEvents1.getEvents().get(1);
Assert.assertEquals("event type 1", event12.getEventType());
Assert.assertEquals(2, event12.getEventInfo().size());
TimelineEvents.EventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
Assert.assertEquals("entity id 1", partEvents2.getEntityId());
Assert.assertEquals(2, partEvents2.getEvents().size());
TimelineEvent event21 = partEvents2.getEvents().get(0);
Assert.assertEquals("event type 0", event21.getEventType());
Assert.assertEquals(2, event21.getEventInfo().size());
TimelineEvent event22 = partEvents2.getEvents().get(1);
Assert.assertEquals("event type 1", event22.getEventType());
Assert.assertEquals(2, event22.getEventInfo().size());

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-applicationhistoryservice

if (events != null) {
for (TimelineEvent event : events) {
if (event.getEventType().equals(
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
createdTime = event.getTimestamp();
} else if (event.getEventType().equals(
ApplicationMetricsConstants.FINISHED_EVENT_TYPE)) {
finishedTime = event.getTimestamp();
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

private static void createAppModifiedEvent(ApplicationId appId,
TimelineEvent tEvent, long updatedTimeIndex, String queue, int priority) {
tEvent.setEventType(ApplicationMetricsConstants.UPDATED_EVENT_TYPE);
tEvent.setTimestamp(Integer.MAX_VALUE + updatedTimeIndex + appId.getId());
Map eventInfo = new HashMap();
eventInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, queue);
eventInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO,
priority);
tEvent.setEventInfo(eventInfo);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

TimelineEvent event = new TimelineEvent();
List> eventInfoList =
new ArrayList>();
eventInfo.put("ekey2", "eval2");
eventInfoList.add(eventInfo);
event.setEventInfo(null);
for (Map eventInfoToSet : eventInfoList) {
event.setEventInfo(eventInfoToSet);
assertEventInfo(event);
event.addEventInfo(eventInfoToAdd);
assertEventInfo(event);

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-applicationhistoryservice

if (events != null) {
for (TimelineEvent event : events) {
if (event.getEventType().equals(
AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;
.toString());
} else if (event.getEventType().equals(
AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-applicationhistoryservice

break;
if (event.getTimestamp() <= windowStart) {
continue;
if (event.getTimestamp() > windowEnd) {
continue;
if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
continue;

代码示例来源:origin: io.hops/hadoop-yarn-common

private static void assertEventInfo(TimelineEvent event) {
Assert.assertNotNull(event);
Assert.assertNotNull(event.getEventInfoJAXB());
Assert.assertTrue(event.getEventInfo() instanceof HashMap);
Assert.assertTrue(event.getEventInfoJAXB() instanceof HashMap);
Assert.assertEquals(event.getEventInfo(), event.getEventInfoJAXB());
}
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

if (e.getTimestamp() startTime = e.getTimestamp();

代码示例来源:origin: ch.cern.hadoop/hadoop-mapreduce-client-jobclient

Assert.assertEquals(EventType.AM_STARTED.toString(),
tEntity.getEvents().get(tEntity.getEvents().size() - 1)
.getEventType());
Assert.assertEquals(EventType.JOB_FINISHED.toString(),
tEntity.getEvents().get(0).getEventType());
Assert.assertEquals(EventType.AM_STARTED.toString(),
tEntity.getEvents().get(tEntity.getEvents().size() - 1)
.getEventType());
Assert.assertEquals(EventType.JOB_FAILED.toString(),
tEntity.getEvents().get(0).getEventType());
} finally {
if (cluster != null) {

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

/**
* Create a test event
*/
private static TimelineEvent createEvent(long timestamp, String type, Map Object> info) {
TimelineEvent event = new TimelineEvent();
event.setTimestamp(timestamp);
event.setEventType(type);
event.setEventInfo(info);
return event;
}

代码示例来源:origin: apache/hive

TimelineEntity createPostHookEvent(String queryId, long stopTime, String user, String requestuser, boolean success,
String opId, Map durations, String domainId) throws Exception {
LOG.info("Received post-hook notification for :" + queryId);
TimelineEntity atsEntity = new TimelineEntity();
atsEntity.setEntityId(queryId);
atsEntity.setEntityType(EntityTypes.HIVE_QUERY_ID.name());
atsEntity.addPrimaryFilter(PrimaryFilterTypes.user.name(), user);
atsEntity.addPrimaryFilter(PrimaryFilterTypes.requestuser.name(), requestuser);
if (opId != null) {
atsEntity.addPrimaryFilter(PrimaryFilterTypes.operationid.name(), opId);
}
TimelineEvent stopEvt = new TimelineEvent();
stopEvt.setEventType(EventTypes.QUERY_COMPLETED.name());
stopEvt.setTimestamp(stopTime);
atsEntity.addEvent(stopEvt);
atsEntity.addOtherInfo(OtherInfoTypes.STATUS.name(), success);
// Perf times
JSONObject perfObj = new JSONObject(new LinkedHashMap<>());
for (Map.Entry entry : durations.entrySet()) {
perfObj.put(entry.getKey(), entry.getValue());
}
atsEntity.addOtherInfo(OtherInfoTypes.PERF.name(), perfObj.toString());
atsEntity.setDomainId(domainId);
return atsEntity;
}

代码示例来源:origin: io.hops/hadoop-yarn-common

partEvents.setEntityType("entity type " + j);
for (int i = 0; i <2; ++i) {
TimelineEvent event = new TimelineEvent();
event.setTimestamp(System.currentTimeMillis());
event.setEventType("event type " + i);
event.addEventInfo("key1", "val1");
event.addEventInfo("key2", "val2");
partEvents.addEvent(event);
Assert.assertEquals(2, partEvents1.getEvents().size());
TimelineEvent event11 = partEvents1.getEvents().get(0);
Assert.assertEquals("event type 0", event11.getEventType());
Assert.assertEquals(2, event11.getEventInfo().size());
TimelineEvent event12 = partEvents1.getEvents().get(1);
Assert.assertEquals("event type 1", event12.getEventType());
Assert.assertEquals(2, event12.getEventInfo().size());
TimelineEvents.EventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
Assert.assertEquals("entity id 1", partEvents2.getEntityId());
Assert.assertEquals(2, partEvents2.getEvents().size());
TimelineEvent event21 = partEvents2.getEvents().get(0);
Assert.assertEquals("event type 0", event21.getEventType());
Assert.assertEquals(2, event21.getEventInfo().size());
TimelineEvent event22 = partEvents2.getEvents().get(1);
Assert.assertEquals("event type 1", event22.getEventType());
Assert.assertEquals(2, event22.getEventInfo().size());

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-applicationhistoryservice

if (events != null) {
for (TimelineEvent event : events) {
if (event.getEventType().equals(
ApplicationMetricsConstants.CREATED_EVENT_TYPE)) {
createdTime = event.getTimestamp();
} else if (event.getEventType().equals(
ApplicationMetricsConstants.FINISHED_EVENT_TYPE)) {
finishedTime = event.getTimestamp();
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;

代码示例来源:origin: io.hops/hadoop-yarn-common

TimelineEvent event = new TimelineEvent();
List> eventInfoList =
new ArrayList>();
eventInfo.put("ekey2", "eval2");
eventInfoList.add(eventInfo);
event.setEventInfo(null);
for (Map eventInfoToSet : eventInfoList) {
event.setEventInfo(eventInfoToSet);
assertEventInfo(event);
event.addEventInfo(eventInfoToAdd);
assertEventInfo(event);

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-applicationhistoryservice

if (events != null) {
for (TimelineEvent event : events) {
if (event.getEventType().equals(
AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;
.toString());
} else if (event.getEventType().equals(
AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
Map eventInfo = event.getEventInfo();
if (eventInfo == null) {
continue;

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-applicationhistoryservice

break;
if (event.getTimestamp() <= windowStart) {
continue;
if (event.getTimestamp() > windowEnd) {
continue;
if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
continue;

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

private static void assertEventInfo(TimelineEvent event) {
Assert.assertNotNull(event);
Assert.assertNotNull(event.getEventInfoJAXB());
Assert.assertTrue(event.getEventInfo() instanceof HashMap);
Assert.assertTrue(event.getEventInfoJAXB() instanceof HashMap);
Assert.assertEquals(event.getEventInfo(), event.getEventInfoJAXB());
}
}

推荐阅读
author-avatar
Just忽略我_559
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有