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 019 package org.apache.hadoop.mapred; 020 021 import org.apache.hadoop.classification.InterfaceAudience; 022 import org.apache.hadoop.classification.InterfaceStability; 023 024 /** 025 * This is used to track task completion events on 026 * job tracker. 027 * @deprecated Use 028 * {@link org.apache.hadoop.mapreduce.TaskCompletionEvent} instead 029 */ 030 @Deprecated 031 @InterfaceAudience.Public 032 @InterfaceStability.Stable 033 public class TaskCompletionEvent 034 extends org.apache.hadoop.mapreduce.TaskCompletionEvent { 035 @InterfaceAudience.Public 036 @InterfaceStability.Stable 037 static public enum Status {FAILED, KILLED, SUCCEEDED, OBSOLETE, TIPFAILED}; 038 039 public static final TaskCompletionEvent[] EMPTY_ARRAY = 040 new TaskCompletionEvent[0]; 041 /** 042 * Default constructor for Writable. 043 * 044 */ 045 public TaskCompletionEvent() { 046 super(); 047 } 048 049 /** 050 * Constructor. eventId should be created externally and incremented 051 * per event for each job. 052 * @param eventId event id, event id should be unique and assigned in 053 * incrementally, starting from 0. 054 * @param taskId task id 055 * @param status task's status 056 * @param taskTrackerHttp task tracker's host:port for http. 057 */ 058 public TaskCompletionEvent(int eventId, 059 TaskAttemptID taskId, 060 int idWithinJob, 061 boolean isMap, 062 Status status, 063 String taskTrackerHttp){ 064 super(eventId, taskId, idWithinJob, isMap, org.apache.hadoop.mapreduce. 065 TaskCompletionEvent.Status.valueOf(status.name()), taskTrackerHttp); 066 } 067 068 static TaskCompletionEvent downgrade( 069 org.apache.hadoop.mapreduce.TaskCompletionEvent event) { 070 return new TaskCompletionEvent(event.getEventId(), 071 TaskAttemptID.downgrade(event.getTaskAttemptId()),event.idWithinJob(), 072 event.isMapTask(), Status.valueOf(event.getStatus().name()), 073 event.getTaskTrackerHttp()); 074 } 075 /** 076 * Returns task id. 077 * @return task id 078 * @deprecated use {@link #getTaskAttemptId()} instead. 079 */ 080 @Deprecated 081 public String getTaskId() { 082 return getTaskAttemptId().toString(); 083 } 084 085 /** 086 * Returns task id. 087 * @return task id 088 */ 089 public TaskAttemptID getTaskAttemptId() { 090 return TaskAttemptID.downgrade(super.getTaskAttemptId()); 091 } 092 093 /** 094 * Returns enum Status.SUCESS or Status.FAILURE. 095 * @return task tracker status 096 */ 097 public Status getTaskStatus() { 098 return Status.valueOf(super.getStatus().name()); 099 } 100 101 /** 102 * Sets task id. 103 * @param taskId 104 * @deprecated use {@link #setTaskAttemptId(TaskAttemptID)} instead. 105 */ 106 @Deprecated 107 public void setTaskId(String taskId) { 108 this.setTaskAttemptId(TaskAttemptID.forName(taskId)); 109 } 110 111 /** 112 * Sets task id. 113 * @param taskId 114 */ 115 protected void setTaskAttemptId(TaskAttemptID taskId) { 116 super.setTaskAttemptId(taskId); 117 } 118 119 /** 120 * Set task status. 121 * @param status 122 */ 123 protected void setTaskStatus(Status status) { 124 super.setTaskStatus(org.apache.hadoop.mapreduce. 125 TaskCompletionEvent.Status.valueOf(status.name())); 126 } 127 128 /** 129 * Set the task completion time 130 * @param taskCompletionTime time (in millisec) the task took to complete 131 */ 132 protected void setTaskRunTime(int taskCompletionTime) { 133 super.setTaskRunTime(taskCompletionTime); 134 } 135 136 /** 137 * set event Id. should be assigned incrementally starting from 0. 138 * @param eventId 139 */ 140 protected void setEventId(int eventId) { 141 super.setEventId(eventId); 142 } 143 144 /** 145 * Set task tracker http location. 146 * @param taskTrackerHttp 147 */ 148 protected void setTaskTrackerHttp(String taskTrackerHttp) { 149 super.setTaskTrackerHttp(taskTrackerHttp); 150 } 151 }