2016-06-07 30 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); –