hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r732609 - in /hadoop/core/trunk: CHANGES.txt src/mapred/org/apache/hadoop/mapred/Task.java src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java src/test/testjar/CustomOutputCommitter.java
Date Thu, 08 Jan 2009 05:20:33 GMT
Author: ddas
Date: Wed Jan  7 21:20:28 2009
New Revision: 732609

URL: http://svn.apache.org/viewvc?rev=732609&view=rev
Log:
HADOOP-4847. Moves the loading of OutputCommitter to the Task. Contributed by Amareshwari
Sriramadasu.

Added:
    hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java
    hadoop/core/trunk/src/test/testjar/CustomOutputCommitter.java
Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/Task.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=732609&r1=732608&r2=732609&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Jan  7 21:20:28 2009
@@ -573,6 +573,9 @@
     HADOOP-4821. Usage description in the Quotas guide documentations are
     incorrect. (Boris Shkolnik via hairong)
 
+    HADOOP-4847. Moves the loading of OutputCommitter to the Task.
+    (Amareshwari Sriramadasu via ddas)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/Task.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/Task.java?rev=732609&r1=732608&r2=732609&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/Task.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/Task.java Wed Jan  7 21:20:28 2009
@@ -295,18 +295,6 @@
     conf.setBoolean("mapred.task.is.map", isMapTask());
     conf.setInt("mapred.task.partition", partition);
     conf.set("mapred.job.id", taskId.getJobID().toString());
-    Path outputPath = FileOutputFormat.getOutputPath(conf);
-    if (outputPath != null) {
-      OutputCommitter committer = conf.getOutputCommitter();
-      if ((committer instanceof FileOutputCommitter)) {
-        TaskAttemptContext context = new TaskAttemptContext(conf, taskId);
-        FileOutputFormat.setWorkOutputPath(conf, 
-          ((FileOutputCommitter)committer).getTempTaskOutputPath(context));
-      } else {
-        FileOutputFormat.setWorkOutputPath(conf, outputPath);
-      }
-    }
-
   }
   
   /** Run this task as a part of the named job.  This method is executed in the
@@ -352,6 +340,15 @@
     } else {
       committer = conf.getOutputCommitter();
     }
+    Path outputPath = FileOutputFormat.getOutputPath(conf);
+    if (outputPath != null) {
+      if ((committer instanceof FileOutputCommitter)) {
+        FileOutputFormat.setWorkOutputPath(conf, 
+          ((FileOutputCommitter)committer).getTempTaskOutputPath(taskContext));
+      } else {
+        FileOutputFormat.setWorkOutputPath(conf, outputPath);
+      }
+    }
     committer.setupTask(taskContext);
   }
   

Added: hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java?rev=732609&view=auto
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java (added)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/mapred/TestCustomOutputCommitter.java Wed
Jan  7 21:20:28 2009
@@ -0,0 +1,65 @@
+/* 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.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.*;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+
+public class TestCustomOutputCommitter extends TestCase {
+  static final Path input = new Path("/test/input/");
+  static final Path output = new Path("/test/output");
+  
+  public void testCommitter() throws Exception {
+    MiniDFSCluster dfs = null;
+    MiniMRCluster mr = null;
+    FileSystem fs = null;
+    Path testFile = new Path(input, "testfile");
+    try {
+      Configuration conf = new Configuration();
+
+      //start the mini mr and dfs cluster.
+      dfs = new MiniDFSCluster(conf, 2 , true, null);
+      fs = dfs.getFileSystem();
+      FSDataOutputStream stream = fs.create(testFile);
+      stream.write("teststring".getBytes());
+      stream.close();
+
+      mr = new MiniMRCluster(2, fs.getUri().toString(), 1);
+
+      String[] args = new String[6];
+      args[0] = "-libjars";
+      // the testjob.jar as a temporary jar file 
+      // holding custom output committer
+      args[1] = "build/test/testjar/testjob.jar";
+      args[2] = "-D";
+      args[3] = "mapred.output.committer.class=testjar.CustomOutputCommitter";
+      args[4] = input.toString();
+      args[5] = output.toString();
+      JobConf jobConf = mr.createJobConf();
+      int ret = ToolRunner.run(jobConf, new WordCount(), args);
+
+      assertTrue("not failed ", ret == 0);
+    } finally {
+      if (dfs != null) {dfs.shutdown();};
+      if (mr != null) {mr.shutdown();};
+    }
+  }
+}

Added: hadoop/core/trunk/src/test/testjar/CustomOutputCommitter.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/testjar/CustomOutputCommitter.java?rev=732609&view=auto
==============================================================================
--- hadoop/core/trunk/src/test/testjar/CustomOutputCommitter.java (added)
+++ hadoop/core/trunk/src/test/testjar/CustomOutputCommitter.java Wed Jan  7 21:20:28 2009
@@ -0,0 +1,25 @@
+/**
+ * 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 testjar;
+
+import org.apache.hadoop.mapred.FileOutputCommitter;
+
+public class CustomOutputCommitter extends FileOutputCommitter {
+  // custom output committer with default implementation
+}



Mime
View raw message