DefaultMailCreator implements MailCreator { @Override public boolean createFirstErrorMessage(final ExecutableFlow flow, final EmailMessage message, final String azkabanName, final String scheme, final String clientHostname, final String clientPortNumber) { final ExecutionOptions option = flow.getExecutionOptions(); final List<String> emailList = option.getFailureEmails(); final int execId = flow.getExecutionId(); if (emailList != null && !emailList.isEmpty()) { message.addAllToAddress(emailList); message.setMimeType("text/html"); message.setSubject("Flow '" + flow.getFlowId() + "' has encountered a failure on " + azkabanName); message.println("<h2 style=\"color:#FF0000\"> Execution '" + flow.getExecutionId() + "' of flow '" + flow.getFlowId() + "' of project '" + flow.getProjectName() + "' has encountered a failure on " + azkabanName + "</h2>"); if (option.getFailureAction() == FailureAction.CANCEL_ALL) { message .println("This flow is set to cancel all currently running jobs."); } else if (option.getFailureAction() == FailureAction.FINISH_ALL_POSSIBLE) { message .println("This flow is set to complete all jobs that aren't blocked by the failure."); } else { message .println("This flow is set to complete all currently running jobs before stopping."); } message.println("<table>"); message.println("<tr><td>Start Time</td><td>" + TimeUtils.formatDateTimeZone(flow.getStartTime()) + "</td></tr>"); message.println("<tr><td>End Time</td><td>" + TimeUtils.formatDateTimeZone(flow.getEndTime()) + "</td></tr>"); message.println("<tr><td>Duration</td><td>" + TimeUtils.formatDuration(flow.getStartTime(), flow.getEndTime()) + "</td></tr>"); message.println("<tr><td>Status</td><td>" + flow.getStatus() + "</td></tr>"); message.println("</table>"); message.println(""); final String executionUrl = scheme + ": + "executor?" + "execid=" + execId; message.println("<a href=\"" + executionUrl + "\">" + flow.getFlowId() + " Execution Link</a>"); message.println(""); message.println("<h3>Reason</h3>"); final List<String> failedJobs = findFailedJobs(flow); message.println("<ul>"); for (final String jobId : failedJobs) { message.println("<li><a href=\"" + executionUrl + "&job=" + jobId + "\">Failed job '" + jobId + "' Link</a></li>"); } message.println("</ul>"); return true; } return false; }  static void registerCreator(final String name, final MailCreator creator); static MailCreator getCreator(final String name); @Override boolean createFirstErrorMessage(final ExecutableFlow flow,
      final EmailMessage message, final String azkabanName, final String scheme,
      final String clientHostname, final String clientPortNumber); @Override boolean createErrorEmail(final ExecutableFlow flow, final List<ExecutableFlow>
      pastExecutions, final EmailMessage message, final String azkabanName, final String scheme,
      final String clientHostname, final String clientPortNumber, final String... reasons); @Override boolean createSuccessEmail(final ExecutableFlow flow, final EmailMessage message,
      final String azkabanName, final String scheme, final String clientHostname,
      final String clientPortNumber); @Override boolean createFailedUpdateMessage(final List<ExecutableFlow> flows,
      final Executor executor, final ExecutorManagerException updateException,
      final EmailMessage message, final String azkabanName,
      final String scheme, final String clientHostname, final String clientPortNumber); @Override boolean createFailedExecutorHealthCheckMessage(final List<ExecutableFlow> flows,
      final Executor executor, final ExecutorManagerException failureException,
      final EmailMessage message, final String azkabanName,
      final String scheme, final String clientHostname, final String clientPortNumber,
      final List<String> emailList); static final String DEFAULT_MAIL_CREATOR; }
@Test public void createFirstErrorMessage() throws Exception { setJobStatus(Status.FAILED); this.executableFlow.setEndTime(END_TIME_MILLIS); this.executableFlow.setStatus(Status.FAILED_FINISHING); assertTrue(this.mailCreator.createFirstErrorMessage( this.executableFlow, this.message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber)); assertEquals("Flow 'mail-creator-test' has encountered a failure on unit-tests", this.message.getSubject()); assertThat(TestUtils.readResource("firstErrorMessage.html", this)) .isEqualToIgnoringWhitespace(this.message.getBody()); }