1
0
Pārlūkot izejas kodu

HADOOP-236. JobTacker now refuses connection from a task tracker with a different version number. Contributed by Sharad Agarwal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@663829 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 17 gadi atpakaļ
vecāks
revīzija
1231caef3b

+ 4 - 0
CHANGES.txt

@@ -235,6 +235,10 @@ Trunk (unreleased changes)
       deprecated mapred.map.output.compression.type 
     (acmurthy)
 
+    HADOOP-236. JobTacker now refuses connection from a task tracker with a 
+    different version number. (Sharad Agarwal via ddas)
+
+
   OPTIMIZATIONS
 
     HADOOP-3274. The default constructor of BytesWritable creates empty 

+ 7 - 1
src/java/org/apache/hadoop/mapred/InterTrackerProtocol.java

@@ -42,8 +42,9 @@ interface InterTrackerProtocol extends VersionedProtocol {
    * version 10 changes the TaskStatus representation for HADOOP-2208
    * version 11 changes string to JobID in getTaskCompletionEvents().
    * version 12 changes the counters representation for HADOOP-1915
+   * version 13 added call getBuildVersion() for HADOOP-236
    */
-  public static final long versionID = 12L;
+  public static final long versionID = 13L;
   
   public final static int TRACKERS_OK = 0;
   public final static int UNKNOWN_TASKTRACKER = 1;
@@ -102,6 +103,11 @@ interface InterTrackerProtocol extends VersionedProtocol {
   TaskCompletionEvent[] getTaskCompletionEvents(JobID jobid, int fromEventId
       , int maxEvents) throws IOException;
   
+  
+  /**
+   * Returns the buildVersion of the JobTracker 
+   */
+  public String getBuildVersion() throws IOException;
 }
 
 

+ 5 - 0
src/java/org/apache/hadoop/mapred/JobTracker.java

@@ -65,6 +65,7 @@ import org.apache.hadoop.net.ScriptBasedMapping;
 import org.apache.hadoop.util.HostsFileReader;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.util.VersionInfo;
 
 /*******************************************************
  * JobTracker is the central location for submitting and 
@@ -1224,6 +1225,10 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
   ////////////////////////////////////////////////////
   // InterTrackerProtocol
   ////////////////////////////////////////////////////
+  
+  public String getBuildVersion() throws IOException{
+    return VersionInfo.getBuildVersion();
+  }
 
   /**
    * The periodic heartbeat mechanism between the {@link TaskTracker} and

+ 18 - 0
src/java/org/apache/hadoop/mapred/TaskTracker.java

@@ -75,6 +75,7 @@ import org.apache.hadoop.util.DiskChecker;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.RunJar;
 import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.util.VersionInfo;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 import org.apache.hadoop.util.Shell.ShellCommandExecutor;
 import org.apache.log4j.LogManager;
@@ -899,6 +900,23 @@ public class TaskTracker
           }
         }
 
+        //verify the buildVersion if justStarted
+        if(justStarted){
+          String jobTrackerBV = jobClient.getBuildVersion();
+          if(!VersionInfo.getBuildVersion().equals(jobTrackerBV)) {
+            String msg = "Shutting down. Incompatible buildVersion." +
+            "\nJobTracker's: " + jobTrackerBV + 
+            "\nTaskTracker's: "+ VersionInfo.getBuildVersion();
+            LOG.error(msg);
+            try {
+              jobClient.reportTaskTrackerError(taskTrackerName, null, msg);
+            } catch(Exception e ) {
+              LOG.info("Problem reporting to jobtracker: " + e);
+            }
+            return State.DENIED;
+          }
+        }
+        
         // Send the heartbeat and process the jobtracker's directives
         HeartbeatResponse heartbeatResponse = transmitHeartBeat();
         TaskTrackerAction[] actions = heartbeatResponse.getActions();

+ 11 - 0
src/java/org/apache/hadoop/util/VersionInfo.java

@@ -80,6 +80,17 @@ public class VersionInfo {
     return version != null ? version.url() : "Unknown";
   }
   
+  /**
+   * Returns the buildVersion which includes version, 
+   * revision, user and date. 
+   */
+  public static String getBuildVersion(){
+    return VersionInfo.getVersion() + 
+    " from " + VersionInfo.getRevision() +
+    " by " + VersionInfo.getUser() + 
+    " on " + VersionInfo.getDate();
+  }
+  
   public static void main(String[] args) {
     System.out.println("Hadoop " + getVersion());
     System.out.println("Subversion " + getUrl() + " -r " + getRevision());