Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
map reduce程序在“线程”中显示错误异常;“主要”;java.io.IOException:作业失败_Java_Apache_Hadoop_Mapreduce - Fatal编程技术网

map reduce程序在“线程”中显示错误异常;“主要”;java.io.IOException:作业失败

map reduce程序在“线程”中显示错误异常;“主要”;java.io.IOException:作业失败,java,apache,hadoop,mapreduce,Java,Apache,Hadoop,Mapreduce,我正在试着运行我的地图还原程序。在我尝试运行它之后,输出如下。 (我仅显示输出的最后一部分) 我不知道错误发生在哪里 有什么帮助吗 我的主要方法内容: public static void main(String[] args) throws Exception { JobConf conf = new JobConf(mapreduceprog.class); conf.setJobName("mapreduceprog"); conf.setOutputKey

我正在试着运行我的地图还原程序。在我尝试运行它之后,输出如下。 (我仅显示输出的最后一部分)

我不知道错误发生在哪里 有什么帮助吗

我的主要方法内容:

public static void main(String[] args) throws Exception {
     JobConf conf = new JobConf(mapreduceprog.class);
     conf.setJobName("mapreduceprog");

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

         conf.setMapOutputKeyClass(Text.class);
         conf.setMapOutputValueClass(Text.class);

     conf.setMapperClass(Map.class);
     conf.setCombinerClass(Reduce.class);
     conf.setReducerClass(Reduce.class);

     conf.setInputFormat(TextInputFormat.class);
     conf.setOutputFormat(TextOutputFormat.class);

     FileInputFormat.setInputPaths(conf, new Path(args[0]));
     FileOutputFormat.setOutputPath(conf, new Path(args[1]));

     JobClient.runJob(conf);
我的68号线是

JobClient.runJob(conf);

您正在使用较旧的Api。我建议您使用更新的Api。代码应该是这样的

import java.io.File;
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;



public class MyDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        if(args.length!=2){
            System.out.println("Error");

            System.exit(-1);
        }
        Job job=new Job();
        job.setJarByClass(MyDriver.class);
        job.setMapperClass(Map.class);
        job.setReducerClass(Reduce.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(Text.class); /*Reducer Output Key and value class*/
        job.setOutputValueClass(NullWritable.class);
        job.setInputFormatClass(CustomInputFormat.class);
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[2]));
        boolean success=job.waitForCompletion(true);
        System.exit(success?0:-1);
    }

}

您正在使用较旧的mapreduce api
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;



public class MyDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        if(args.length!=2){
            System.out.println("Error");

            System.exit(-1);
        }
        Job job=new Job();
        job.setJarByClass(MyDriver.class);
        job.setMapperClass(Map.class);
        job.setReducerClass(Reduce.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setOutputKeyClass(Text.class); /*Reducer Output Key and value class*/
        job.setOutputValueClass(NullWritable.class);
        job.setInputFormatClass(CustomInputFormat.class);
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[2]));
        boolean success=job.waitForCompletion(true);
        System.exit(success?0:-1);
    }

}