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


Java TaskAttemptState类代码示例

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


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

示例1: testMRAppHistory

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
private void testMRAppHistory(MRApp app) throws Exception {
  Configuration conf = new Configuration();
  Job job = app.submit(conf);
  app.waitForState(job, JobState.FAILED);
  Map<TaskId, Task> tasks = job.getTasks();

  Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
  Task task = tasks.values().iterator().next();
  Assert.assertEquals("Task state not correct", TaskState.FAILED, task
      .getReport().getTaskState());
  Map<TaskAttemptId, TaskAttempt> attempts = tasks.values().iterator().next()
      .getAttempts();
  Assert.assertEquals("Num attempts is not correct", 4, attempts.size());

  Iterator<TaskAttempt> it = attempts.values().iterator();
  TaskAttemptReport report = it.next().getReport();
  Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
      report.getTaskAttemptState());
  Assert.assertEquals("Diagnostic Information is not Correct",
      "Test Diagnostic Event", report.getDiagnosticInfo());
  report = it.next().getReport();
  Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
      report.getTaskAttemptState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestTaskAttempt.java

示例2: testKillDuringTaskAttemptCommit

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Test
public void testKillDuringTaskAttemptCommit() {
  mockTask = createMockTask(TaskType.REDUCE);        
  TaskId taskId = getNewTaskID();
  scheduleTaskAttempt(taskId);
  
  launchTaskAttempt(getLastAttempt().getAttemptId());
  updateLastAttemptState(TaskAttemptState.COMMIT_PENDING);
  commitTaskAttempt(getLastAttempt().getAttemptId());

  TaskAttemptId commitAttempt = getLastAttempt().getAttemptId();
  updateLastAttemptState(TaskAttemptState.KILLED);
  killRunningTaskAttempt(commitAttempt);

  assertFalse(mockTask.canCommit(commitAttempt));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestTaskImpl.java

示例3: waitForState

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
public void waitForState(TaskAttempt attempt, 
    TaskAttemptState finalState) throws Exception {
  int timeoutSecs = 0;
  TaskAttemptReport report = attempt.getReport();
  while (!finalState.equals(report.getTaskAttemptState()) &&
      timeoutSecs++ < 20) {
    System.out.println("TaskAttempt State is : " + report.getTaskAttemptState() +
        " Waiting for state : " + finalState +
        "   progress : " + report.getProgress());
    report = attempt.getReport();
    Thread.sleep(500);
  }
  System.out.println("TaskAttempt State is : " + report.getTaskAttemptState());
  Assert.assertEquals("TaskAttempt state is not correct (timedout)",
      finalState, 
      report.getTaskAttemptState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:MRApp.java

示例4: testFailTask

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Test
//First attempt is failed and second attempt is passed
//The job succeeds.
public void testFailTask() throws Exception {
  MRApp app = new MockFirstFailingAttemptMRApp(1, 0);
  Configuration conf = new Configuration();
  // this test requires two task attempts, but uberization overrides max to 1
  conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
  Job job = app.submit(conf);
  app.waitForState(job, JobState.SUCCEEDED);
  Map<TaskId,Task> tasks = job.getTasks();
  Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
  Task task = tasks.values().iterator().next();
  Assert.assertEquals("Task state not correct", TaskState.SUCCEEDED,
      task.getReport().getTaskState());
  Map<TaskAttemptId, TaskAttempt> attempts =
      tasks.values().iterator().next().getAttempts();
  Assert.assertEquals("Num attempts is not correct", 2, attempts.size());
  //one attempt must be failed 
  //and another must have succeeded
  Iterator<TaskAttempt> it = attempts.values().iterator();
  Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
      it.next().getReport().getTaskAttemptState());
  Assert.assertEquals("Attempt state not correct", TaskAttemptState.SUCCEEDED,
      it.next().getReport().getTaskAttemptState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestFail.java

示例5: testTimedOutTask

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Test
//All Task attempts are timed out, leading to Job failure
public void testTimedOutTask() throws Exception {
  MRApp app = new TimeOutTaskMRApp(1, 0);
  Configuration conf = new Configuration();
  int maxAttempts = 2;
  conf.setInt(MRJobConfig.MAP_MAX_ATTEMPTS, maxAttempts);
  // disable uberization (requires entire job to be reattempted, so max for
  // subtask attempts is overridden to 1)
  conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
  Job job = app.submit(conf);
  app.waitForState(job, JobState.FAILED);
  Map<TaskId,Task> tasks = job.getTasks();
  Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
  Task task = tasks.values().iterator().next();
  Assert.assertEquals("Task state not correct", TaskState.FAILED,
      task.getReport().getTaskState());
  Map<TaskAttemptId, TaskAttempt> attempts =
      tasks.values().iterator().next().getAttempts();
  Assert.assertEquals("Num attempts is not correct", maxAttempts,
      attempts.size());
  for (TaskAttempt attempt : attempts.values()) {
    Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
        attempt.getReport().getTaskAttemptState());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestFail.java

示例6: toYarn

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
public static TaskAttemptState toYarn(
    org.apache.hadoop.mapred.TaskStatus.State state) {
  switch (state) {
  case COMMIT_PENDING:
    return TaskAttemptState.COMMIT_PENDING;
  case FAILED:
  case FAILED_UNCLEAN:
    return TaskAttemptState.FAILED;
  case KILLED:
  case KILLED_UNCLEAN:
    return TaskAttemptState.KILLED;
  case RUNNING:
    return TaskAttemptState.RUNNING;
  case SUCCEEDED:
    return TaskAttemptState.SUCCEEDED;
  case UNASSIGNED:
    return TaskAttemptState.STARTING;
  default:
    throw new YarnRuntimeException("Unrecognized State: " + state);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TypeConverter.java

示例7: testTimeoutWhileSuccessFinishing

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Test
public void testTimeoutWhileSuccessFinishing() throws Exception {
  MockEventHandler eventHandler = new MockEventHandler();
  TaskAttemptImpl taImpl = createTaskAttemptImpl(eventHandler);

  taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
      TaskAttemptEventType.TA_DONE));

  assertEquals("Task attempt is not in RUNNING state", taImpl.getState(),
      TaskAttemptState.SUCCEEDED);
  assertEquals("Task attempt's internal state is not " +
      "SUCCESS_FINISHING_CONTAINER", taImpl.getInternalState(),
      TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER);

  // If the task stays in SUCCESS_FINISHING_CONTAINER for too long,
  // TaskAttemptListenerImpl will time out the attempt.
  taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
      TaskAttemptEventType.TA_TIMED_OUT));
  assertEquals("Task attempt is not in RUNNING state", taImpl.getState(),
      TaskAttemptState.SUCCEEDED);
  assertEquals("Task attempt's internal state is not " +
      "SUCCESS_CONTAINER_CLEANUP", taImpl.getInternalState(),
      TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP);

  assertFalse("InternalError occurred", eventHandler.internalError);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestTaskAttempt.java

示例8: testTimeoutWhileFailFinishing

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Test
public void testTimeoutWhileFailFinishing() throws Exception {
  MockEventHandler eventHandler = new MockEventHandler();
  TaskAttemptImpl taImpl = createTaskAttemptImpl(eventHandler);

  taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
      TaskAttemptEventType.TA_FAILMSG));

  assertEquals("Task attempt is not in RUNNING state", taImpl.getState(),
      TaskAttemptState.FAILED);
  assertEquals("Task attempt's internal state is not " +
      "FAIL_FINISHING_CONTAINER", taImpl.getInternalState(),
      TaskAttemptStateInternal.FAIL_FINISHING_CONTAINER);

  // If the task stays in FAIL_FINISHING_CONTAINER for too long,
  // TaskAttemptListenerImpl will time out the attempt.
  taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
      TaskAttemptEventType.TA_TIMED_OUT));
  assertEquals("Task attempt's internal state is not FAIL_CONTAINER_CLEANUP",
      taImpl.getInternalState(),
      TaskAttemptStateInternal.FAIL_CONTAINER_CLEANUP);

  assertFalse("InternalError occurred", eventHandler.internalError);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:25,代码来源:TestTaskAttempt.java

示例9: statusUpdate

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
/**
 * Absorbs one TaskAttemptStatus
 *
 * @param reportedStatus the status report that we got from a task attempt
 *        that we want to fold into the speculation data for this job
 * @param timestamp the time this status corresponds to.  This matters
 *        because statuses contain progress.
 */
protected void statusUpdate(TaskAttemptStatus reportedStatus, long timestamp) {

  String stateString = reportedStatus.taskState.toString();

  TaskAttemptId attemptID = reportedStatus.id;
  TaskId taskID = attemptID.getTaskId();
  Job job = context.getJob(taskID.getJobId());

  if (job == null) {
    return;
  }

  Task task = job.getTask(taskID);

  if (task == null) {
    return;
  }

  estimator.updateAttempt(reportedStatus, timestamp);

  if (stateString.equals(TaskAttemptState.RUNNING.name())) {
    runningTasks.putIfAbsent(taskID, Boolean.TRUE);
  } else {
    runningTasks.remove(taskID, Boolean.TRUE);
    if (!stateString.equals(TaskAttemptState.STARTING.name())) {
      runningTaskAttemptStatistics.remove(attemptID);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:DefaultSpeculator.java

示例10: getSuccessfulAttempt

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
private TaskAttempt getSuccessfulAttempt(Task task) {
  for (TaskAttempt attempt : task.getAttempts().values()) {
    if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
      return attempt;
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TaskInfo.java

示例11: getState

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Override
public TaskAttemptState getState() {
  readLock.lock();
  try {
    return getExternalState(stateMachine.getCurrentState());
  } finally {
    readLock.unlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TaskAttemptImpl.java

示例12: getExternalState

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
private static TaskAttemptState getExternalState(
    TaskAttemptStateInternal smState) {
  switch (smState) {
  case ASSIGNED:
  case UNASSIGNED:
    return TaskAttemptState.STARTING;
  case COMMIT_PENDING:
    return TaskAttemptState.COMMIT_PENDING;
  case FAILED:
    return TaskAttemptState.FAILED;
  case KILLED:
    return TaskAttemptState.KILLED;
    // All CLEANUP states considered as RUNNING since events have not gone out
    // to the Task yet. May be possible to consider them as a Finished state.
  case FAIL_CONTAINER_CLEANUP:
  case FAIL_TASK_CLEANUP:
  case KILL_CONTAINER_CLEANUP:
  case KILL_TASK_CLEANUP:
  case SUCCESS_CONTAINER_CLEANUP:
  case RUNNING:
    return TaskAttemptState.RUNNING;
  case NEW:
    return TaskAttemptState.NEW;
  case SUCCEEDED:
    return TaskAttemptState.SUCCEEDED;
  default:
    throw new YarnRuntimeException("Attempt to convert invalid "
        + "stateMachineTaskAttemptState to externalTaskAttemptState: "
        + smState);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:TaskAttemptImpl.java

示例13: initTaskAttemptStatus

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
private void initTaskAttemptStatus(TaskAttemptStatus result) {
  result.progress = 0.0f;
  result.phase = Phase.STARTING;
  result.stateString = "NEW";
  result.taskState = TaskAttemptState.NEW;
  Counters counters = EMPTY_COUNTERS;
  result.counters = counters;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TaskAttemptImpl.java

示例14: verifyTaskAttemptReport

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
private void verifyTaskAttemptReport(TaskAttemptReport tar) {
  Assert.assertEquals(TaskAttemptState.RUNNING, tar.getTaskAttemptState());
  Assert.assertNotNull("TaskAttemptReport is null", tar);
  Assert.assertEquals(MRApp.NM_HOST, tar.getNodeManagerHost());
  Assert.assertEquals(MRApp.NM_PORT, tar.getNodeManagerPort());
  Assert.assertEquals(MRApp.NM_HTTP_PORT, tar.getNodeManagerHttpPort());
  Assert.assertEquals(1, tar.getContainerId().getApplicationAttemptId()
      .getAttemptId());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestMRClientService.java

示例15: isFinished

import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState; //导入依赖的package包/类
@Override
public boolean isFinished() {
  for (TaskAttempt attempt : attempts.values()) {
    if (attempt.getState() == TaskAttemptState.SUCCEEDED) {
      return true;
    }
  }

  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRuntimeEstimators.java


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