如何在 hadoop 源代码中调试本机函数?
How can i debug a native function in hadoop source code?
我试图通过使用 eclipse 调试来理解 hadoop 源代码。
在调试它时,我在这里遇到了一个名为 start0() 的本机函数:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Thread.java#Thread.start0%28%29
我可以使用 eclipse 调试它吗"or using any external tool" 或者至少我可以阅读这个函数的源代码吗?
Hadoop 是开源的,所以我应该可以访问和阅读其中所有功能的代码,但我不知道如何。
Note: my hadoop version : 1.2.1
编辑:
我阅读了本机函数,从我读到的内容来看,包含本机函数的 class 应该包含类似的内容:
`// load DLL that contains static method
static {
System.loadLibrary("NativeDemo");
}`
但是 hadoop 中的线程 class 包含这个:
/* Make sure registerNatives is the first thing <clinit> does. */
134 private static native void More ...registerNatives();
135 static {
136 registerNatives();
137 }
那么我如何知道 start0() 函数链接到的库的名称?
你总能得到源代码。示例配置文件,您的版本是 here
我终于明白 start0() 函数是 java 代码的一部分,而不是 hadoop 代码的一部分,所以它只是 do/create 运行 作业的新线程关于它和 hadoop 开发我们只需要知道:
Thread.start0 最终创建一个新的操作系统线程,并在该新线程中调用 Thread.run()。
创建新线程后调用的 运行 函数也在这里:
http://grepcode.com/file/repo1.maven.org/maven2/com.ning/metrics.collector/1.2.1/org/apache/hadoop/mapred/LocalJobRunner.java#LocalJobRunner.Job.run%28%29
我试图通过使用 eclipse 调试来理解 hadoop 源代码。
在调试它时,我在这里遇到了一个名为 start0() 的本机函数:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Thread.java#Thread.start0%28%29
我可以使用 eclipse 调试它吗"or using any external tool" 或者至少我可以阅读这个函数的源代码吗?
Hadoop 是开源的,所以我应该可以访问和阅读其中所有功能的代码,但我不知道如何。
Note: my hadoop version : 1.2.1
编辑: 我阅读了本机函数,从我读到的内容来看,包含本机函数的 class 应该包含类似的内容:
`// load DLL that contains static method
static {
System.loadLibrary("NativeDemo");
}`
但是 hadoop 中的线程 class 包含这个:
/* Make sure registerNatives is the first thing <clinit> does. */
134 private static native void More ...registerNatives();
135 static {
136 registerNatives();
137 }
那么我如何知道 start0() 函数链接到的库的名称?
你总能得到源代码。示例配置文件,您的版本是 here
我终于明白 start0() 函数是 java 代码的一部分,而不是 hadoop 代码的一部分,所以它只是 do/create 运行 作业的新线程关于它和 hadoop 开发我们只需要知道:
Thread.start0 最终创建一个新的操作系统线程,并在该新线程中调用 Thread.run()。
创建新线程后调用的 运行 函数也在这里:
http://grepcode.com/file/repo1.maven.org/maven2/com.ning/metrics.collector/1.2.1/org/apache/hadoop/mapred/LocalJobRunner.java#LocalJobRunner.Job.run%28%29