2

WordCount map/reduce ジョブのサンプル コードを実行しようとしています。Hadoop 1.2.1 で実行しています。Eclipseから実行しています。実行しようとするコードは次のとおりです。

package mypackage;

import java.io.IOException;
import java.util.StringTokenizer;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Reducer.Context;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;


public class WordCount {

    public static class Map extends
            Mapper<LongWritable, Text, Text, IntWritable> {
        private final static IntWritable one = new IntWritable(1);
        private Text word = new Text();

        public void map(LongWritable key, Text value, Context context)
                throws IOException, InterruptedException {
            String line = value.toString();
            StringTokenizer tokenizer = new StringTokenizer(line);
            while (tokenizer.hasMoreTokens()) {
                word.set(tokenizer.nextToken());
                context.write(word, one);
            }
        }
    }

    public static class Reduce extends
            Reducer<Text, IntWritable, Text, IntWritable> {

        public void reduce(Text key, Iterable<IntWritable> values,
                Context context) throws IOException, InterruptedException {
            int sum = 0;
            for (IntWritable val : values) {
                sum += val.get();
            }
            context.write(key, new IntWritable(sum));
        }
    }

    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.set("mapred.job.tracker", "maprfs://,y_address");
        conf.set("fs.default.name", "hdfs://my_address");

        Job job = new Job(conf, "wordcount");
        job.setJarByClass(WordCount.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        job.setMapperClass(Map.class);
    job.setReducerClass(Reduce.class);

        job.setInputFormatClass(TextInputFormat.class);
        job.setOutputFormatClass(TextOutputFormat.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        job.waitForCompletion(true);    
    }   
}

残念ながら、このコードを実行すると、次のエラーが発生します。

13/11/04 13:27:53 情報 mapred.JobClient: タスク ID: 試行_201310311611_0005_m_000000_0、ステータス: 失敗しましたorg.apache.hadoop.mapreduce.JobContext.getMapperClass(JobContext.java:199) の .conf.Configuration.getClass(Configuration.java:857) org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:718) の) org.apache.hadoop.mapred.MapTask.run(MapTask.java:364) で org.apache.hadoop.mapred.Child$4.run(Child.java:255) で java.security.AccessController.doPrivileged(Native Method) で javax.security.auth.Subject.doAs(Subject.java:415) で org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190) で org.apache.hadoop.mapred.Child.main (Child.java:249)

WordClass が見つからないことは理解していますが、これを機能させる方法がわかりません。何か案は?

4

1 に答える 1