haoop 错误记录
来源:互联网 发布:python nonzero 编辑:程序博客网 时间:2024/05/24 03:21
源代码:
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
//import org.apache.hadoop.mapred.JobConf;
public class WordCount{
public static class Map extends MapReduceBase implements 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,OutputCollector<Text,IntWritable> output,Reporter reporter) throws IOException{
String line=value.toString();
StringTokenizer tokenizer=new StringTokenizer(line);
while(tokenizer.hasMoreTokens()){
word.set(tokenizer.nextToken());
output.collect(word, one);
}
}
}
public static class Reduce extends MapReduceBase implements Reducer<Text,IntWritable,Text,IntWritable>{
public void reduce (Text key,Iterator<IntWritable> values,OutputCollector<Text,IntWritable> output,Reporter reporter) throws IOException{
try{
int sum=0;
while(values.hasNext()){
sum+=values.next().get();
}
output.collect(key, new IntWritable(sum));
}
catch(IOException e){
System.out.println("nkenxknxknecxkn");
}
}
}
public static void main(String[] args) throws Exception {
JobConf conf=new JobConf();
conf.setJobName("WordCount");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(Map.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);
}
}
eclipse 错误显示:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:143)at WordCount.main(WordCount.java:45)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
- haoop 错误记录
- haoop问题解决
- Windows下 haoop下运行程序时出现错误:Hadoop HDFS Wrong FS: hdfs:/ expected file:///
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 错误记录
- 【错误记录】
- MFC类成员函数作为线程函数的解决办法
- yum帮助信息
- NSThread 和 NSTimer
- ubuntu12增加环境变量
- android安全:flag FLAG_RECEIVER_REGISTERED_ONLY的意义
- haoop 错误记录
- Unity3D教程:实现基于Socket通讯的公共聊天室
- 随机 取题
- Non-negative Matrix Factorization and Probabilistic Latent Semantic Analysis
- oracle分配权限
- 由setlocale解决中文显示引发的探索
- VS2005 :Fatal Error C1902:程序数据库管理器不匹配,解决办法
- 如何使用Axure RP Widget Library?
- VB备忘录(21)ADO实例