public void submitJob(final CallableJob cj) { dao.createJobRun(cj); final Future<Void> future = executor.submit(cj); reporter.mark("chronos.agentconsumer.submitted"); }
protected void end() { String jobName = plannedJob.getJobSpec().getName(); finish.set(System.currentTimeMillis()); reporting.histogram("chronos.query." + jobName + "." + "querytime", finish.get() - start.get()); dao.updateJobRun(this); final Long jobId = plannedJob.getJobSpec().getId(); List<JobSpec> children = dao.getChildren(jobId); for (JobSpec aChild : children) { dao.addToQueue(new PlannedJob(aChild, plannedJob.getReplaceTime())); } }
public void begin() { String jobName = plannedJob.getJobSpec().getName(); reporting.mark("chronos.query." + jobName + "." + "launched"); start.set(System.currentTimeMillis()); dao.updateJobRun(this); }
protected void handleException(Exception ex) { String jobName = plannedJob.getJobSpec().getName(); LOG.error(ex); setExceptionMessage(ex.getMessage()); JobSpec spec = plannedJob.getJobSpec(); if (spec.getStatusEmail() != null && spec.getStatusEmail().size() > 0 && !spec.getStatusEmail().get(0).equals("")) { for (String statusEmail : spec.getStatusEmail()) { MailInfo errMailInfo = new MailInfo(mailInfo.from, mailInfo.fromName, statusEmail, String.format("%s creator", jobName)); AgentConsumer.sendErrorReport(spec, replacedCode, ex, jobId, hostname, errMailInfo, session, attemptNumber); } } else { AgentConsumer.sendErrorReport(spec, replacedCode, ex, jobId, hostname, mailInfo, session, attemptNumber); } reporting.mark("chronos.query." + jobName + "." + "failed"); setStatus(1); }
@Override protected void callInternal() throws BackendException { JobSpec currJob = plannedJob.getJobSpec(); String jobName = currJob.getName(); try (Connection conn = getConnectionForJobSpec(currJob)) { int step = 0; try (Statement statement = conn.createStatement()) { while (step < parts.length) { doStep(currJob, parts[step], statement); step++; } } catch (SQLException ex) { throw new BackendException(ex); } if (replacedReportQuery != null && !replacedReportQuery.isEmpty()) { PersistentResultSet results = doReportStep(conn, replacedReportQuery); String content = createMessageContent (results, currJob, this.getReplacedReportQuery()); DataSource attachment = createAttachment(results); if (reportRootPath != null) { writeReportToLocal(results, reportRootPath, plannedJob); } sendEmail(mailInfo, attachment, content, currJob); } } catch (Exception ex) { throw new RuntimeException(ex); } reporting.mark("chronos.query." + jobName + "." + "passed"); setStatus(0); }
@Override protected void callInternal() throws BackendException { String jobName = plannedJob.getJobSpec().getName(); String aCommand = replacedCode; try { int exitCode = runner.exec(aCommand); if (exitCode == BashRunner.SUCCESS) { reporting.mark("chronos.query." + jobName + "." + "passed"); setStatus(0); } else { String error = runner.getError(); String aMessage = genErrorMessage(plannedJob.getJobSpec(), error); handleException(new Exception(aMessage)); } } catch (BackendException ex) { handleException(ex); } finally { runner.clean(); } }