• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TimelineEvents类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.yarn.api.records.timeline.TimelineEvents的典型用法代码示例。如果您正苦于以下问题:Java TimelineEvents类的具体用法?Java TimelineEvents怎么用?Java TimelineEvents使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TimelineEvents类属于org.apache.hadoop.yarn.api.records.timeline包,在下文中一共展示了TimelineEvents类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testGetEvents

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Test
public void testGetEvents() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("timeline")
      .path("type_1").path("events")
      .queryParam("entityId", "id_1")
      .accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  TimelineEvents events = response.getEntity(TimelineEvents.class);
  Assert.assertNotNull(events);
  Assert.assertEquals(1, events.getAllEvents().size());
  TimelineEvents.EventsOfOneEntity partEvents = events.getAllEvents().get(0);
  Assert.assertEquals(2, partEvents.getEvents().size());
  TimelineEvent event1 = partEvents.getEvents().get(0);
  Assert.assertEquals(456l, event1.getTimestamp());
  Assert.assertEquals("end_event", event1.getEventType());
  Assert.assertEquals(1, event1.getEventInfo().size());
  TimelineEvent event2 = partEvents.getEvents().get(1);
  Assert.assertEquals(123l, event2.getTimestamp());
  Assert.assertEquals("start_event", event2.getEventType());
  Assert.assertEquals(0, event2.getEventInfo().size());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestTimelineWebServices.java


示例2: getEvents

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
/**
 * Get the events whose entities the given user has access to. The meaning of
 * each argument has been documented with
 * {@link TimelineReader#getEntityTimelines}.
 *
 * @see TimelineReader#getEntityTimelines
 */
public TimelineEvents getEvents(
    String entityType,
    SortedSet<String> entityIds,
    SortedSet<String> eventTypes,
    Long windowStart,
    Long windowEnd,
    Long limit,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  long startTime = Time.monotonicNow();
  metrics.incrGetEventsOps();
  try {
    TimelineEvents events = doGetEvents(
        entityType,
        entityIds,
        eventTypes,
        windowStart,
        windowEnd,
        limit,
        callerUGI);
    metrics.incrGetEventsTotal(events.getAllEvents().size());
    return events;
  } finally {
    metrics.addGetEventsTime(Time.monotonicNow() - startTime);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:33,代码来源:TimelineDataManager.java


示例3: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Override
public TimelineEvents getEntityTimelines(String entityType,
    SortedSet<String> entityIds, Long limit, Long windowStart,
    Long windowEnd, Set<String> eventTypes) throws IOException {
  LOG.debug("getEntityTimelines type={} ids={}", entityType, entityIds);
  TimelineEvents returnEvents = new TimelineEvents();
  List<EntityCacheItem> relatedCacheItems = new ArrayList<>();
  for (String entityId : entityIds) {
    LOG.debug("getEntityTimeline type={} id={}", entityType, entityId);
    List<TimelineStore> stores
        = getTimelineStoresForRead(entityId, entityType, relatedCacheItems);
    for (TimelineStore store : stores) {
      LOG.debug("Try timeline store {}:{} for the request", store.getName(),
          store.toString());
      SortedSet<String> entityIdSet = new TreeSet<>();
      entityIdSet.add(entityId);
      TimelineEvents events =
          store.getEntityTimelines(entityType, entityIdSet, limit,
              windowStart, windowEnd, eventTypes);
      if (events != null) {
        returnEvents.addEvents(events.getAllEvents());
      }
    }
  }
  return returnEvents;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:27,代码来源:EntityGroupFSTimelineStore.java


示例4: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Override
public synchronized TimelineEvents getEntityTimelines(String entityType,
    SortedSet<String> entityIds, Long limit, Long windowStart,
    Long windowEnd,
    Set<String> eventTypes) {
  TimelineEvents allEvents = new TimelineEvents();
  if (entityIds == null) {
    return allEvents;
  }
  if (limit == null) {
    limit = DEFAULT_LIMIT;
  }
  if (windowStart == null) {
    windowStart = Long.MIN_VALUE;
  }
  if (windowEnd == null) {
    windowEnd = Long.MAX_VALUE;
  }
  for (String entityId : entityIds) {
    EntityIdentifier entityID = new EntityIdentifier(entityId, entityType);
    TimelineEntity entity = entities.get(entityID);
    if (entity == null) {
      continue;
    }
    EventsOfOneEntity events = new EventsOfOneEntity();
    events.setEntityId(entityId);
    events.setEntityType(entityType);
    for (TimelineEvent event : entity.getEvents()) {
      if (events.getEvents().size() >= limit) {
        break;
      }
      if (event.getTimestamp() <= windowStart) {
        continue;
      }
      if (event.getTimestamp() > windowEnd) {
        continue;
      }
      if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
        continue;
      }
      events.addEvent(event);
    }
    allEvents.addEvent(events);
  }
  return allEvents;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:MemoryTimelineStore.java


示例5: getEvents

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
/**
 * Get the events whose entities the given user has access to. The meaning of
 * each argument has been documented with
 * {@link TimelineReader#getEntityTimelines}.
 * 
 * @see TimelineReader#getEntityTimelines
 */
public TimelineEvents getEvents(
    String entityType,
    SortedSet<String> entityIds,
    SortedSet<String> eventTypes,
    Long windowStart,
    Long windowEnd,
    Long limit,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineEvents events = null;
  events = store.getEntityTimelines(
      entityType,
      entityIds,
      limit,
      windowStart,
      windowEnd,
      eventTypes);
  if (events != null) {
    Iterator<TimelineEvents.EventsOfOneEntity> eventsItr =
        events.getAllEvents().iterator();
    while (eventsItr.hasNext()) {
      TimelineEvents.EventsOfOneEntity eventsOfOneEntity = eventsItr.next();
      try {
        TimelineEntity entity = store.getEntity(
            eventsOfOneEntity.getEntityId(),
            eventsOfOneEntity.getEntityType(),
            EnumSet.of(Field.PRIMARY_FILTERS));
        addDefaultDomainIdIfAbsent(entity);
        // check ACLs
        if (!timelineACLsManager.checkAccess(
            callerUGI, ApplicationAccessType.VIEW_APP, entity)) {
          eventsItr.remove();
        }
      } catch (Exception e) {
        LOG.error("Error when verifying access for user " + callerUGI
            + " on the events of the timeline entity "
            + new EntityIdentifier(eventsOfOneEntity.getEntityId(),
                eventsOfOneEntity.getEntityType()), e);
        eventsItr.remove();
      }
    }
  }
  if (events == null) {
    return new TimelineEvents();
  }
  return events;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:54,代码来源:TimelineDataManager.java


示例6: doGetEvents

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
private TimelineEvents doGetEvents(
    String entityType,
    SortedSet<String> entityIds,
    SortedSet<String> eventTypes,
    Long windowStart,
    Long windowEnd,
    Long limit,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineEvents events = null;
  events = store.getEntityTimelines(
      entityType,
      entityIds,
      limit,
      windowStart,
      windowEnd,
      eventTypes);
  if (events != null) {
    Iterator<TimelineEvents.EventsOfOneEntity> eventsItr =
        events.getAllEvents().iterator();
    while (eventsItr.hasNext()) {
      TimelineEvents.EventsOfOneEntity eventsOfOneEntity = eventsItr.next();
      try {
        TimelineEntity entity = store.getEntity(
            eventsOfOneEntity.getEntityId(),
            eventsOfOneEntity.getEntityType(),
            EnumSet.of(Field.PRIMARY_FILTERS));
        addDefaultDomainIdIfAbsent(entity);
        // check ACLs
        if (!timelineACLsManager.checkAccess(
            callerUGI, ApplicationAccessType.VIEW_APP, entity)) {
          eventsItr.remove();
        }
      } catch (Exception e) {
        LOG.warn("Error when verifying access for user " + callerUGI
            + " on the events of the timeline entity "
            + new EntityIdentifier(eventsOfOneEntity.getEntityId(),
                eventsOfOneEntity.getEntityType()), e);
        eventsItr.remove();
      }
    }
  }
  if (events == null) {
    return new TimelineEvents();
  }
  return events;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:47,代码来源:TimelineDataManager.java


示例7: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Override
public synchronized TimelineEvents getEntityTimelines(String entityType,
    SortedSet<String> entityIds, Long limit, Long windowStart,
    Long windowEnd,
    Set<String> eventTypes) {
  if (getServiceStopped()) {
    LOG.info("Service stopped, return null for the storage");
    return null;
  }
  TimelineEvents allEvents = new TimelineEvents();
  if (entityIds == null) {
    return allEvents;
  }
  if (limit == null) {
    limit = DEFAULT_LIMIT;
  }
  if (windowStart == null) {
    windowStart = Long.MIN_VALUE;
  }
  if (windowEnd == null) {
    windowEnd = Long.MAX_VALUE;
  }
  for (String entityId : entityIds) {
    EntityIdentifier entityID = new EntityIdentifier(entityId, entityType);
    TimelineEntity entity = entities.get(entityID);
    if (entity == null) {
      continue;
    }
    EventsOfOneEntity events = new EventsOfOneEntity();
    events.setEntityId(entityId);
    events.setEntityType(entityType);
    for (TimelineEvent event : entity.getEvents()) {
      if (events.getEvents().size() >= limit) {
        break;
      }
      if (event.getTimestamp() <= windowStart) {
        continue;
      }
      if (event.getTimestamp() > windowEnd) {
        continue;
      }
      if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
        continue;
      }
      events.addEvent(event);
    }
    allEvents.addEvent(events);
  }
  return allEvents;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:51,代码来源:KeyValueBasedTimelineStore.java


示例8: testEvents

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Test
public void testEvents() throws Exception {
  TimelineEvents events = new TimelineEvents();
  for (int j = 0; j < 2; ++j) {
    TimelineEvents.EventsOfOneEntity partEvents =
        new TimelineEvents.EventsOfOneEntity();
    partEvents.setEntityId("entity id " + j);
    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);
    }
    events.addEvent(partEvents);
  }
  LOG.info("Events in JSON:");
  LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(events, true));

  Assert.assertEquals(2, events.getAllEvents().size());
  TimelineEvents.EventsOfOneEntity partEvents1 = events.getAllEvents().get(0);
  Assert.assertEquals("entity id 0", partEvents1.getEntityId());
  Assert.assertEquals("entity type 0", partEvents1.getEntityType());
  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("entity type 1", partEvents2.getEntityType());
  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());
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:44,代码来源:TestTimelineRecords.java


示例9: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
@Override
public TimelineEvents getEntityTimelines(String entityType,
    SortedSet<String> entityIds, Long limit, Long windowStart,
    Long windowEnd,
    Set<String> eventTypes) {
  TimelineEvents allEvents = new TimelineEvents();
  if (entityIds == null) {
    return allEvents;
  }
  if (limit == null) {
    limit = DEFAULT_LIMIT;
  }
  if (windowStart == null) {
    windowStart = Long.MIN_VALUE;
  }
  if (windowEnd == null) {
    windowEnd = Long.MAX_VALUE;
  }
  for (String entityId : entityIds) {
    EntityIdentifier entityID = new EntityIdentifier(entityId, entityType);
    TimelineEntity entity = entities.get(entityID);
    if (entity == null) {
      continue;
    }
    EventsOfOneEntity events = new EventsOfOneEntity();
    events.setEntityId(entityId);
    events.setEntityType(entityType);
    for (TimelineEvent event : entity.getEvents()) {
      if (events.getEvents().size() >= limit) {
        break;
      }
      if (event.getTimestamp() <= windowStart) {
        continue;
      }
      if (event.getTimestamp() > windowEnd) {
        continue;
      }
      if (eventTypes != null && !eventTypes.contains(event.getEventType())) {
        continue;
      }
      events.addEvent(event);
    }
    allEvents.addEvent(events);
  }
  return allEvents;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:47,代码来源:MemoryTimelineStore.java


示例10: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; //导入依赖的package包/类
/**
 * This method retrieves the events for a list of entities all of the same
 * entity type. The events for each entity are sorted in order of their
 * timestamps, descending.
 * 
 * @param entityType
 *          The type of entities to retrieve events for.
 * @param entityIds
 *          The entity IDs to retrieve events for.
 * @param limit
 *          A limit on the number of events to return for each entity. If
 *          null, defaults to {@link #DEFAULT_LIMIT} events per entity.
 * @param windowStart
 *          If not null, retrieves only events later than the given time
 *          (exclusive)
 * @param windowEnd
 *          If not null, retrieves only events earlier than the given time
 *          (inclusive)
 * @param eventTypes
 *          Restricts the events returned to the given types. If null, events
 *          of all types will be returned.
 * @return An {@link TimelineEvents} object.
 * @throws IOException
 */
TimelineEvents getEntityTimelines(String entityType,
    SortedSet<String> entityIds, Long limit, Long windowStart,
    Long windowEnd, Set<String> eventTypes) throws IOException;
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TimelineReader.java



注:本文中的org.apache.hadoop.yarn.api.records.timeline.TimelineEvents类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UploadEvent类代码示例发布时间:2022-05-23
下一篇:
Java TABLESWITCH类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap