hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r807148 - in /hadoop/common/branches/branch-0.20: CHANGES.txt src/mapred/org/apache/hadoop/mapred/JobTracker.java src/test/org/apache/hadoop/mapred/MiniMRCluster.java src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java
Date Mon, 24 Aug 2009 11:20:22 GMT
Author: ddas
Date: Mon Aug 24 11:20:21 2009
New Revision: 807148

URL: http://svn.apache.org/viewvc?rev=807148&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/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java
Modified:
    hadoop/common/branches/branch-0.20/CHANGES.txt
    hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobTracker.java
    hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/MiniMRCluster.java

Modified: hadoop/common/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/CHANGES.txt?rev=807148&r1=807147&r2=807148&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20/CHANGES.txt Mon Aug 24 11:20:21 2009
@@ -231,6 +231,10 @@
     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)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobTracker.java?rev=807148&r1=807147&r2=807148&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobTracker.java
(original)
+++ hadoop/common/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobTracker.java
Mon Aug 24 11:20:21 2009
@@ -186,6 +186,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));
@@ -1651,7 +1655,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) {
@@ -1691,17 +1695,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/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/MiniMRCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/MiniMRCluster.java?rev=807148&r1=807147&r2=807148&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/MiniMRCluster.java
(original)
+++ hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/MiniMRCluster.java
Mon Aug 24 11:20:21 2009
@@ -550,11 +550,20 @@
    * Start the jobtracker.
    */
   public void startJobTracker() {
+    startJobTracker(true);
+  }
+  
+  void startJobTracker(boolean wait) {
     //  Create the JobTracker
     jobTracker = new JobTrackerRunner(conf);
     jobTrackerThread = new Thread(jobTracker);
         
     jobTrackerThread.start();
+    
+    if (!wait) {
+    	return;
+    }
+    
     while (jobTracker.isActive() && !jobTracker.isUp()) {
       try {                                     // let daemons get started
         Thread.sleep(1000);

Added: hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java?rev=807148&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java
(added)
+++ hadoop/common/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestMapredSystemDir.java
Mon Aug 24 11:20:21 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



Mime
View raw message