MAPREDUCE-5156. Change hadoop examples ProgramDriver to be able to run 1.x examples jar on top of YARN. This change breaks 0.23.x direct usages of ProgramDriver. Contributed by Zhijie Shen.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1485085 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-05-22 06:36:24 +00:00
parent 4a4e42d919
commit 27e6673ec3
7 changed files with 24 additions and 6 deletions

View File

@ -100,6 +100,11 @@
<Method name="run" />
<Bug pattern="DM_EXIT" />
</Match>
<Match>
<Class name="org.apache.hadoop.util.ProgramDriver" />
<Method name="driver" />
<Bug pattern="DM_EXIT" />
</Match>
<!--
We need to cast objects between old and new api objects
-->

View File

@ -117,7 +117,7 @@ public void addClass (String name, Class mainClass, String description) throws T
* @throws IllegalArgumentException
* @throws Throwable Anything thrown by the example program's main
*/
public int driver(String[] args)
public int run(String[] args)
throws Throwable
{
// Make sure they gave us a program name.
@ -144,5 +144,14 @@ public int driver(String[] args)
pgm.invoke(new_args);
return 0;
}
/**
* API compatible with Hadoop 1.x
*/
public void driver(String[] argv) throws Throwable {
if (run(argv) == -1) {
System.exit(-1);
}
}
}

View File

@ -52,7 +52,7 @@ public CoreTestDriver(ProgramDriver pgd) {
public void run(String argv[]) {
int exitCode = -1;
try {
exitCode = pgd.driver(argv);
exitCode = pgd.run(argv);
} catch(Throwable e) {
e.printStackTrace();
}

View File

@ -47,7 +47,7 @@ public HdfsTestDriver(ProgramDriver pgd) {
public void run(String argv[]) {
int exitCode = -1;
try {
exitCode = pgd.driver(argv);
exitCode = pgd.run(argv);
} catch(Throwable e) {
e.printStackTrace();
}

View File

@ -179,6 +179,10 @@ Release 2.0.5-beta - UNRELEASED
compatibility with mapred in 1.x but incompatible with 0.23.x. (Mayank Bansal
via vinodkv)
MAPREDUCE-5156. Change hadoop examples ProgramDriver to be able to run
1.x examples jar on top of YARN. This change breaks 0.23.x direct usages of
ProgramDriver. (Zhijie Shen via vinodkv)
NEW FEATURES
IMPROVEMENTS

View File

@ -112,7 +112,7 @@ public MapredTestDriver(ProgramDriver pgd) {
public void run(String argv[]) {
int exitCode = -1;
try {
exitCode = pgd.driver(argv);
exitCode = pgd.run(argv);
} catch(Throwable e) {
e.printStackTrace();
}

View File

@ -71,7 +71,7 @@ public static void main(String argv[]){
pgd.addClass("teragen", TeraGen.class, "Generate data for the terasort");
pgd.addClass("terasort", TeraSort.class, "Run the terasort");
pgd.addClass("teravalidate", TeraValidate.class, "Checking results of terasort");
exitCode = pgd.driver(argv);
exitCode = pgd.run(argv);
}
catch(Throwable e){
e.printStackTrace();