hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r807147 - in /hadoop/mapreduce/trunk: ./ src/java/org/apache/hadoop/mapred/ src/test/mapred/org/apache/hadoop/mapred/
Date Mon, 24 Aug 2009 11:15:14 GMT
Author: ddas
Date: Mon Aug 24 11:15:13 2009
New Revision: 807147

URL: http://svn.apache.org/viewvc?rev=807147&view=rev
Log:
MAPREDUCE-807. Handles the AccessControlException during the deletion of mapred.system.dir
in the JobTracker. The JobTracker will bail out if it encounters such an exception. Contributed
by Amar Kamat.

Added:
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMapredSystemDir.java
Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/FakeObjectUtilities.java
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/MiniMRCluster.java
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMRServerPorts.java
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerBlacklisting.java
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTrackerReservation.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Mon Aug 24 11:15:13 2009
@@ -456,3 +456,7 @@
     MAPREDUCE-818. Fixes Counters#getGroup API. (Amareshwari Sriramadasu 
     via sharad)
 
+    MAPREDUCE-807. Handles the AccessControlException during the deletion of
+    mapred.system.dir in the JobTracker. The JobTracker will bail out if it
+    encounters such an exception. (Amar Kamat via ddas)
+

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java Mon Aug 24 11:15:13
2009
@@ -188,19 +188,18 @@
    * @param conf configuration for the JobTracker.
    * @throws IOException
    */
-  public static JobTracker startTracker(JobConf conf
-                                        ) throws IOException,
-                                                 InterruptedException {
+  public static JobTracker startTracker(JobConf conf) 
+  throws IOException, InterruptedException, LoginException {
     return startTracker(conf, DEFAULT_CLOCK);
   }
 
   static JobTracker startTracker(JobConf conf, Clock clock) 
-  throws IOException, InterruptedException {
+  throws IOException, InterruptedException, LoginException {
     return startTracker(conf, clock, generateNewIdentifier());
   }
 
   static JobTracker startTracker(JobConf conf, Clock clock, String identifier) 
-  throws IOException, InterruptedException {
+  throws IOException, InterruptedException, LoginException {
     JobTracker result = null;
     while (true) {
       try {
@@ -213,6 +212,10 @@
         throw e;
       } catch (UnknownHostException e) {
         throw e;
+      } catch (AccessControlException ace) {
+        // in case of jobtracker not having right access
+        // bail out
+        throw ace;
       } catch (IOException e) {
         LOG.warn("Error starting tracker: " + 
                  StringUtils.stringifyException(e));
@@ -1784,25 +1787,23 @@
 
   private QueueManager queueManager;
 
-  JobTracker(JobConf conf) throws IOException,InterruptedException{
+  JobTracker(JobConf conf) 
+  throws IOException,InterruptedException, LoginException {
     this(conf, new Clock());
   }
   /**
    * Start the JobTracker process, listen on the indicated port
    */
-  JobTracker(JobConf conf, Clock clock) throws IOException, InterruptedException {
+  JobTracker(JobConf conf, Clock clock) 
+  throws IOException, InterruptedException, LoginException {
     this(conf, clock, generateNewIdentifier());
   }
 
   JobTracker(JobConf conf, Clock newClock, String jobtrackerIndentifier) 
-  throws IOException, InterruptedException {
+  throws IOException, InterruptedException, LoginException {
     // find the owner of the process
     clock = newClock;
-    try {
-      mrOwner = UnixUserGroupInformation.login(conf);
-    } catch (LoginException e) {
-      throw new IOException(StringUtils.stringifyException(e));
-    }
+    mrOwner = UnixUserGroupInformation.login(conf);
     supergroup = conf.get("mapred.permissions.supergroup", "supergroup");
     LOG.info("Starting jobtracker with owner as " + mrOwner.getUserName() 
              + " and supergroup as " + supergroup);
@@ -1918,7 +1919,7 @@
     // start the recovery manager
     recoveryManager = new RecoveryManager();
     
-    while (true) {
+    while (!Thread.currentThread().isInterrupted()) {
       try {
         // if we haven't contacted the namenode go ahead and do it
         if (fs == null) {
@@ -1964,17 +1965,23 @@
           break;
         }
         LOG.error("Mkdirs failed to create " + systemDir);
+      } catch (AccessControlException ace) {
+        LOG.warn("Failed to operate on mapred.system.dir (" + systemDir 
+                 + ") because of permissions.");
+        LOG.warn("Manually delete the mapred.system.dir (" + systemDir 
+                 + ") and then start the JobTracker.");
+        LOG.warn("Bailing out ... ");
+        throw ace;
       } catch (IOException ie) {
-        if (ie instanceof RemoteException && 
-            AccessControlException.class.getName().equals(
-                ((RemoteException)ie).getClassName())) {
-          throw ie;
-        }
         LOG.info("problem cleaning system directory: " + systemDir, ie);
       }
       Thread.sleep(FS_ACCESS_RETRY_PERIOD);
     }
     
+    if (Thread.currentThread().isInterrupted()) {
+      throw new InterruptedException();
+    }
+    
     // Same with 'localDir' except it's always on the local disk.
     jobConf.deleteLocalFiles(SUBDIR);
 

Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/FakeObjectUtilities.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/FakeObjectUtilities.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/FakeObjectUtilities.java
(original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/FakeObjectUtilities.java
Mon Aug 24 11:15:13 2009
@@ -22,6 +22,8 @@
 import java.util.Collection;
 import java.util.Iterator;
 
+import javax.security.auth.login.LoginException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.Path;
@@ -48,7 +50,7 @@
     private String[] trackers;
 
     FakeJobTracker(JobConf conf, Clock clock, String[] tts) throws IOException, 
-    InterruptedException {
+    InterruptedException, LoginException {
       super(conf, clock);
       this.trackers = tts;
       //initialize max{Map/Reduce} task capacities to twice the clustersize

Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/MiniMRCluster.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/MiniMRCluster.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/MiniMRCluster.java (original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/MiniMRCluster.java Mon
Aug 24 11:15:13 2009
@@ -580,11 +580,20 @@
    * Start the jobtracker.
    */
   public void startJobTracker() {
+    startJobTracker(true);
+  }
+
+  public void startJobTracker(boolean wait) {
     //  Create the JobTracker
     jobTracker = new JobTrackerRunner(conf, clock);
     jobTrackerThread = new Thread(jobTracker);
         
     jobTrackerThread.start();
+
+    if (!wait) {
+      return;
+    }
+
     while (jobTracker.isActive() && !jobTracker.isUp()) {
       try {                                     // let daemons get started
         Thread.sleep(1000);

Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMRServerPorts.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMRServerPorts.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMRServerPorts.java
(original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMRServerPorts.java
Mon Aug 24 11:15:13 2009
@@ -18,6 +18,9 @@
 package org.apache.hadoop.mapred;
 
 import java.io.IOException;
+
+import javax.security.auth.login.LoginException;
+
 import junit.framework.TestCase;
 import org.apache.hadoop.hdfs.TestHDFSServerPorts;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
@@ -57,7 +60,7 @@
    * Check whether the JobTracker can be started.
    */
   private JobTracker startJobTracker(JobConf conf, JTRunner runner) 
-  throws IOException {
+  throws IOException, LoginException {
     conf.set("mapred.job.tracker", "localhost:0");
     conf.set("mapred.job.tracker.http.address", "0.0.0.0:0");
     JobTracker jt = null;
@@ -87,7 +90,7 @@
    * Check whether the JobTracker can be started.
    */
   private boolean canStartJobTracker(JobConf conf) 
-  throws IOException, InterruptedException {
+  throws IOException, InterruptedException, LoginException {
     JobTracker jt = null;
     try {
       jt = JobTracker.startTracker(conf);

Added: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMapredSystemDir.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMapredSystemDir.java?rev=807147&view=auto
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMapredSystemDir.java
(added)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestMapredSystemDir.java
Mon Aug 24 11:15:13 2009
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.mapred;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.security.*;
+
+/**
+ * Test if JobTracker is resilient to garbage in mapred.system.dir.
+ */
+public class TestMapredSystemDir extends TestCase {
+  private static final Log LOG = LogFactory.getLog(TestMapredSystemDir.class);
+  
+  // dfs ugi
+  private static final UnixUserGroupInformation DFS_UGI = 
+    TestMiniMRWithDFSWithDistinctUsers.createUGI("dfs", true);
+  // mapred ugi
+  private static final UnixUserGroupInformation MR_UGI = 
+    TestMiniMRWithDFSWithDistinctUsers.createUGI("mr", false);
+  private static final FsPermission SYSTEM_DIR_PERMISSION =
+    FsPermission.createImmutable((short) 0733); // rwx-wx-wx
+  
+  public void testGarbledMapredSystemDir() throws Exception {
+    MiniDFSCluster dfs = null;
+    MiniMRCluster mr = null;
+    try {
+      // start dfs
+      Configuration conf = new Configuration();
+      conf.set("dfs.permissions.supergroup", "supergroup");
+      UnixUserGroupInformation.saveToConf(conf,
+          UnixUserGroupInformation.UGI_PROPERTY_NAME, DFS_UGI);
+      dfs = new MiniDFSCluster(conf, 1, true, null);
+      FileSystem fs = dfs.getFileSystem();
+      
+      // create mapred.system.dir
+      Path mapredSysDir = new Path("/mapred");
+      fs.mkdirs(mapredSysDir);
+      fs.setPermission(mapredSysDir, new FsPermission(SYSTEM_DIR_PERMISSION));
+      fs.setOwner(mapredSysDir, "mr", "mrgroup");
+
+      // start mr (i.e jobtracker)
+      Configuration mrConf = new Configuration();
+      UnixUserGroupInformation.saveToConf(mrConf,
+          UnixUserGroupInformation.UGI_PROPERTY_NAME, MR_UGI);
+      mr = new MiniMRCluster(0, 0, 0, dfs.getFileSystem().getUri().toString(),
+                             1, null, null, MR_UGI, new JobConf(mrConf));
+      JobTracker jobtracker = mr.getJobTrackerRunner().getJobTracker();
+      
+      // add garbage to mapred.system.dir
+      Path garbage = new Path(jobtracker.getSystemDir(), "garbage");
+      fs.mkdirs(garbage);
+      fs.setPermission(garbage, new FsPermission(SYSTEM_DIR_PERMISSION));
+      fs.setOwner(garbage, "test", "test-group");
+      
+      // stop the jobtracker
+      mr.stopJobTracker();
+      mr.getJobTrackerConf().setBoolean("mapred.jobtracker.restart.recover", 
+                                        false);
+      // start jobtracker but dont wait for it to be up
+      mr.startJobTracker(false);
+
+      // check 5 times .. each time wait for 2 secs to check if the jobtracker
+      // has crashed or not.
+      for (int i = 0; i < 5; ++i) {
+        LOG.info("Check #" + i);
+        if (!mr.getJobTrackerRunner().isActive()) {
+          return;
+        }
+        UtilsForTests.waitFor(2000);
+      }
+
+      assertFalse("JobTracker did not bail out (waited for 10 secs)", 
+                  mr.getJobTrackerRunner().isActive());
+    } finally {
+      if (dfs != null) { dfs.shutdown(); }
+      if (mr != null) { mr.shutdown();}
+    }
+  }
+}
\ No newline at end of file

Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerBlacklisting.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerBlacklisting.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerBlacklisting.java
(original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerBlacklisting.java
Mon Aug 24 11:15:13 2009
@@ -26,6 +26,8 @@
 import java.util.Set;
 import java.util.Map.Entry;
 
+import javax.security.auth.login.LoginException;
+
 import junit.extensions.TestSetup;
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -85,7 +87,7 @@
       org.apache.hadoop.mapred.FakeObjectUtilities.FakeJobTracker {
   
     FakeJobTracker(JobConf conf, Clock clock, String[] tts) throws IOException,
-        InterruptedException {
+        InterruptedException, LoginException {
       super(conf, clock, tts);
     }
 

Modified: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTrackerReservation.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTrackerReservation.java?rev=807147&r1=807146&r2=807147&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTrackerReservation.java
(original)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTrackerReservation.java
Mon Aug 24 11:15:13 2009
@@ -20,6 +20,8 @@
 import java.io.IOException;
 import java.util.ArrayList;
 
+import javax.security.auth.login.LoginException;
+
 import org.apache.hadoop.mapred.FakeObjectUtilities.FakeJobInProgress;
 import org.apache.hadoop.mapreduce.TaskType;
 import org.apache.hadoop.mapreduce.server.jobtracker.TaskTracker;
@@ -39,7 +41,7 @@
       org.apache.hadoop.mapred.FakeObjectUtilities.FakeJobTracker {
 
     FakeJobTracker(JobConf conf, Clock clock, String[] tts) throws IOException,
-        InterruptedException {
+        InterruptedException, LoginException {
       super(conf, clock, tts);
     }
 



Mime
View raw message