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


Java TaskAttemptEvent.getType方法代码示例

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


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

示例1: dispatch

import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent; //导入方法依赖的package包/类
@Override
protected void dispatch(Event event) {
  if (event instanceof TaskAttemptEvent) {
    TaskAttemptEvent attemptEvent = (TaskAttemptEvent) event;
    TaskAttemptId attemptID = ((TaskAttemptEvent) event).getTaskAttemptID();
    if (attemptEvent.getType() == this.attemptEventTypeToWait
        && attemptID.getTaskId().getId() == 0 && attemptID.getId() == 0 ) {
      try {
        latch.await();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  super.dispatch(event);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestKill.java

示例2: handle

import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent; //导入方法依赖的package包/类
@Override
public void handle(Event event) {
  if (event instanceof TaskAttemptEvent) {
    TaskAttemptEvent attemptEvent = ((TaskAttemptEvent) event);
    if (TaskAttemptEventType.TA_TIMED_OUT == attemptEvent.getType()) {
      timedOut = true;
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:10,代码来源:TestTaskAttemptFinishingMonitor.java

示例3: testKillTaskWait

import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent; //导入方法依赖的package包/类
@Test
public void testKillTaskWait() throws Exception {
  final Dispatcher dispatcher = new AsyncDispatcher() {
    private TaskAttemptEvent cachedKillEvent;
    @Override
    protected void dispatch(Event event) {
      if (event instanceof TaskAttemptEvent) {
        TaskAttemptEvent killEvent = (TaskAttemptEvent) event;
        if (killEvent.getType() == TaskAttemptEventType.TA_KILL) {
          TaskAttemptId taID = killEvent.getTaskAttemptID();
          if (taID.getTaskId().getTaskType() == TaskType.REDUCE
              && taID.getTaskId().getId() == 0 && taID.getId() == 0) {
            // Task is asking the reduce TA to kill itself. 'Create' a race
            // condition. Make the task succeed and then inform the task that
            // TA has succeeded. Once Task gets the TA succeeded event at
            // KILL_WAIT, then relay the actual kill signal to TA
            super.dispatch(new TaskAttemptEvent(taID,
              TaskAttemptEventType.TA_DONE));
            super.dispatch(new TaskAttemptEvent(taID,
              TaskAttemptEventType.TA_CONTAINER_CLEANED));
            super.dispatch(new TaskTAttemptEvent(taID,
              TaskEventType.T_ATTEMPT_SUCCEEDED));
            this.cachedKillEvent = killEvent;
            return;
          }
        }
      } else if (event instanceof TaskEvent) {
        TaskEvent taskEvent = (TaskEvent) event;
        if (taskEvent.getType() == TaskEventType.T_ATTEMPT_SUCCEEDED
            && this.cachedKillEvent != null) {
          // When the TA comes and reports that it is done, send the
          // cachedKillEvent
          super.dispatch(this.cachedKillEvent);
          return;
        }

      }
      super.dispatch(event);
    }
  };
  MRApp app = new MRApp(1, 1, false, this.getClass().getName(), true) {
    @Override
    public Dispatcher createDispatcher() {
      return dispatcher;
    }
  };
  Job job = app.submit(new Configuration());
  JobId jobId = app.getJobId();
  app.waitForState(job, JobState.RUNNING);
  Assert.assertEquals("Num tasks not correct", 2, job.getTasks().size());
  Iterator<Task> it = job.getTasks().values().iterator();
  Task mapTask = it.next();
  Task reduceTask = it.next();
  app.waitForState(mapTask, TaskState.RUNNING);
  app.waitForState(reduceTask, TaskState.RUNNING);
  TaskAttempt mapAttempt = mapTask.getAttempts().values().iterator().next();
  app.waitForState(mapAttempt, TaskAttemptState.RUNNING);
  TaskAttempt reduceAttempt = reduceTask.getAttempts().values().iterator().next();
  app.waitForState(reduceAttempt, TaskAttemptState.RUNNING);

  // Finish map
  app.getContext().getEventHandler().handle(
      new TaskAttemptEvent(
          mapAttempt.getID(),
          TaskAttemptEventType.TA_DONE));
  app.waitForState(mapTask, TaskState.SUCCEEDED);

  // Now kill the job
  app.getContext().getEventHandler()
    .handle(new JobEvent(jobId, JobEventType.JOB_KILL));

  app.waitForInternalState((JobImpl)job, JobStateInternal.KILLED);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:74,代码来源:TestKill.java

示例4: testKillTaskWait

import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent; //导入方法依赖的package包/类
@Test
public void testKillTaskWait() throws Exception {
  final Dispatcher dispatcher = new AsyncDispatcher() {
    private TaskAttemptEvent cachedKillEvent;
    @Override
    protected void dispatch(Event event) {
      if (event instanceof TaskAttemptEvent) {
        TaskAttemptEvent killEvent = (TaskAttemptEvent) event;
        if (killEvent.getType() == TaskAttemptEventType.TA_KILL) {
          TaskAttemptId taID = killEvent.getTaskAttemptID();
          if (taID.getTaskId().getTaskType() == TaskType.REDUCE
              && taID.getTaskId().getId() == 0 && taID.getId() == 0) {
            // Task is asking the reduce TA to kill itself. 'Create' a race
            // condition. Make the task succeed and then inform the task that
            // TA has succeeded. Once Task gets the TA succeeded event at
            // KILL_WAIT, then relay the actual kill signal to TA
            super.dispatch(new TaskAttemptEvent(taID,
              TaskAttemptEventType.TA_DONE));
            super.dispatch(new TaskAttemptEvent(taID,
              TaskAttemptEventType.TA_CONTAINER_COMPLETED));
            super.dispatch(new TaskTAttemptEvent(taID,
              TaskEventType.T_ATTEMPT_SUCCEEDED));
            this.cachedKillEvent = killEvent;
            return;
          }
        }
      } else if (event instanceof TaskEvent) {
        TaskEvent taskEvent = (TaskEvent) event;
        if (taskEvent.getType() == TaskEventType.T_ATTEMPT_SUCCEEDED
            && this.cachedKillEvent != null) {
          // When the TA comes and reports that it is done, send the
          // cachedKillEvent
          super.dispatch(this.cachedKillEvent);
          return;
        }

      }
      super.dispatch(event);
    }
  };
  MRApp app = new MRApp(1, 1, false, this.getClass().getName(), true) {
    @Override
    public Dispatcher createDispatcher() {
      return dispatcher;
    }
  };
  Job job = app.submit(new Configuration());
  JobId jobId = app.getJobId();
  app.waitForState(job, JobState.RUNNING);
  Assert.assertEquals("Num tasks not correct", 2, job.getTasks().size());
  Iterator<Task> it = job.getTasks().values().iterator();
  Task mapTask = it.next();
  Task reduceTask = it.next();
  app.waitForState(mapTask, TaskState.RUNNING);
  app.waitForState(reduceTask, TaskState.RUNNING);
  TaskAttempt mapAttempt = mapTask.getAttempts().values().iterator().next();
  app.waitForState(mapAttempt, TaskAttemptState.RUNNING);
  TaskAttempt reduceAttempt = reduceTask.getAttempts().values().iterator().next();
  app.waitForState(reduceAttempt, TaskAttemptState.RUNNING);

  // Finish map
  app.getContext().getEventHandler().handle(
      new TaskAttemptEvent(
          mapAttempt.getID(),
          TaskAttemptEventType.TA_DONE));
  app.waitForState(mapTask, TaskState.SUCCEEDED);

  // Now kill the job
  app.getContext().getEventHandler()
    .handle(new JobEvent(jobId, JobEventType.JOB_KILL));

  app.waitForInternalState((JobImpl) job, JobStateInternal.KILLED);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:74,代码来源:TestKill.java


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