You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by yh...@apache.org on 2009/05/06 07:44:59 UTC

svn commit: r772060 - in /hadoop/core/branches/branch-0.20: ./ src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/ src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/

Author: yhemanth
Date: Wed May  6 05:44:58 2009
New Revision: 772060

URL: http://svn.apache.org/viewvc?rev=772060&view=rev
Log:
HADOOP-5719. Remove jobs that failed initialization from the waiting queue in the capacity scheduler. Contributed by Sreekanth Ramakrishnan.

Added:
    hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobInitialization.java
Modified:
    hadoop/core/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/JobInitializationPoller.java
    hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacityScheduler.java

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=772060&r1=772059&r2=772060&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Wed May  6 05:44:58 2009
@@ -46,6 +46,9 @@
     HADOOP-5718. Remove the check for the default queue in capacity scheduler.
     (Sreekanth Ramakrishnan via yhemanth)
 
+    HADOOP-5719. Remove jobs that failed initialization from the waiting queue
+    in the capacity scheduler. (Sreekanth Ramakrishnan via yhemanth)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/JobInitializationPoller.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/JobInitializationPoller.java?rev=772060&r1=772059&r2=772060&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/JobInitializationPoller.java (original)
+++ hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/java/org/apache/hadoop/mapred/JobInitializationPoller.java Wed May  6 05:44:58 2009
@@ -20,7 +20,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeMap;
@@ -149,8 +148,8 @@
           } catch (Throwable t) {
             LOG.info("Job initialization failed:\n"
                 + StringUtils.stringifyException(t));
-            if (job != null)
-              job.fail();
+            jobQueueManager.removeJobFromWaitingQueue(job);
+            job.fail(); 
           }
         }
       }

Modified: hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacityScheduler.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacityScheduler.java?rev=772060&r1=772059&r2=772060&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacityScheduler.java (original)
+++ hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestCapacityScheduler.java Wed May  6 05:44:58 2009
@@ -248,6 +248,24 @@
     
   }
   
+  static class FakeFailingJobInProgress extends FakeJobInProgress {
+
+    public FakeFailingJobInProgress(JobID id, JobConf jobConf,
+        FakeTaskTrackerManager taskTrackerManager, String user) {
+      super(id, jobConf, taskTrackerManager, user);
+    }
+    
+    @Override
+    public synchronized void initTasks() throws IOException {
+      throw new IOException("Failed Initalization");
+    }
+    
+    @Override
+    synchronized void fail() {
+      this.status.setRunState(JobStatus.FAILED);
+    }
+  }
+  
   static class FakeTaskInProgress extends TaskInProgress {
     private boolean isMap;
     private FakeJobInProgress fakeJob;
@@ -2009,6 +2027,39 @@
     t = checkAssignment("tt1", "attempt_test_0001_r_000001_0 on tt1");
   }
   
+  public void testFailedJobInitalizations() throws Exception {
+    String[] qs = {"default"};
+    taskTrackerManager.addQueues(qs);
+    ArrayList<FakeQueueInfo> queues = new ArrayList<FakeQueueInfo>();
+    queues.add(new FakeQueueInfo("default", 100.0f, true, 100));
+    resConf.setFakeQueues(queues);
+    scheduler.setResourceManagerConf(resConf);
+    scheduler.start();
+
+    JobQueuesManager mgr = scheduler.jobQueuesManager;
+    
+    //Submit a job whose initialization would fail always.
+    FakeJobInProgress job =
+      new FakeFailingJobInProgress(new JobID("test", ++jobCounter),
+          new JobConf(), taskTrackerManager,"u1");
+    job.getStatus().setRunState(JobStatus.PREP);
+    taskTrackerManager.submitJob(job);
+    //check if job is present in waiting list.
+    assertEquals("Waiting job list does not contain submitted job",
+        1, mgr.getWaitingJobCount("default"));
+    assertTrue("Waiting job does not contain submitted job", 
+        mgr.getWaitingJobs("default").contains(job));
+    //initialization should fail now.
+    controlledInitializationPoller.selectJobsToInitialize();
+    //Check if the job has been properly cleaned up.
+    assertEquals("Waiting job list contains submitted job",
+        0, mgr.getWaitingJobCount("default"));
+    assertFalse("Waiting job contains submitted job", 
+        mgr.getWaitingJobs("default").contains(job));
+    assertFalse("Waiting job contains submitted job", 
+        mgr.getRunningJobQueue("default").contains(job));
+  }
+  
   private void checkRunningJobMovementAndCompletion() throws IOException {
     
     JobQueuesManager mgr = scheduler.jobQueuesManager;

Added: hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobInitialization.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobInitialization.java?rev=772060&view=auto
==============================================================================
--- hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobInitialization.java (added)
+++ hadoop/core/branches/branch-0.20/src/contrib/capacity-scheduler/src/test/org/apache/hadoop/mapred/TestJobInitialization.java Wed May  6 05:44:58 2009
@@ -0,0 +1,57 @@
+/**
+ * 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 java.util.Properties;
+import org.apache.hadoop.mapred.ControlledMapReduceJob.ControlledMapReduceJobRunner;
+
+public class TestJobInitialization extends ClusterWithCapacityScheduler {
+ 
+  public void testFailingJobInitalization() throws Exception {
+    Properties schedulerProps = new Properties();
+    schedulerProps.put(
+        "mapred.capacity-scheduler.queue.default.capacity", "100");
+    Properties clusterProps = new Properties();
+    clusterProps
+        .put("mapred.tasktracker.map.tasks.maximum", String.valueOf(1));
+    clusterProps.put("mapred.tasktracker.reduce.tasks.maximum", String
+        .valueOf(1));
+    clusterProps.put("mapred.jobtracker.maxtasks.per.job", String
+        .valueOf(1));
+    // cluster capacity 1 maps, 1 reduces
+    startCluster(1, clusterProps, schedulerProps);
+    ControlledMapReduceJobRunner jobRunner =
+      ControlledMapReduceJobRunner.getControlledMapReduceJobRunner(
+          getJobConf(), 3, 3);
+    jobRunner.start();
+    JobID myJobID = jobRunner.getJobID();
+    JobInProgress myJob = getJobTracker().getJob(myJobID);
+    while(!myJob.isComplete()) {
+      Thread.sleep(1000);
+    }
+    assertTrue("The submitted job successfully completed", 
+        myJob.status.getRunState() == JobStatus.FAILED);
+    CapacityTaskScheduler scheduler = (CapacityTaskScheduler) getJobTracker().getTaskScheduler();
+    JobQueuesManager mgr = scheduler.jobQueuesManager;
+    assertEquals("Failed job present in Waiting queue", 
+        0, mgr.getWaitingJobCount("default"));
+    assertFalse("Failed job present in Waiting queue", 
+        mgr.getWaitingJobs("default").contains(myJob));
+  }
+}