须要进一步学习hadoop、须要看看内部源代码实现。因此须要将hadoop源代码导入都eclipse中,简单总结一下,详细过程例如以下:
首先确保已经安装了git、maven3、protobuf2.5、假设没有安装须要提前安装一下
1、下载hadoop源代码
git clone git://git.apache.org/hadoop-common.git
2、进入hadoop-common文件夹,用maven生成eclipseproject
mvn install -DskipTests
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
3、导入Eclipse
导入Hadoop-Common
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-common-project文件夹为跟文件夹导入
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-assemblies文件夹为跟文件夹导入
导入HDFS
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-hdfs-project文件夹为跟文件夹导入
导入MapReduce
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-mapreduce-project文件夹为跟文件夹导入
导入YARN
File->import...->Choose "Existing Projects into Workspace" 选择hadoop-yarn-project文件夹为跟文件夹导入
OK、所有导入成功,可是须要注意两个地方:
首先假设想hadoop-common所有编译成功。须要将hadoop-common的target/generate-test-source/java文件夹设置source folder
其次还得把JDK lib文件夹的tools.jar加入到classpath中。
配置好上面之后,全部代码都清晰可见