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


Java JobCounter.TOTAL_LAUNCHED_MAPS属性代码示例

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


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

示例1: recoveryChecker

private void recoveryChecker(MapTaskImpl checkTask, TaskState finalState,
    Map<TaskAttemptID, TaskAttemptState> finalAttemptStates,
    ArgumentCaptor<Event> arg, List<EventType> expectedJobHistoryEvents,
    long expectedMapLaunches, long expectedFailedMaps) {

  assertEquals("Final State of Task", finalState, checkTask.getState());

  Map<TaskAttemptId, TaskAttempt> recoveredAttempts =
      checkTask.getAttempts();
  assertEquals("Expected Number of Task Attempts",
      finalAttemptStates.size(), recoveredAttempts.size());
  for (TaskAttemptID taID : finalAttemptStates.keySet()) {
    assertEquals("Expected Task Attempt State",
        finalAttemptStates.get(taID),
        recoveredAttempts.get(TypeConverter.toYarn(taID)).getState());
  }

  Iterator<Event> ie = arg.getAllValues().iterator();
  int eventNum = 0;
  long totalLaunchedMaps = 0;
  long totalFailedMaps = 0;
  boolean jobTaskEventReceived = false;

  while (ie.hasNext()) {
    Object current = ie.next();
    ++eventNum;
    LOG.info(eventNum + " " + current.getClass().getName());
    if (current instanceof JobHistoryEvent) {
      JobHistoryEvent jhe = (JobHistoryEvent) current;
      LOG.info(expectedJobHistoryEvents.get(0).toString() + " " +
          jhe.getHistoryEvent().getEventType().toString() + " " +
          jhe.getJobID());
      assertEquals(expectedJobHistoryEvents.get(0),
          jhe.getHistoryEvent().getEventType());
      expectedJobHistoryEvents.remove(0);
    }  else if (current instanceof JobCounterUpdateEvent) {
      JobCounterUpdateEvent jcue = (JobCounterUpdateEvent) current;

      LOG.info("JobCounterUpdateEvent "
          + jcue.getCounterUpdates().get(0).getCounterKey()
          + " " + jcue.getCounterUpdates().get(0).getIncrementValue());
      if (jcue.getCounterUpdates().get(0).getCounterKey() ==
          JobCounter.NUM_FAILED_MAPS) {
        totalFailedMaps += jcue.getCounterUpdates().get(0)
            .getIncrementValue();
      } else if (jcue.getCounterUpdates().get(0).getCounterKey() ==
          JobCounter.TOTAL_LAUNCHED_MAPS) {
        totalLaunchedMaps += jcue.getCounterUpdates().get(0)
            .getIncrementValue();
      }
    } else if (current instanceof JobTaskEvent) {
      JobTaskEvent jte = (JobTaskEvent) current;
      assertEquals(jte.getState(), finalState);
      jobTaskEventReceived = true;
    }
  }
  assertTrue(jobTaskEventReceived || (finalState == TaskState.RUNNING));
  assertEquals("Did not process all expected JobHistoryEvents",
      0, expectedJobHistoryEvents.size());
  assertEquals("Expected Map Launches",
      expectedMapLaunches, totalLaunchedMaps);
  assertEquals("Expected Failed Maps",
      expectedFailedMaps, totalFailedMaps);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:64,代码来源:TestRecovery.java


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