Java Code Examples for org.apache.hadoop.mapreduce.TaskType#equals()

The following examples show how to use org.apache.hadoop.mapreduce.TaskType#equals() . 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 File: TestCapacityScheduler.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the number of slots of type 'type' from the queue 'queue'.
 * incrMapIndex and incrReduceIndex are set , when expected output string is
 * changed.these values can be set if the index of
 * "Used capacity: %d (%.1f%% of Capacity)"
 * is changed.
 * 
 * @param queue
 * @param type
 * @param numActiveUsers in the queue at present.
 * @param expectedOccupiedSlots
 * @param expectedOccupiedSlotsPercent
 * @param incrMapIndex
 * @param incrReduceIndex
 */
private void checkOccupiedSlots(
  String queue,
  TaskType type, int numActiveUsers,
  int expectedOccupiedSlots, float expectedOccupiedSlotsPercent,int incrMapIndex
  ,int incrReduceIndex
) {
  scheduler.updateQSIInfoForTests();
  QueueManager queueManager = scheduler.taskTrackerManager.getQueueManager();
  String schedulingInfo =
      queueManager.getJobQueueInfo(queue).getSchedulingInfo();
  String[] infoStrings = schedulingInfo.split("\n");
  int index = -1;
  if (type.equals(TaskType.MAP)) {
    index = 7+ incrMapIndex;
  } else if (type.equals(TaskType.REDUCE)) {
    index = (numActiveUsers == 0 ? 12 : 13 + numActiveUsers)+incrReduceIndex;
  }
  LOG.info(infoStrings[index]);
  assertEquals(String.format("Used capacity: %d (%.1f%% of Capacity)",
      expectedOccupiedSlots, expectedOccupiedSlotsPercent),
      infoStrings[index]);
}
 
Example 2
Source File: HistoryViewer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void printTasks(TaskType taskType, String status) {
  Map<TaskID, JobHistoryParser.TaskInfo> tasks = job.getAllTasks();
  StringBuffer header = new StringBuffer();
  header.append("\n").append(status).append(" ");
  header.append(taskType).append(" task list for ").append(jobId);
  header.append("\nTaskId\t\tStartTime\tFinishTime\tError");
  if (TaskType.MAP.equals(taskType)) {
    header.append("\tInputSplits");
  }
  header.append("\n====================================================");
  StringBuffer taskList = new StringBuffer();
  for (JobHistoryParser.TaskInfo task : tasks.values()) {
    if (taskType.equals(task.getTaskType()) &&
       (status.equals(task.getTaskStatus())
        || status.equalsIgnoreCase("ALL"))) {
      taskList.setLength(0);
      taskList.append(task.getTaskId());
      taskList.append("\t").append(StringUtils.getFormattedTimeWithDiff(
                 dateFormat, task.getStartTime(), 0));
      taskList.append("\t").append(StringUtils.getFormattedTimeWithDiff(
                 dateFormat, task.getFinishTime(),
                 task.getStartTime())); 
      taskList.append("\t").append(task.getError());
      if (TaskType.MAP.equals(taskType)) {
        taskList.append("\t").append(task.getSplitLocations());
      }
      if (taskList != null) {
        System.out.println(header.toString());
        System.out.println(taskList.toString());
      }
    }
  }
}
 
Example 3
Source File: HistoryViewer.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void printTasks(TaskType taskType, String status) {
  Map<TaskID, JobHistoryParser.TaskInfo> tasks = job.getAllTasks();
  StringBuffer header = new StringBuffer();
  header.append("\n").append(status).append(" ");
  header.append(taskType).append(" task list for ").append(jobId);
  header.append("\nTaskId\t\tStartTime\tFinishTime\tError");
  if (TaskType.MAP.equals(taskType)) {
    header.append("\tInputSplits");
  }
  header.append("\n====================================================");
  StringBuffer taskList = new StringBuffer();
  for (JobHistoryParser.TaskInfo task : tasks.values()) {
    if (taskType.equals(task.getTaskType()) &&
       (status.equals(task.getTaskStatus())
        || status.equalsIgnoreCase("ALL"))) {
      taskList.setLength(0);
      taskList.append(task.getTaskId());
      taskList.append("\t").append(StringUtils.getFormattedTimeWithDiff(
                 dateFormat, task.getStartTime(), 0));
      taskList.append("\t").append(StringUtils.getFormattedTimeWithDiff(
                 dateFormat, task.getFinishTime(),
                 task.getStartTime())); 
      taskList.append("\t").append(task.getError());
      if (TaskType.MAP.equals(taskType)) {
        taskList.append("\t").append(task.getSplitLocations());
      }
      if (taskList != null) {
        System.out.println(header.toString());
        System.out.println(taskList.toString());
      }
    }
  }
}
 
Example 4
Source File: JobTracker.java    From RDFS with Apache License 2.0 5 votes vote down vote up
void incrementReservations(TaskType type, int reservedSlots) {
  if (type.equals(TaskType.MAP)) {
    reservedMapSlots += reservedSlots;
  } else if (type.equals(TaskType.REDUCE)) {
    reservedReduceSlots += reservedSlots;
  }
}
 
Example 5
Source File: JobTracker.java    From RDFS with Apache License 2.0 5 votes vote down vote up
void decrementReservations(TaskType type, int reservedSlots) {
  if (type.equals(TaskType.MAP)) {
    reservedMapSlots -= reservedSlots;
  } else if (type.equals(TaskType.REDUCE)) {
    reservedReduceSlots -= reservedSlots;
  }
}
 
Example 6
Source File: HistoryViewer.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void printAllTaskAttempts(TaskType taskType) {
  Map<TaskID, TaskInfo> tasks = job.getAllTasks();
  StringBuffer taskList = new StringBuffer();
  taskList.append("\n").append(taskType);
  taskList.append(" task list for ").append(job.getJobId());
  taskList.append("\nTaskId\t\tStartTime");
  if (TaskType.REDUCE.equals(taskType)) {
    taskList.append("\tShuffleFinished\tSortFinished");
  }
  taskList.append("\tFinishTime\tHostName\tError\tTaskLogs");
  taskList.append("\n====================================================");
  System.out.println(taskList.toString());
  for (JobHistoryParser.TaskInfo task : tasks.values()) {
    for (JobHistoryParser.TaskAttemptInfo attempt : 
      task.getAllTaskAttempts().values()) {
      if (taskType.equals(task.getTaskType())){
        taskList.setLength(0); 
        taskList.append(attempt.getAttemptId()).append("\t");
        taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                        attempt.getStartTime(), 0)).append("\t");
        if (TaskType.REDUCE.equals(taskType)) {
          taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                          attempt.getShuffleFinishTime(),
                          attempt.getStartTime()));
          taskList.append("\t"); 
          taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat, 
                          attempt.getSortFinishTime(),
                          attempt.getShuffleFinishTime())); 
        } 
        taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                        attempt.getFinishTime(),
                        attempt.getStartTime())); 
        taskList.append("\t"); 
        taskList.append(attempt.getHostname()).append("\t");
        taskList.append(attempt.getError());
        String taskLogsUrl = getTaskLogsUrl(
            WebAppUtils.getHttpSchemePrefix(fs.getConf()), attempt);
        taskList.append(taskLogsUrl != null ? taskLogsUrl : "n/a");
        System.out.println(taskList.toString());
      }
    }
  }
}
 
Example 7
Source File: HistoryViewer.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void printAllTaskAttempts(TaskType taskType) {
  Map<TaskID, TaskInfo> tasks = job.getAllTasks();
  StringBuffer taskList = new StringBuffer();
  taskList.append("\n").append(taskType);
  taskList.append(" task list for ").append(job.getJobId());
  taskList.append("\nTaskId\t\tStartTime");
  if (TaskType.REDUCE.equals(taskType)) {
    taskList.append("\tShuffleFinished\tSortFinished");
  }
  taskList.append("\tFinishTime\tHostName\tError\tTaskLogs");
  taskList.append("\n====================================================");
  System.out.println(taskList.toString());
  for (JobHistoryParser.TaskInfo task : tasks.values()) {
    for (JobHistoryParser.TaskAttemptInfo attempt : 
      task.getAllTaskAttempts().values()) {
      if (taskType.equals(task.getTaskType())){
        taskList.setLength(0); 
        taskList.append(attempt.getAttemptId()).append("\t");
        taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                        attempt.getStartTime(), 0)).append("\t");
        if (TaskType.REDUCE.equals(taskType)) {
          taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                          attempt.getShuffleFinishTime(),
                          attempt.getStartTime()));
          taskList.append("\t"); 
          taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat, 
                          attempt.getSortFinishTime(),
                          attempt.getShuffleFinishTime())); 
        } 
        taskList.append(StringUtils.getFormattedTimeWithDiff(dateFormat,
                        attempt.getFinishTime(),
                        attempt.getStartTime())); 
        taskList.append("\t"); 
        taskList.append(attempt.getHostname()).append("\t");
        taskList.append(attempt.getError());
        String taskLogsUrl = getTaskLogsUrl(
            WebAppUtils.getHttpSchemePrefix(fs.getConf()), attempt);
        taskList.append(taskLogsUrl != null ? taskLogsUrl : "n/a");
        System.out.println(taskList.toString());
      }
    }
  }
}