} catch (InvalidProtocolBufferException e1) {
}
SocketLog.info("receive master to worker manual request,rid="
+ req.getRid() + ",historyId=" + mm.getHistoryId());
final String historyId = mm.getHistoryId();
final JobHistory history = context.getJobHistoryManager()
.findJobHistory(historyId);
Future<Response> f = context.getThreadPool().submit(
new Callable<Response>() {
public Response call() throws Exception {
history.setExecuteHost(WorkerContext.host);
history.setStartTime(new Date());
context.getJobHistoryManager()
.updateJobHistory(history);
String date = new SimpleDateFormat("yyyy-MM-dd")
.format(new Date());
File direcotry = new File(Environment.getDownloadPath()
+ File.separator + date + File.separator
+ "manual-" + history.getId());
if (!direcotry.exists()) {
direcotry.mkdirs();
}
JobBean jb = context.getGroupManager()
.getUpstreamJobBean(history.getJobId());
final Job job = JobUtils.createJob(new JobContext(JobContext.MANUAL_RUN),
jb, history, direcotry.getAbsolutePath(),
context.getApplicationContext());
context.getManualRunnings().put(historyId, job);
Integer exitCode = -1;
Exception exception = null;
try {
exitCode = job.run();
} catch (Exception e) {
exception = e;
history.getLog().appendZeusException(e);
} finally {
JobHistory jobHistory = context
.getJobHistoryManager()
.findJobHistory(history.getId());
jobHistory.setEndTime(new Date());
if (exitCode == 0) {
jobHistory
.setStatus(com.taobao.zeus.model.JobStatus.Status.SUCCESS);
} else {
jobHistory
.setStatus(com.taobao.zeus.model.JobStatus.Status.FAILED);
}
context.getJobHistoryManager().updateJobHistory(
jobHistory);
history.getLog().appendZeus("exitCode=" + exitCode);