My intent is that I want to debug something of hadoop. The command to run the hadoop program is :
bin/hadoop jar path/to/hadoop-mapreduce-examples-2.2.0.jar wordcount /wordcount /output
And this command will call the RunJar.java 's main() method . I could pass jvm parameter to RunJar.java 's main() method by add these in hadoop-env.sh :
HADOOP_OPTS="$HADOOP_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9000"
But the code inside RunJar.java 's main() is :
ClassLoader loader =
new URLClassLoader(classPath.toArray(new URL[0]));
Class<?> mainClass = Class.forName(mainClassName, true, loader);
Method main = mainClass.getMethod("main", new Class[] {
Array.newInstance(String.class, 0).getClass()
});
main.invoke(null, new Object[] { newArgs });
Can I pass some jvm parameter ( -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8999
) to this invoke method
main.invoke(null, new Object[] { newArgs });
So that I could debug the main method invoked by RunJar.java in remote way
No, the JVM is already started.
The only way is if you run your JAR by starting a new JVM using Runtime.getRuntime().exec()
or ProcessBuilder
and Process
classes.
This would probably do the trick, and you woudn't need to pass the arguments since you can actually call the script:
Runtime.getRuntime().exec(
"bin/hadoop jar path/to/hadoop-mapreduce-examples-2.2.0.jar " +
"wordcount /wordcount /output");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.