分享

YARN Timeline Server

helianthus 发表于 2016-1-3 19:36:40 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 7472
本帖最后由 helianthus 于 2016-1-3 19:39 编辑
问题导读:
1.如何将应用程序的相关数据发布到timeline server?
2.如何通过web UI访问应用程序的历史信息?





1.Publishing application specific data
    开发者可以通过创建TimelineEntity 和TimelineEvent 实例来将需要的应用程序信息记录下来。然后通过TimelineClient  API将这些entities和events发布到timeline server。例如:
[mw_shl_code=java,true]// Create and start the Timeline client
TimelineClient client = TimelineClient.createTimelineClient();
client.init(conf);
client.start();

try {
  TimelineDomain myDomain = new TimelineDomain();
  myDomain.setID("MyDomain");
  // Compose other Domain info ....

  client.putDomain(myDomain);

  TimelineEntity myEntity = new TimelineEntity();
  myEntity.setDomainId(myDomain.getId());
  myEntity.setEntityType("APPLICATION");
  myEntity.setEntityID("MyApp1")
  // Compose other entity info

  TimelinePutResponse response = client.putEntities(entity);

  TimelineEvent event = new TimelineEvent();
  event.setEventType("APP_FINISHED");
  event.setTimestamp(System.currentTimeMillis());
  event.addEventInfo("Exit Status", "SUCCESS");
  // Compose other Event info ....

  myEntity.addEvent(event);
  TimelinePutResponse response = timelineClient.putEntities(entity);

} catch (IOException e) {
  // Handle the exception
} catch (RuntimeException e) {
  // In Hadoop 2.6, if attempts submit information to the Timeline Server fail more than the retry limit,
  // a RuntimeException will be raised. This may change in future releases, being
  // replaced with a IOException that is (or wraps) that which triggered retry failures.
} catch (YarnException e) {
  // Handle the exception
} finally {
  // Stop the Timeline client
  client.stop();
}[/mw_shl_code]
(1)发布数据到timeline server是一个同步操作,直到执行成功才返回;
(2)timelineClient实现类是YARN Service API的子类,将它当做一个组件式服务,更便于对其生命周期的管理;
(3)返回值中调用的putEntities()是一个TimelinePutResponse对象,返回结果包括了一组被timeline server拒绝的timeline entities及其对应的错误码。
在hadoop2.6和2.7版本中,这类错误码包括:
1 No start time
2 IOException
3 System Filter conflict (reserved filter key used)
4 Access Denied
5 No domain
6 Forbidden relation
  在更新entity时,需要注意:
(1)对于已经存在entity,不能更改其domain ID;
(2)修改了主过滤器的值,新的值将会以append的方式被追加到旧值后面,原先的值依然存在;
(3)建议对entity的所有更新操作都使用相同的主过滤器

2.Generic Data Web UI
用户可以通过下面的web UI访问应用程序的通用的历史信息:
[mw_shl_code=java,true]http(s)://<timeline server http(s) address:port>/applicationhistory[/mw_shl_code]
(1)Timeline Server REST API V1
目前只支持通过调用REST API的方式来查询timeline server。在YARN库中还没有客户端实现。在java语言的实现框架中,以Jersey 客户端来访问服务端比较高效,及时在安全模式下。
V1版本的REST API的实现放在timeline server web服务的/ws/v1/timeline/路径下。关于其API这里有个不甚规范的描述:
执行:
[mw_shl_code=applescript,true]GET /ws/v1/timeline/[/mw_shl_code]
返回一个json对象描述的服务器实例:
[mw_shl_code=applescript,true]{"About":"Timeline API"}[/mw_shl_code]
(2)Domain summary information /ws/v1/timeline/domain
[mw_shl_code=applescript,true]GET /ws/v1/timeline/domain?owner=$OWNER[/mw_shl_code]
返回一组属于某个具体用户的domains,且这些domains以JSON形式表示的TimelineDomains数据结构,如果没有经过身份验证,则必须通过GET对用户进行设置;对于已经认证的请求,默认该用户为调用者:
[mw_shl_code=applescript,true]PUT /ws/v1/timeline/domain[/mw_shl_code]
如上面的命令,对于上面的路径执行一个序列化TimelineDomain结构的PUT操作,会将domain添加到一组属于当前或者某个具体user的domain中,一次成功操作将会返回值为200的操作码和一个无错误信息的TimelinePutResponse。





没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条