private void setExitMessage(TaskExecution taskExecutionParam) { if(taskExecutionParam.getExitMessage() != null) { this.taskExecution.setExitMessage(taskExecutionParam.getExitMessage()); } }
protected void updateExternalExecutionId(long executionId, String taskLaunchId) { this.taskRepository.updateExternalExecutionId(executionId, taskLaunchId); }
@Override public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments, String externalExecutionid, Long parentExecutionId) { TaskExecution taskExecution= taskExecutions.get(executionId); taskExecution.setTaskName(taskName); taskExecution.setStartTime(startTime); taskExecution.setArguments(arguments); taskExecution.setParentExecutionId(parentExecutionId); if(externalExecutionid != null) { taskExecution.setExternalExecutionId(externalExecutionid); } return taskExecution; }
private TaskExecution getTaskExecutionCopy(TaskExecution taskExecution){ Date startTime = new Date(taskExecution.getStartTime().getTime()); Date endTime = (taskExecution.getEndTime() == null) ? null : new Date(taskExecution.getEndTime().getTime()); return new TaskExecution(taskExecution.getExecutionId(), taskExecution.getExitCode(), taskExecution.getTaskName(), startTime, endTime,taskExecution.getExitMessage(), Collections.unmodifiableList(taskExecution.getArguments()), taskExecution.getErrorMessage(), taskExecution.getExternalExecutionId()); }
private boolean isTaskDefined(JobExecution jobExecution) { TaskExecution taskExecution = taskExplorer .getTaskExecution(taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecution.getId())); TaskDefinition definition = taskDefinitionRepository.findOne(taskExecution.getTaskName()); return (definition != null); } }
@Override public int compare(TaskExecution e1, TaskExecution e2) { int result = e1.getStartTime().compareTo(e2.getStartTime()); if (result == 0){ result = Long.valueOf(e1.getExecutionId()).compareTo(e2.getExecutionId()); } return result; } });
@Override public void cleanupExecution(long id) { TaskExecution taskExecution = taskExplorer.getTaskExecution(id); Assert.notNull(taskExecution, "There was no task execution with id " + id); String launchId = taskExecution.getExternalExecutionId(); Assert.hasLength(launchId, "The TaskExecution for id " + id + " did not have an externalExecutionId"); taskLauncher.cleanup(launchId); }
private String resolveApplicationName() { if(StringUtils.hasText(this.applicationName)) { return this.applicationName; } else { return this.taskExecution.getTaskName(); } }
@Override public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage, String errorMessage) { if(!this.taskExecutions.containsKey(executionId)) { throw new IllegalStateException("Invalid TaskExecution, ID " + executionId + " not found."); } TaskExecution taskExecution= taskExecutions.get(executionId); taskExecution.setEndTime(endTime); taskExecution.setExitCode(exitCode); taskExecution.setExitMessage(exitMessage); taskExecution.setErrorMessage(errorMessage); }
@Override public List<String> getCommandLineArgs(ExecutionContext executionContext) { int listSize = this.taskExecution.getArguments().size() + (this.appendedArgs != null ? this.appendedArgs.size() : 0); List<String> args = new ArrayList<>(listSize); args.addAll(this.taskExecution.getArguments()); if(this.appendedArgs != null) { args.addAll(this.appendedArgs); } return args; } }
@Override public long getRunningTaskExecutionCount() { long count = 0; for (Map.Entry<Long, TaskExecution> entry : taskExecutions.entrySet()) { if ( entry.getValue().getEndTime() == null) { count++; } } return count; }
@Override public TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments, String externalExecutionId, Long parentExecutionId) { long taskExecutionId = getNextExecutionId(); TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName, startTime, null, null, arguments, null, externalExecutionId, parentExecutionId); taskExecutions.put(taskExecutionId, taskExecution); return taskExecution; }
@Override public synchronized boolean maxConcurrentExecutionsReached() { return this.taskExplorer.getRunningTaskExecutionCount() >= taskConfigurationProperties .getMaximumConcurrentTasks(); }
private boolean isTaskDefined(JobExecution jobExecution) { TaskExecution taskExecution = taskExplorer .getTaskExecution(taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecution.getId())); return taskDefinitionRepository.findById(taskExecution.getTaskName()).isPresent(); } }
@Override public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments, String externalExecutionid, Long parentExecutionId) { TaskExecution taskExecution= taskExecutions.get(executionId); taskExecution.setTaskName(taskName); taskExecution.setStartTime(startTime); taskExecution.setArguments(arguments); taskExecution.setParentExecutionId(parentExecutionId); if(externalExecutionid != null) { taskExecution.setExternalExecutionId(externalExecutionid); } return taskExecution; }
@Override public int compare(TaskExecution e1, TaskExecution e2) { int result = e1.getStartTime().compareTo(e2.getStartTime()); if (result == 0){ result = Long.valueOf(e1.getExecutionId()).compareTo(e2.getExecutionId()); } return result; } });
private void setExitMessage(TaskExecution taskExecutionParam) { if(taskExecutionParam.getExitMessage() != null) { this.taskExecution.setExitMessage(taskExecutionParam.getExitMessage()); } }
private String resolveApplicationName() { if(StringUtils.hasText(this.applicationName)) { return this.applicationName; } else { return this.taskExecution.getTaskName(); } }
@Override public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage, String errorMessage) { if(!this.taskExecutions.containsKey(executionId)) { throw new IllegalStateException("Invalid TaskExecution, ID " + executionId + " not found."); } TaskExecution taskExecution= taskExecutions.get(executionId); taskExecution.setEndTime(endTime); taskExecution.setExitCode(exitCode); taskExecution.setExitMessage(exitMessage); taskExecution.setErrorMessage(errorMessage); }
private synchronized boolean maxConcurrentExecutionsReached() { return this.taskExplorer.getRunningTaskExecutionCount() >= this.taskConfigurationProperties .getMaximumConcurrentTasks(); }