Java Code Examples for org.springframework.cloud.task.repository.TaskExecution#getErrorMessage()

The following examples show how to use org.springframework.cloud.task.repository.TaskExecution#getErrorMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskExecutionResource.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor to initialize the TaskExecutionResource using a
 * {@link TaskExecution} and {@link TaskManifest}.
 *
 * @param taskExecution contains the {@link TaskExecution}
 * @param taskManifest contains the (@link TaskManifest}
 */
public TaskExecutionResource(TaskExecution taskExecution, TaskManifest taskManifest) {
	Assert.notNull(taskExecution, "taskExecution must not be null");
	Assert.notNull(taskManifest, "taskManifest must not be null");
	this.executionId = taskExecution.getExecutionId();
	this.exitCode = taskExecution.getExitCode();
	this.taskName = taskExecution.getTaskName();
	this.exitMessage = taskExecution.getExitMessage();
	this.arguments = Collections.unmodifiableList(taskExecution.getArguments());
	this.startTime = taskExecution.getStartTime();
	this.endTime = taskExecution.getEndTime();
	this.errorMessage = taskExecution.getErrorMessage();
	this.externalExecutionId = taskExecution.getExternalExecutionId();
	this.resourceUrl = taskManifest.getTaskDeploymentRequest().getResource().toString();
	this.appProperties = taskManifest.getTaskDeploymentRequest().getDefinition().getProperties();
	this.deploymentProperties = taskManifest.getTaskDeploymentRequest().getDeploymentProperties();
}
 
Example 2
Source File: TaskExecutionResource.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor to initialize the TaskExecutionResource using a
 * {@link TaskExecution}.
 *
 * @param taskExecution contains the {@link TaskExecution}
 */
public TaskExecutionResource(TaskExecution taskExecution) {
	Assert.notNull(taskExecution, "taskExecution must not be null");
	this.executionId = taskExecution.getExecutionId();
	this.exitCode = taskExecution.getExitCode();
	this.taskName = taskExecution.getTaskName();
	this.exitMessage = taskExecution.getExitMessage();
	this.arguments = Collections.unmodifiableList(taskExecution.getArguments());
	this.startTime = taskExecution.getStartTime();
	this.endTime = taskExecution.getEndTime();
	this.errorMessage = taskExecution.getErrorMessage();
	this.externalExecutionId = taskExecution.getExternalExecutionId();
}
 
Example 3
Source File: TaskLifecycleListener.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private TaskExecution invokeOnTaskError(TaskExecution taskExecution,
		Throwable throwable) {
	this.taskMetrics.onTaskFailed(throwable);
	TaskExecution listenerTaskExecution = getTaskExecutionCopy(taskExecution);
	if (this.taskExecutionListeners != null) {
		try {
			for (TaskExecutionListener taskExecutionListener : this.taskExecutionListeners) {
				taskExecutionListener.onTaskFailed(listenerTaskExecution, throwable);
			}
		}
		catch (Throwable listenerException) {
			this.listenerFailed = true;
			String errorMessage;
			if (StringUtils.hasText(listenerTaskExecution.getErrorMessage())) {
				errorMessage = String.format("%s :While handling " + "this error: %s",
						listenerException.getMessage(),
						listenerTaskExecution.getErrorMessage());
			}
			else {
				errorMessage = listenerTaskExecution.getErrorMessage();
			}
			logger.error(errorMessage);
			listenerTaskExecution.setErrorMessage(errorMessage);
			listenerTaskExecution.setExitCode(1);
		}

	}
	return listenerTaskExecution;
}
 
Example 4
Source File: TaskLifecycleListener.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
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());
}