5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-08 06:51:35 +08:00

SQOOP-986: Sqoop2: Add detection of local mode to mapreduce submission engine

(Jarek Jarcec Cecho via Kate Ting)
This commit is contained in:
Kate Ting 2013-04-14 19:08:34 -04:00
parent 0a0a65a29f
commit 75ae6e3ea0

View File

@ -114,6 +114,10 @@ public boolean accept(File dir, String name) {
} catch (IOException e) {
throw new SqoopException(MapreduceSubmissionError.MAPREDUCE_0002, e);
}
if(isLocal()) {
LOG.info("Detected MapReduce local mode, some methods might not work correctly.");
}
}
/**
@ -249,7 +253,14 @@ public boolean submit(SubmissionRequest generalRequest) {
job.setOutputKeyClass(request.getOutputKeyClass());
job.setOutputValueClass(request.getOutputValueClass());
job.submit();
// If we're in local mode than wait on completion. Local job runner do not
// seems to be exposing API to get previously submitted job which makes
// other methods of the submission engine quite useless.
if(isLocal()) {
job.waitForCompletion(true);
} else {
job.submit();
}
String jobId = job.getJobID().toString();
request.getSummary().setExternalId(jobId);
@ -400,4 +411,13 @@ private Counters convertMapreduceCounters(org.apache.hadoop.mapred.Counters hado
return sqoopCounters;
}
/**
* Detect MapReduce local mode.
*
* @return True if we're running in local mode
*/
private boolean isLocal() {
return "local".equals(globalConfiguration.get("mapreduce.jobtracker.address"))
|| "local".equals(globalConfiguration.get("mapred.job.tracker"));
}
}