public
void
initializeJob(String user, String jobid, Path credentials,
Path jobConf, TaskUmbilicalProtocol taskTracker,
InetSocketAddress ttAddr
)
throws
IOException {
List<String> command =
new
ArrayList<String>(
Arrays.asList(taskControllerExe ,
user,
localStorage.getDirsString(),
Integer. toString(Commands.INITIALIZE_JOB.getValue()),
jobid,
credentials.toUri().getPath().toString(),
jobConf.toUri().getPath().toString()));
File jvm =
new
File(
new
File(System.getProperty(
"java.home"
),
"bin"
),
"java"
);
command.add(jvm.toString());
command.add(
"-classpath"
);
command.add(System.getProperty(
"java.class.path"
));
command.add(
"-Dhadoop.log.dir="
+ TaskLog.getBaseLogDir());
command.add(
"-Dhadoop.root.logger=INFO,console"
);
command.add(JobLocalizer.
class
.getName());
command.add(user);
command.add(jobid);
command.add(ttAddr.getHostName());
command.add(Integer.toString(ttAddr.getPort()));
String[] commandArray = command.toArray(
new
String[
0
]);
ShellCommandExecutor shExec =
new
ShellCommandExecutor(commandArray);
if
(LOG.isDebugEnabled()) {
LOG.debug(
"initializeJob: "
+ Arrays.toString(commandArray));
}
try
{
shExec.execute();
if
(LOG.isDebugEnabled()) {
logOutput(shExec.getOutput());
}
}
catch
(ExitCodeException e) {
int
exitCode = shExec.getExitCode();
logOutput(shExec.getOutput());
throw
new
IOException(
"Job initialization failed ("
+ exitCode +
") with output: "
+ shExec.getOutput(), e);
}
}