001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.hadoop.mapred; 019 020 import java.util.ArrayList; 021 import java.util.Collection; 022 import java.util.List; 023 024 import org.apache.hadoop.classification.InterfaceAudience; 025 import org.apache.hadoop.classification.InterfaceStability; 026 027 /** A report on the state of a task. 028 * @deprecated Use {@link org.apache.hadoop.mapreduce.TaskReport} instead 029 **/ 030 @Deprecated 031 @InterfaceAudience.Public 032 @InterfaceStability.Stable 033 public class TaskReport extends org.apache.hadoop.mapreduce.TaskReport { 034 035 public TaskReport() { 036 super(); 037 } 038 039 /** 040 * Creates a new TaskReport object 041 * @param taskid 042 * @param progress 043 * @param state 044 * @param diagnostics 045 * @param startTime 046 * @param finishTime 047 * @param counters 048 * @deprecated 049 */ 050 @Deprecated 051 TaskReport(TaskID taskid, float progress, String state, 052 String[] diagnostics, long startTime, long finishTime, 053 Counters counters) { 054 this(taskid, progress, state, diagnostics, null, startTime, finishTime, 055 counters); 056 } 057 058 /** 059 * Creates a new TaskReport object 060 * @param taskid 061 * @param progress 062 * @param state 063 * @param diagnostics 064 * @param currentStatus 065 * @param startTime 066 * @param finishTime 067 * @param counters 068 */ 069 TaskReport(TaskID taskid, float progress, String state, 070 String[] diagnostics, TIPStatus currentStatus, 071 long startTime, long finishTime, 072 Counters counters) { 073 super(taskid, progress, state, diagnostics, currentStatus, startTime, 074 finishTime, new org.apache.hadoop.mapreduce.Counters(counters)); 075 } 076 077 static TaskReport downgrade( 078 org.apache.hadoop.mapreduce.TaskReport report) { 079 return new TaskReport(TaskID.downgrade(report.getTaskId()), 080 report.getProgress(), report.getState(), report.getDiagnostics(), 081 report.getCurrentStatus(), report.getStartTime(), report.getFinishTime(), 082 Counters.downgrade(report.getTaskCounters())); 083 } 084 085 static TaskReport[] downgradeArray(org.apache.hadoop. 086 mapreduce.TaskReport[] reports) { 087 List<TaskReport> ret = new ArrayList<TaskReport>(); 088 for (org.apache.hadoop.mapreduce.TaskReport report : reports) { 089 ret.add(downgrade(report)); 090 } 091 return ret.toArray(new TaskReport[0]); 092 } 093 094 /** The id of the task. */ 095 public TaskID getTaskID() { return TaskID.downgrade(super.getTaskId()); } 096 097 public Counters getCounters() { 098 return Counters.downgrade(super.getTaskCounters()); 099 } 100 101 /** 102 * set successful attempt ID of the task. 103 */ 104 public void setSuccessfulAttempt(TaskAttemptID t) { 105 super.setSuccessfulAttemptId(t); 106 } 107 /** 108 * Get the attempt ID that took this task to completion 109 */ 110 public TaskAttemptID getSuccessfulTaskAttempt() { 111 return TaskAttemptID.downgrade(super.getSuccessfulTaskAttemptId()); 112 } 113 /** 114 * set running attempt(s) of the task. 115 */ 116 public void setRunningTaskAttempts( 117 Collection<TaskAttemptID> runningAttempts) { 118 Collection<org.apache.hadoop.mapreduce.TaskAttemptID> attempts = 119 new ArrayList<org.apache.hadoop.mapreduce.TaskAttemptID>(); 120 for (TaskAttemptID id : runningAttempts) { 121 attempts.add(id); 122 } 123 super.setRunningTaskAttemptIds(attempts); 124 } 125 /** 126 * Get the running task attempt IDs for this task 127 */ 128 public Collection<TaskAttemptID> getRunningTaskAttempts() { 129 Collection<TaskAttemptID> attempts = new ArrayList<TaskAttemptID>(); 130 for (org.apache.hadoop.mapreduce.TaskAttemptID id : 131 super.getRunningTaskAttemptIds()) { 132 attempts.add(TaskAttemptID.downgrade(id)); 133 } 134 return attempts; 135 } 136 137 /** 138 * set finish time of task. 139 * @param finishTime finish time of task. 140 */ 141 protected void setFinishTime(long finishTime) { 142 super.setFinishTime(finishTime); 143 } 144 145 /** 146 * set start time of the task. 147 */ 148 protected void setStartTime(long startTime) { 149 super.setStartTime(startTime); 150 } 151 152 }