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.mapreduce;
019    
020    import java.io.DataInput;
021    import java.io.DataOutput;
022    import java.io.IOException;
023    
024    import org.apache.hadoop.classification.InterfaceAudience;
025    import org.apache.hadoop.classification.InterfaceStability;
026    import org.apache.hadoop.io.Text;
027    import org.apache.hadoop.io.Writable;
028    
029    /**
030     * Information about TaskTracker.
031     */
032    @InterfaceAudience.Public
033    @InterfaceStability.Evolving
034    public class TaskTrackerInfo implements Writable {
035      String name;
036      boolean isBlacklisted = false;
037      String reasonForBlacklist = "";
038      String blacklistReport = "";
039      
040      public TaskTrackerInfo() {
041      }
042      // construct an active tracker
043      public TaskTrackerInfo(String name) {
044        this.name = name;
045      }
046    
047      // construct blacklisted tracker
048      public TaskTrackerInfo(String name, String reasonForBlacklist,
049          String report) {
050        this.name = name;
051        this.isBlacklisted = true;
052        this.reasonForBlacklist = reasonForBlacklist;
053        this.blacklistReport = report;
054      }
055    
056      /**
057       * Gets the tasktracker's name.
058       * 
059       * @return tracker's name.
060       */
061      public String getTaskTrackerName() {
062        return name;
063      }
064      
065      /**
066       * Whether tracker is blacklisted
067       * @return true if tracker is blacklisted
068       *         false otherwise
069       */
070      public boolean isBlacklisted() {
071        return isBlacklisted;
072      }
073      
074      /**
075       * Gets the reason for which the tasktracker was blacklisted.
076       * 
077       * @return reason which tracker was blacklisted
078       */
079      public String getReasonForBlacklist() {
080        return reasonForBlacklist;
081      }
082    
083      /**
084       * Gets a descriptive report about why the tasktracker was blacklisted.
085       * 
086       * @return report describing why the tasktracker was blacklisted.
087       */
088      public String getBlacklistReport() {
089        return blacklistReport;
090      }
091      
092      @Override
093      public void readFields(DataInput in) throws IOException {
094        name = Text.readString(in);
095        isBlacklisted = in.readBoolean();
096        reasonForBlacklist = Text.readString(in);
097        blacklistReport = Text.readString(in);
098      }
099    
100      @Override
101      public void write(DataOutput out) throws IOException {
102        Text.writeString(out, name);
103        out.writeBoolean(isBlacklisted);
104        Text.writeString(out, reasonForBlacklist);
105        Text.writeString(out, blacklistReport);
106      }
107    
108    }