Java Code Examples for org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId#setTaskId()

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId#setTaskId() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   File: TypeConverter.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId toYarn(
    org.apache.hadoop.mapred.TaskAttemptID id) {
  TaskAttemptId taskAttemptId = recordFactory.newRecordInstance(TaskAttemptId.class);
  taskAttemptId.setTaskId(toYarn(id.getTaskID()));
  taskAttemptId.setId(id.getId());
  return taskAttemptId;
}
 
Example 2
Source Project: hadoop   File: TypeConverter.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId toYarn(
    org.apache.hadoop.mapreduce.TaskAttemptID id) {
  TaskAttemptId taskAttemptId = recordFactory.newRecordInstance(TaskAttemptId.class);
  taskAttemptId.setTaskId(toYarn(id.getTaskID()));
  taskAttemptId.setId(id.getId());
  return taskAttemptId;
}
 
Example 3
Source Project: hadoop   File: MRBuilderUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId newTaskAttemptId(TaskId taskId, int attemptId) {
  TaskAttemptId taskAttemptId =
      Records.newRecord(TaskAttemptId.class);
  taskAttemptId.setTaskId(taskId);
  taskAttemptId.setId(attemptId);
  return taskAttemptId;
}
 
Example 4
Source Project: hadoop   File: TestMRApps.java    License: Apache License 2.0 5 votes vote down vote up
@Test (timeout = 120000)
public void testTaskAttemptIDtoString() {
  TaskAttemptId taid = RecordFactoryProvider.getRecordFactory(null).newRecordInstance(TaskAttemptId.class);
  taid.setTaskId(RecordFactoryProvider.getRecordFactory(null).newRecordInstance(TaskId.class));
  taid.getTaskId().setTaskType(TaskType.MAP);
  taid.getTaskId().setJobId(RecordFactoryProvider.getRecordFactory(null).newRecordInstance(JobId.class));
  taid.getTaskId().getJobId().setAppId(ApplicationId.newInstance(0, 0));
  assertEquals("attempt_0_0000_m_000000_0", MRApps.toString(taid));
}
 
Example 5
Source Project: big-c   File: TypeConverter.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId toYarn(
    org.apache.hadoop.mapred.TaskAttemptID id) {
  TaskAttemptId taskAttemptId = recordFactory.newRecordInstance(TaskAttemptId.class);
  taskAttemptId.setTaskId(toYarn(id.getTaskID()));
  taskAttemptId.setId(id.getId());
  return taskAttemptId;
}
 
Example 6
Source Project: big-c   File: TypeConverter.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId toYarn(
    org.apache.hadoop.mapreduce.TaskAttemptID id) {
  TaskAttemptId taskAttemptId = recordFactory.newRecordInstance(TaskAttemptId.class);
  taskAttemptId.setTaskId(toYarn(id.getTaskID()));
  taskAttemptId.setId(id.getId());
  return taskAttemptId;
}
 
Example 7
Source Project: big-c   File: MRBuilderUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static TaskAttemptId newTaskAttemptId(TaskId taskId, int attemptId) {
  TaskAttemptId taskAttemptId =
      Records.newRecord(TaskAttemptId.class);
  taskAttemptId.setTaskId(taskId);
  taskAttemptId.setId(attemptId);
  return taskAttemptId;
}
 
Example 8
Source Project: big-c   File: TestMRApps.java    License: Apache License 2.0 5 votes vote down vote up
@Test (timeout = 120000)
public void testTaskAttemptIDtoString() {
  TaskAttemptId taid = RecordFactoryProvider.getRecordFactory(null).newRecordInstance(TaskAttemptId.class);
  taid.setTaskId(RecordFactoryProvider.getRecordFactory(null).newRecordInstance(TaskId.class));
  taid.getTaskId().setTaskType(TaskType.MAP);
  taid.getTaskId().setJobId(RecordFactoryProvider.getRecordFactory(null).newRecordInstance(JobId.class));
  taid.getTaskId().getJobId().setAppId(ApplicationId.newInstance(0, 0));
  assertEquals("attempt_0_0000_m_000000_0", MRApps.toString(taid));
}
 
Example 9
Source Project: hadoop   File: TestBlocks.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * test AttemptsBlock's rendering.
 */
@Test
public void testAttemptsBlock() {
  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);

  Task task = getTask(0);
  Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>();
  TaskAttempt attempt = mock(TaskAttempt.class);
  TaskAttemptId taId = new TaskAttemptIdPBImpl();
  taId.setId(0);
  taId.setTaskId(task.getID());
  when(attempt.getID()).thenReturn(taId);
  when(attempt.getNodeHttpAddress()).thenReturn("Node address");

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1);

  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);
  when(attempt.getAssignedContainerID()).thenReturn(containerId);

  when(attempt.getAssignedContainerMgrAddress()).thenReturn(
          "assignedContainerMgrAddress");
  when(attempt.getNodeRackName()).thenReturn("nodeRackName");

  final long taStartTime = 100002L;
  final long taFinishTime = 100012L;
  final long taShuffleFinishTime = 100010L;
  final long taSortFinishTime = 100011L;
  final TaskAttemptState taState = TaskAttemptState.SUCCEEDED;

  when(attempt.getLaunchTime()).thenReturn(taStartTime);
  when(attempt.getFinishTime()).thenReturn(taFinishTime);
  when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(attempt.getState()).thenReturn(taState);

  TaskAttemptReport taReport = mock(TaskAttemptReport.class);
  when(taReport.getStartTime()).thenReturn(taStartTime);
  when(taReport.getFinishTime()).thenReturn(taFinishTime);
  when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(taReport.getContainerId()).thenReturn(containerId);
  when(taReport.getProgress()).thenReturn(1.0f);
  when(taReport.getStateString()).thenReturn("Processed 128/128 records <p> \n");
  when(taReport.getTaskAttemptState()).thenReturn(taState);
  when(taReport.getDiagnosticInfo()).thenReturn("");

  when(attempt.getReport()).thenReturn(taReport);

  attempts.put(taId, attempt);
  when(task.getAttempts()).thenReturn(attempts);

  app.setTask(task);
  Job job = mock(Job.class);
  when(job.getUserName()).thenReturn("User");
  app.setJob(job);

  AttemptsBlockForTest block = new AttemptsBlockForTest(app);
  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about attempts
  assertTrue(data.toString().contains("0 attempt_0_0001_r_000000_0"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertFalse(data.toString().contains("Processed 128/128 records <p> \n"));
  assertTrue(data.toString().contains("Processed 128\\/128 records &lt;p&gt; \\n"));
  assertTrue(data.toString().contains(
          "_0005_01_000001:attempt_0_0001_r_000000_0:User:"));
  assertTrue(data.toString().contains("100002"));
  assertTrue(data.toString().contains("100010"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains("100012"));
}
 
Example 10
Source Project: big-c   File: TestBlocks.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * test AttemptsBlock's rendering.
 */
@Test
public void testAttemptsBlock() {
  AppContext ctx = mock(AppContext.class);
  AppForTest app = new AppForTest(ctx);

  Task task = getTask(0);
  Map<TaskAttemptId, TaskAttempt> attempts = new HashMap<TaskAttemptId, TaskAttempt>();
  TaskAttempt attempt = mock(TaskAttempt.class);
  TaskAttemptId taId = new TaskAttemptIdPBImpl();
  taId.setId(0);
  taId.setTaskId(task.getID());
  when(attempt.getID()).thenReturn(taId);
  when(attempt.getNodeHttpAddress()).thenReturn("Node address");

  ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1);

  ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1);
  when(attempt.getAssignedContainerID()).thenReturn(containerId);

  when(attempt.getAssignedContainerMgrAddress()).thenReturn(
          "assignedContainerMgrAddress");
  when(attempt.getNodeRackName()).thenReturn("nodeRackName");

  final long taStartTime = 100002L;
  final long taFinishTime = 100012L;
  final long taShuffleFinishTime = 100010L;
  final long taSortFinishTime = 100011L;
  final TaskAttemptState taState = TaskAttemptState.SUCCEEDED;

  when(attempt.getLaunchTime()).thenReturn(taStartTime);
  when(attempt.getFinishTime()).thenReturn(taFinishTime);
  when(attempt.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(attempt.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(attempt.getState()).thenReturn(taState);

  TaskAttemptReport taReport = mock(TaskAttemptReport.class);
  when(taReport.getStartTime()).thenReturn(taStartTime);
  when(taReport.getFinishTime()).thenReturn(taFinishTime);
  when(taReport.getShuffleFinishTime()).thenReturn(taShuffleFinishTime);
  when(taReport.getSortFinishTime()).thenReturn(taSortFinishTime);
  when(taReport.getContainerId()).thenReturn(containerId);
  when(taReport.getProgress()).thenReturn(1.0f);
  when(taReport.getStateString()).thenReturn("Processed 128/128 records <p> \n");
  when(taReport.getTaskAttemptState()).thenReturn(taState);
  when(taReport.getDiagnosticInfo()).thenReturn("");

  when(attempt.getReport()).thenReturn(taReport);

  attempts.put(taId, attempt);
  when(task.getAttempts()).thenReturn(attempts);

  app.setTask(task);
  Job job = mock(Job.class);
  when(job.getUserName()).thenReturn("User");
  app.setJob(job);

  AttemptsBlockForTest block = new AttemptsBlockForTest(app);
  block.addParameter(AMParams.TASK_TYPE, "r");

  PrintWriter pWriter = new PrintWriter(data);
  Block html = new BlockForTest(new HtmlBlockForTest(), pWriter, 0, false);

  block.render(html);
  pWriter.flush();
  // should be printed information about attempts
  assertTrue(data.toString().contains("0 attempt_0_0001_r_000000_0"));
  assertTrue(data.toString().contains("SUCCEEDED"));
  assertFalse(data.toString().contains("Processed 128/128 records <p> \n"));
  assertTrue(data.toString().contains("Processed 128\\/128 records &lt;p&gt; \\n"));
  assertTrue(data.toString().contains(
          "_0005_01_000001:attempt_0_0001_r_000000_0:User:"));
  assertTrue(data.toString().contains("100002"));
  assertTrue(data.toString().contains("100010"));
  assertTrue(data.toString().contains("100011"));
  assertTrue(data.toString().contains("100012"));
}