当前位置: 首页>>代码示例>>Java>>正文


Java TimelineEntity.getEvents方法代码示例

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


在下文中一共展示了TimelineEntity.getEvents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPublishAppAttemptMetrics

import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void testPublishAppAttemptMetrics() throws Exception {
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
  RMAppAttempt appAttempt = createRMAppAttempt(appAttemptId);
  metricsPublisher.appAttemptRegistered(appAttempt, Integer.MAX_VALUE + 1L);
  RMApp app = mock(RMApp.class);
  when(app.getFinalApplicationStatus()).thenReturn(FinalApplicationStatus.UNDEFINED);
  metricsPublisher.appAttemptFinished(appAttempt, RMAppAttemptState.FINISHED, app,
      Integer.MAX_VALUE + 2L);
  TimelineEntity entity = null;
  do {
    entity =
        store.getEntity(appAttemptId.toString(),
            AppAttemptMetricsConstants.ENTITY_TYPE,
            EnumSet.allOf(Field.class));
    // ensure two events are both published before leaving the loop
  } while (entity == null || entity.getEvents().size() < 2);
  // verify all the fields
  Assert.assertEquals(AppAttemptMetricsConstants.ENTITY_TYPE,
      entity.getEntityType());
  Assert.assertEquals(appAttemptId.toString(), entity.getEntityId());
  Assert.assertEquals(
      appAttemptId.getApplicationId().toString(),
      entity.getPrimaryFilters()
          .get(AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER).iterator()
          .next());
  boolean hasRegisteredEvent = false;
  boolean hasFinishedEvent = false;
  for (TimelineEvent event : entity.getEvents()) {
    if (event.getEventType().equals(
        AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
      hasRegisteredEvent = true;
      Assert.assertEquals(appAttempt.getHost(),
          event.getEventInfo()
              .get(AppAttemptMetricsConstants.HOST_EVENT_INFO));
      Assert
          .assertEquals(appAttempt.getRpcPort(),
              event.getEventInfo().get(
                  AppAttemptMetricsConstants.RPC_PORT_EVENT_INFO));
      Assert.assertEquals(
          appAttempt.getMasterContainer().getId().toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.MASTER_CONTAINER_EVENT_INFO));
    } else if (event.getEventType().equals(
        AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
      hasFinishedEvent = true;
      Assert.assertEquals(appAttempt.getDiagnostics(), event.getEventInfo()
          .get(AppAttemptMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO));
      Assert.assertEquals(appAttempt.getTrackingUrl(), event.getEventInfo()
          .get(AppAttemptMetricsConstants.TRACKING_URL_EVENT_INFO));
      Assert.assertEquals(
          appAttempt.getOriginalTrackingUrl(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_EVENT_INFO));
      Assert.assertEquals(
          FinalApplicationStatus.UNDEFINED.toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.FINAL_STATUS_EVENT_INFO));
      Assert.assertEquals(
          YarnApplicationAttemptState.FINISHED.toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.STATE_EVENT_INFO));
    }
  }
  Assert.assertTrue(hasRegisteredEvent && hasFinishedEvent);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:68,代码来源:TestSystemMetricsPublisher.java

示例2: testPublishContainerMetrics

import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void testPublishContainerMetrics() throws Exception {
  ContainerId containerId =
      ContainerId.newContainerId(ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1), 1);
  RMContainer container = createRMContainer(containerId);
  metricsPublisher.containerCreated(container, container.getCreationTime());
  metricsPublisher.containerFinished(container, container.getFinishTime());
  TimelineEntity entity = null;
  do {
    entity =
        store.getEntity(containerId.toString(),
            ContainerMetricsConstants.ENTITY_TYPE,
            EnumSet.allOf(Field.class));
    // ensure two events are both published before leaving the loop
  } while (entity == null || entity.getEvents().size() < 2);
  // verify all the fields
  Assert.assertEquals(ContainerMetricsConstants.ENTITY_TYPE,
      entity.getEntityType());
  Assert.assertEquals(containerId.toString(), entity.getEntityId());
  Assert.assertEquals(
      containerId.getApplicationAttemptId().toString(),
      entity.getPrimaryFilters()
          .get(ContainerMetricsConstants.PARENT_PRIMARIY_FILTER).iterator()
          .next());
  Assert.assertEquals(
      container.getAllocatedNode().getHost(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_HOST_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedNode().getPort(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedResource().getMemory(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_MEMORY_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedResource().getVirtualCores(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_VCORE_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedResource().getGpuCores(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_GCORE_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedPriority().getPriority(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_PRIORITY_ENTITY_INFO));
  boolean hasCreatedEvent = false;
  boolean hasFinishedEvent = false;
  for (TimelineEvent event : entity.getEvents()) {
    if (event.getEventType().equals(
        ContainerMetricsConstants.CREATED_EVENT_TYPE)) {
      hasCreatedEvent = true;
      Assert.assertEquals(container.getCreationTime(), event.getTimestamp());
    } else if (event.getEventType().equals(
        ContainerMetricsConstants.FINISHED_EVENT_TYPE)) {
      hasFinishedEvent = true;
      Assert.assertEquals(container.getFinishTime(), event.getTimestamp());
      Assert.assertEquals(
          container.getDiagnosticsInfo(),
          event.getEventInfo().get(
              ContainerMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO));
      Assert.assertEquals(
          container.getContainerExitStatus(),
          event.getEventInfo().get(
              ContainerMetricsConstants.EXIT_STATUS_EVENT_INFO));
      Assert.assertEquals(container.getContainerState().toString(), event
          .getEventInfo().get(ContainerMetricsConstants.STATE_EVENT_INFO));
    }
  }
  Assert.assertTrue(hasCreatedEvent && hasFinishedEvent);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:75,代码来源:TestSystemMetricsPublisher.java

示例3: getEntityTimelines

import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; //导入方法依赖的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

示例4: testPublishAppAttemptMetrics

import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void testPublishAppAttemptMetrics() throws Exception {
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
  RMAppAttempt appAttempt = createRMAppAttempt(appAttemptId, false);
  metricsPublisher.appAttemptRegistered(appAttempt, Integer.MAX_VALUE + 1L);
  RMApp app = mock(RMApp.class);
  when(app.getFinalApplicationStatus()).thenReturn(FinalApplicationStatus.UNDEFINED);
  metricsPublisher.appAttemptFinished(appAttempt, RMAppAttemptState.FINISHED, app,
      Integer.MAX_VALUE + 2L);
  TimelineEntity entity = null;
  do {
    entity =
        store.getEntity(appAttemptId.toString(),
            AppAttemptMetricsConstants.ENTITY_TYPE,
            EnumSet.allOf(Field.class));
    // ensure two events are both published before leaving the loop
  } while (entity == null || entity.getEvents().size() < 2);
  // verify all the fields
  Assert.assertEquals(AppAttemptMetricsConstants.ENTITY_TYPE,
      entity.getEntityType());
  Assert.assertEquals(appAttemptId.toString(), entity.getEntityId());
  Assert.assertEquals(
      appAttemptId.getApplicationId().toString(),
      entity.getPrimaryFilters()
          .get(AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER).iterator()
          .next());
  boolean hasRegisteredEvent = false;
  boolean hasFinishedEvent = false;
  for (TimelineEvent event : entity.getEvents()) {
    if (event.getEventType().equals(
        AppAttemptMetricsConstants.REGISTERED_EVENT_TYPE)) {
      hasRegisteredEvent = true;
      Assert.assertEquals(appAttempt.getHost(),
          event.getEventInfo()
              .get(AppAttemptMetricsConstants.HOST_EVENT_INFO));
      Assert
          .assertEquals(appAttempt.getRpcPort(),
              event.getEventInfo().get(
                  AppAttemptMetricsConstants.RPC_PORT_EVENT_INFO));
      Assert.assertEquals(
          appAttempt.getMasterContainer().getId().toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.MASTER_CONTAINER_EVENT_INFO));
    } else if (event.getEventType().equals(
        AppAttemptMetricsConstants.FINISHED_EVENT_TYPE)) {
      hasFinishedEvent = true;
      Assert.assertEquals(appAttempt.getDiagnostics(), event.getEventInfo()
          .get(AppAttemptMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO));
      Assert.assertEquals(appAttempt.getTrackingUrl(), event.getEventInfo()
          .get(AppAttemptMetricsConstants.TRACKING_URL_EVENT_INFO));
      Assert.assertEquals(
          appAttempt.getOriginalTrackingUrl(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_EVENT_INFO));
      Assert.assertEquals(
          FinalApplicationStatus.UNDEFINED.toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.FINAL_STATUS_EVENT_INFO));
      Assert.assertEquals(
          YarnApplicationAttemptState.FINISHED.toString(),
          event.getEventInfo().get(
              AppAttemptMetricsConstants.STATE_EVENT_INFO));
    }
  }
  Assert.assertTrue(hasRegisteredEvent && hasFinishedEvent);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:68,代码来源:TestSystemMetricsPublisher.java

示例5: testPublishContainerMetrics

import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void testPublishContainerMetrics() throws Exception {
  ContainerId containerId =
      ContainerId.newContainerId(ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(0, 1), 1), 1);
  RMContainer container = createRMContainer(containerId);
  metricsPublisher.containerCreated(container, container.getCreationTime());
  metricsPublisher.containerFinished(container, container.getFinishTime());
  TimelineEntity entity = null;
  do {
    entity =
        store.getEntity(containerId.toString(),
            ContainerMetricsConstants.ENTITY_TYPE,
            EnumSet.allOf(Field.class));
    // ensure two events are both published before leaving the loop
  } while (entity == null || entity.getEvents().size() < 2);
  // verify all the fields
  Assert.assertEquals(ContainerMetricsConstants.ENTITY_TYPE,
      entity.getEntityType());
  Assert.assertEquals(containerId.toString(), entity.getEntityId());
  Assert.assertEquals(
      containerId.getApplicationAttemptId().toString(),
      entity.getPrimaryFilters()
          .get(ContainerMetricsConstants.PARENT_PRIMARIY_FILTER).iterator()
          .next());
  Assert.assertEquals(
      container.getAllocatedNode().getHost(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_HOST_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedNode().getPort(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedResource().getMemory(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_MEMORY_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedResource().getVirtualCores(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_VCORE_ENTITY_INFO));
  Assert.assertEquals(
      container.getAllocatedPriority().getPriority(),
      entity.getOtherInfo().get(
          ContainerMetricsConstants.ALLOCATED_PRIORITY_ENTITY_INFO));
  boolean hasCreatedEvent = false;
  boolean hasFinishedEvent = false;
  for (TimelineEvent event : entity.getEvents()) {
    if (event.getEventType().equals(
        ContainerMetricsConstants.CREATED_EVENT_TYPE)) {
      hasCreatedEvent = true;
      Assert.assertEquals(container.getCreationTime(), event.getTimestamp());
    } else if (event.getEventType().equals(
        ContainerMetricsConstants.FINISHED_EVENT_TYPE)) {
      hasFinishedEvent = true;
      Assert.assertEquals(container.getFinishTime(), event.getTimestamp());
      Assert.assertEquals(
          container.getDiagnosticsInfo(),
          event.getEventInfo().get(
              ContainerMetricsConstants.DIAGNOSTICS_INFO_EVENT_INFO));
      Assert.assertEquals(
          container.getContainerExitStatus(),
          event.getEventInfo().get(
              ContainerMetricsConstants.EXIT_STATUS_EVENT_INFO));
      Assert.assertEquals(container.getContainerState().toString(), event
          .getEventInfo().get(ContainerMetricsConstants.STATE_EVENT_INFO));
    }
  }
  Assert.assertTrue(hasCreatedEvent && hasFinishedEvent);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:71,代码来源:TestSystemMetricsPublisher.java


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