/** * This will call the stored procedure abandon_feed_jobs */ public void abandonFeedJobs(String feed) { String exitMessage = String.format("Job manually abandoned @ %s", DateTimeUtil.getNowFormattedWithTimeZone()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); repository.abandonFeedJobs(feed, exitMessage, username); //TODO Notify the JobExecution Cache of updates //all the alerts manager to handle all job failures AlertCriteria criteria = alertProvider.criteria().type(OperationalAlerts.JOB_FALURE_ALERT_TYPE).subtype(feed); Iterator<? extends Alert> alerts = alertProvider.getAlerts(criteria); StreamSupport.stream(Spliterators.spliteratorUnknownSize(alerts, Spliterator.ORDERED), false) .forEach(alert -> alertProvider.respondTo(alert.getId(), (alert1, response) -> response.handle(exitMessage))); alertManager.updateLastUpdatedTime(); }
@Override public BatchJobExecution abandonJob(Long executionId) { BatchJobExecution execution = findByJobExecutionId(executionId,false); if (execution != null && !execution.getStatus().equals(BatchJobExecution.JobStatus.ABANDONED)) { if (execution.getStartTime() == null) { execution.setStartTime(DateTimeUtil.getNowUTCTime()); } execution.setStatus(BatchJobExecution.JobStatus.ABANDONED); if (execution.getEndTime() == null) { execution.setEndTime(DateTimeUtil.getNowUTCTime()); } String abandonMessage = "Job manually abandoned @ " + DateTimeUtil.getNowFormattedWithTimeZone(); String msg = execution.getExitMessage() != null ? execution.getExitMessage() + "\n" : ""; msg += abandonMessage; execution.setExitMessage(msg); //also stop any running steps?? //find the feed associated with the job OpsManagerFeed feed = execution.getJobInstance().getFeed(); save(execution); jobExecutionChangedNotifier.notifyAbandoned(execution, feed, null); //clear the associated alert String alertId = execution.getJobExecutionContextAsMap().get(BatchJobExecutionProvider.KYLO_ALERT_ID_PROPERTY); if (StringUtils.isNotBlank(alertId)) { provider.respondTo(provider.resolve(alertId), (alert1, response) -> response.handle(abandonMessage)); } } return execution; }