2016-06-07 59 views
0

我编译了mapreduce代码(驱动程序,mapper和reducer类)并创建了Jar文件。当我在数据集上运行它时,似乎没有运行。它只是回到如图所示的提示。任何建议人?运行mapreduce作业根本没有输出。它甚至没有运行。很奇怪。在终端上没有错误

感谢很多 basam

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.io.Text; 

import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat; 
import org.apache.hadoop.mapreduce.Job; 
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; 
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; 

//This driver program will bring all the information needed to submit this Map reduce job. 

public class MultiLangDictionary { 

public static void main(String[] args) throws Exception{ 

    if (args.length !=2){ 

     System.err.println("Usage: MultiLangDictionary <input path> <output path>"); 

     System.exit(-1);    

    } 



    Configuration conf = new Configuration(); 



    Job ajob = new Job(conf, "MultiLangDictionary"); 

    //Assigning the driver class name 
    ajob.setJarByClass(MultiLangDictionary.class); 


    FileInputFormat.addInputPath(ajob, new Path(args[0])); 

    //first argument is the job itself 
    //second argument is the location of the output dataset 
    FileOutputFormat.setOutputPath(ajob, new Path(args[1])); 


    ajob.setInputFormatClass(TextInputFormat.class); 



    ajob.setOutputFormatClass(TextOutputFormat.class); 


    //Defining the mapper class name 
    ajob.setMapperClass(MultiLangDictionaryMapper.class); 

    //Defining the Reducer class name 
    ajob.setReducerClass(MultiLangDictionaryReducer.class); 

    //setting the second argument as a path in a path variable 
    Path outputPath = new Path(args[1]); 

    //deleting the output path automatically from hdfs so that we don't have delete it explicitly 
    outputPath.getFileSystem(conf).delete(outputPath); 



} 

} 
+0

你提交这份工作吗?在上面的代码中没有作业提交。 – PetrosP

+0

Petros,作业提交声明位于本帖子中的图片文件中 –

+0

hadoop正在运行,请尝试运行'hadoop fs -ls /'或'jps'。它给了什么? – syadav

回答

0

尝试用java packagename.classname在命令

hadoop jar MultiLangDictionary.jar [yourpackagename].MultiLangDictionary input output 
+0

Ashok,我一直在运行hadoop jar文件,我也运行这个程序。他们都是成功的。我不明白为什么这个失败。 Jar文件名或输入文件名长度或驱动程序名称长度是否有任何大小限制?只是想大声 –

+0

我不认为这个工作是与文件名长度问题失败。你能否在webui中检查作业日志,以便你能够找出可能的错误。 – Ashok

+0

Ashok,如果工作没有运行,我该如何检查工作日志? –

0

你可以尝试添加Map和Reduce输出密钥类型到驱动程序。喜欢的东西(这是一个例子):

job2.setMapOutputKeyClass(Text.class); 
job2.setMapOutputValueClass(Text.class); 
job2.setOutputKeyClass(Text.class); 
job2.setOutputValueClass(Text.class); 

在上述的映射器和减速都将被写入在其context.write()方法(Text,Text)

+0

我会试试。非常感谢。我会尽快完成代码的发布。但我不能标记为有用。 stackflow不会让我这样做。 –

+0

我添加了两行,但没有帮助。 ://输出类型 ajob.setMapOutputKeyClass(Text.class); ajob.setMapOutputValueClass(Text.class); –