하둡에서 새롭다. 매퍼마다 전송할 데이터 세트를 나누기 위해 각 실행마다 2, 4, 6 노드를 사용하고 싶다. 하지만 필자가 작성한 코드는 제대로 작동하지 않습니다. 실제로 그것은 2 개의 노드에서 작동하지만 노드의 수가 증가하면 출력 파일에서 손실되는 일부 출력 데이터가 증가합니다. 도와 주시겠습니까?하둡 Java로 다중 노드 프로그래밍
이public static void main(String[] args) throws Exception {
System.out.println("MapReduce Started at:"+System.currentTimeMillis());
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
int numOfNodes = 2;
Job job = new Job(conf, "calculateSAAM");
job.setJarByClass(calculateSAAM.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(DoubleWritable.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path("/home/helsene/wordcount/input"));
String outputFile = "/home/helsene/wordcount/output/";
long dataLength = fs.getContentSummary(new Path(outputFile)).getLength();
FileInputFormat.setMaxInputSplitSize(job, (dataLength/numOfNodes));
job.setNumReduceTasks(numOfNodes/2);
Path outPath = new Path(outputFile);
fs.delete(outPath, true);
FileOutputFormat.setOutputPath(job, new Path(outputFile));
job.waitForCompletion(true);
System.out.println("MapReduce ends at:"+System.currentTimeMillis());
}
}
고맙습니다. 이것은 해결책이었습니다 – Suzi
@Maryam 제가 도와 줬기 때문에 기쁩니다! 다른 사람들이 해결책을 알기 위해서는 내 대답을 인정 된 것으로 표시 할 수 있습니다. – vefthym