hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r790839 - in /hadoop/mapreduce/trunk: ./ src/java/org/apache/hadoop/mapred/lib/ src/java/org/apache/hadoop/mapreduce/lib/map/ src/test/mapred/org/apache/hadoop/mapreduce/lib/map/
Date Fri, 03 Jul 2009 09:52:59 GMT
Author: sharad
Date: Fri Jul  3 09:52:58 2009
New Revision: 790839

URL: http://svn.apache.org/viewvc?rev=790839&view=rev
Log:
MAPREDUCE-465. Deprecate o.a.h.mapred.lib.MultithreadedMapRunner and add test for o.a.h.mapreduce.lib.MultithreadedMapper.
Contributed by Amareshwari Sriramadasu.

Added:
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/
    hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/TestMultithreadedMapper.java
Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/lib/MultithreadedMapRunner.java
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/map/MultithreadedMapper.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=790839&r1=790838&r2=790839&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Fri Jul  3 09:52:58 2009
@@ -61,6 +61,10 @@
     MAPREDUCE-625. Modify TestTaskLimits to improve execution time.
     (Jothi Padmanabhan via sharad)
 
+    MAPREDUCE-465. Deprecate o.a.h.mapred.lib.MultithreadedMapRunner and add
+    test for o.a.h.mapreduce.lib.MultithreadedMapper.
+    (Amareshwari Sriramadasu via sharad)
+
   BUG FIXES
     HADOOP-4687. MapReduce is split from Hadoop Core. It is a subproject under 
     Hadoop (Owen O'Malley)

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/lib/MultithreadedMapRunner.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/lib/MultithreadedMapRunner.java?rev=790839&r1=790838&r2=790839&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/lib/MultithreadedMapRunner.java
(original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/lib/MultithreadedMapRunner.java
Fri Jul  3 09:52:58 2009
@@ -26,6 +26,7 @@
 import org.apache.hadoop.mapred.OutputCollector;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hadoop.mapred.SkipBadRecords;
+import org.apache.hadoop.mapreduce.lib.map.MultithreadedMapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -47,7 +48,9 @@
  * <code>mapred.map.multithreadedrunner.threads</code> property, its default
  * value is 10 threads.
  * <p>
+ * @deprecated Use {@link MultithreadedMapper} instead.
  */
+@Deprecated
 public class MultithreadedMapRunner<K1, V1, K2, V2>
     implements MapRunnable<K1, V1, K2, V2> {
 

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/map/MultithreadedMapper.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/map/MultithreadedMapper.java?rev=790839&r1=790838&r2=790839&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/map/MultithreadedMapper.java
(original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/lib/map/MultithreadedMapper.java
Fri Jul  3 09:52:58 2009
@@ -56,7 +56,7 @@
   extends Mapper<K1, V1, K2, V2> {
 
   private static final Log LOG = LogFactory.getLog(MultithreadedMapper.class);
-  private Class<Mapper<K1,V1,K2,V2>> mapClass;
+  private Class<? extends Mapper<K1,V1,K2,V2>> mapClass;
   private Context outer;
   private List<MapRunner> runners;
 
@@ -108,7 +108,7 @@
    */
   public static <K1,V1,K2,V2> 
   void setMapperClass(Job job, 
-                      Class<Mapper<K1,V1,K2,V2>> cls) {
+                      Class<? extends Mapper<K1,V1,K2,V2>> cls) {
     if (MultithreadedMapper.class.isAssignableFrom(cls)) {
       throw new IllegalArgumentException("Can't have recursive " + 
                                          "MultithreadedMapper instances.");
@@ -134,7 +134,7 @@
     for(int i=0; i < numberOfThreads; ++i) {
       MapRunner thread = new MapRunner(context);
       thread.start();
-      runners.set(i, thread);
+      runners.add(i, thread);
     }
     for(int i=0; i < numberOfThreads; ++i) {
       MapRunner thread = runners.get(i);

Added: hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/TestMultithreadedMapper.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/TestMultithreadedMapper.java?rev=790839&view=auto
==============================================================================
--- hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/TestMultithreadedMapper.java
(added)
+++ hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapreduce/lib/map/TestMultithreadedMapper.java
Fri Jul  3 09:52:58 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.mapreduce.lib.map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.HadoopTestCase;
+import org.apache.hadoop.mapreduce.*;
+
+import java.io.IOException;
+
+public class TestMultithreadedMapper extends HadoopTestCase {
+
+  public TestMultithreadedMapper() throws IOException {
+    super(HadoopTestCase.LOCAL_MR, HadoopTestCase.LOCAL_FS, 1, 1);
+  }
+
+  public void testOKRun() throws Exception {
+    run(false, false);
+  }
+
+  public void testIOExRun() throws Exception {
+    run(true, false);
+  }
+  public void testRuntimeExRun() throws Exception {
+    run(false, true);
+  }
+
+  private void run(boolean ioEx, boolean rtEx) throws Exception {
+    String localPathRoot = System.getProperty("test.build.data", "/tmp");
+    Path inDir = new Path(localPathRoot, "testing/mt/input");
+    Path outDir = new Path(localPathRoot, "testing/mt/output");
+
+
+    Configuration conf = createJobConf();
+    if (ioEx) {
+      conf.setBoolean("multithreaded.ioException", true);
+    }
+    if (rtEx) {
+      conf.setBoolean("multithreaded.runtimeException", true);
+    }
+
+    Job job = MapReduceTestUtil.createJob(conf, inDir, outDir, 1, 1);
+    job.setJobName("mt");
+
+    job.setMapperClass(MultithreadedMapper.class);
+    MultithreadedMapper.setMapperClass(job, IDMap.class);
+    MultithreadedMapper.setNumberOfThreads(job, 2);
+    job.setReducerClass(Reducer.class);
+
+    job.waitForCompletion(true);
+
+    if (job.isSuccessful()) {
+      assertFalse(ioEx || rtEx);
+    }
+    else {
+      assertTrue(ioEx || rtEx);
+    }
+  }
+
+  public static class IDMap extends 
+      Mapper<LongWritable, Text, LongWritable, Text> {
+    private boolean ioEx = false;
+    private boolean rtEx = false;
+
+    public void setup(Context context) {
+      ioEx = context.getConfiguration().
+               getBoolean("multithreaded.ioException", false);
+      rtEx = context.getConfiguration().
+               getBoolean("multithreaded.runtimeException", false);
+    }
+
+    public void map(LongWritable key, Text value, Context context)
+        throws IOException, InterruptedException {
+      if (ioEx) {
+        throw new IOException();
+      }
+      if (rtEx) {
+        throw new RuntimeException();
+      }
+      super.map(key, value, context);
+    }
+  }
+}



Mime
View raw message