Author: ddas
Date: Thu Feb 26 11:23:54 2009
New Revision: 748090
URL: http://svn.apache.org/viewvc?rev=748090&view=rev
Log:
HADOOP-5248. A testcase that checks for the existence of job directory after
the job completes. Fails if it exists. Contributed by Devaraj Das.
Added:
hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestJobDirCleanup.java
Modified:
hadoop/core/trunk/CHANGES.txt
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=748090&r1=748089&r2=748090&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Feb 26 11:23:54 2009
@@ -575,6 +575,9 @@
HADOOP-4804. Provide Forrest documentation for the Fair Scheduler.
(Sreekanth Ramakrishnan via yhemanth)
+ HADOOP-5248. A testcase that checks for the existence of job directory
+ after the job completes. Fails if it exists. (ddas)
+
OPTIMIZATIONS
HADOOP-3293. Fixes FileInputFormat to do provide locations for splits
Added:
hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestJobDirCleanup.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestJobDirCleanup.java?rev=748090&view=auto
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestJobDirCleanup.java
(added)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestJobDirCleanup.java
Thu Feb 26 11:23:54 2009
@@ -0,0 +1,86 @@
+/**
+ * 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.io.File;
+import java.io.IOException;
+
+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.examples.SleepJob;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.util.ToolRunner;
+
+public class TestJobDirCleanup extends TestCase {
+ //The testcase brings up a cluster with many trackers, and
+ //runs a job with a single map and many reduces. The check is
+ //to see whether the job directories are cleaned up at the
+ //end of the job (indirectly testing whether all tasktrackers
+ //got a KillJobAction).
+ private static final Log LOG =
+ LogFactory.getLog(TestEmptyJobWithDFS.class.getName());
+ private void runSleepJob(JobConf conf) throws Exception {
+ String[] args = { "-m", "1", "-r", "10", "-mt", "1000", "-rt", "10000" };
+ ToolRunner.run(conf, new SleepJob(), args);
+ }
+ public void testJobDirCleanup() throws IOException {
+ String namenode = null;
+ MiniDFSCluster dfs = null;
+ MiniMRCluster mr = null;
+ FileSystem fileSys = null;
+ try {
+ final int taskTrackers = 10;
+ final int jobTrackerPort = 60050;
+ Configuration conf = new Configuration();
+ JobConf mrConf = new JobConf();
+ mrConf.set("mapred.tasktracker.reduce.tasks.maximum", "1");
+ dfs = new MiniDFSCluster(conf, 1, true, null);
+ fileSys = dfs.getFileSystem();
+ namenode = fileSys.getUri().toString();
+ mr = new MiniMRCluster(10, namenode, 3,
+ null, null, mrConf);
+ final String jobTrackerName = "localhost:" + mr.getJobTrackerPort();
+ JobConf jobConf = mr.createJobConf();
+ runSleepJob(jobConf);
+ for(int i=0; i < taskTrackers; ++i) {
+ String jobDirStr = mr.getTaskTrackerLocalDir(i)+
+ "/taskTracker/jobcache";
+ File jobDir = new File(jobDirStr);
+ String[] contents = jobDir.list();
+ while (contents.length > 0) {
+ try {
+ Thread.sleep(1000);
+ LOG.warn(jobDir +" not empty yet");
+ contents = jobDir.list();
+ } catch (InterruptedException ie){}
+ }
+ }
+ } catch (Exception ee){
+ } finally {
+ if (fileSys != null) { fileSys.close(); }
+ if (dfs != null) { dfs.shutdown(); }
+ if (mr != null) { mr.shutdown(); }
+ }
+ }
+}
+
+