Set Spring Cloud Task Date Strategy to match Batch
resolves #868 Signed-off-by: Glenn Renfro <grenfro@vmware.com> Updated the timestamps for H2,oracle, db2, hsqldb to be 9 digits for improved accuracy
This commit is contained in:
@@ -19,11 +19,11 @@ package org.springframework.cloud.task.listener;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.micrometer.observation.ObservationConvention;
|
||||
@@ -191,7 +191,7 @@ public class TaskLifecycleListener
|
||||
|
||||
private void doTaskEnd() {
|
||||
if ((this.listenerFailed || this.started) && !this.finished) {
|
||||
this.taskExecution.setEndTime(new Date());
|
||||
this.taskExecution.setEndTime(LocalDateTime.now());
|
||||
|
||||
if (this.applicationFailedException != null) {
|
||||
this.taskExecution.setErrorMessage(stackTraceToString(this.applicationFailedException));
|
||||
@@ -277,7 +277,8 @@ public class TaskLifecycleListener
|
||||
Assert.isNull(taskExecution.getEndTime(),
|
||||
String.format("Invalid TaskExecution, ID %s task is already complete",
|
||||
this.taskProperties.getExecutionid()));
|
||||
Date startDate = (taskExecution.getStartTime() == null) ? new Date() : taskExecution.getStartTime();
|
||||
LocalDateTime startDate = (taskExecution.getStartTime() == null) ? LocalDateTime.now()
|
||||
: taskExecution.getStartTime();
|
||||
this.taskExecution = this.taskRepository.startTaskExecution(this.taskProperties.getExecutionid(),
|
||||
this.taskNameResolver.getTaskName(), startDate, args,
|
||||
this.taskProperties.getExternalExecutionId(), this.taskProperties.getParentExecutionId());
|
||||
@@ -285,7 +286,7 @@ public class TaskLifecycleListener
|
||||
else {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setTaskName(this.taskNameResolver.getTaskName());
|
||||
taskExecution.setStartTime(new Date());
|
||||
taskExecution.setStartTime(LocalDateTime.now());
|
||||
taskExecution.setArguments(args);
|
||||
taskExecution.setExternalExecutionId(this.taskProperties.getExternalExecutionId());
|
||||
taskExecution.setParentExecutionId(this.taskProperties.getParentExecutionId());
|
||||
@@ -384,8 +385,8 @@ public class TaskLifecycleListener
|
||||
}
|
||||
|
||||
private TaskExecution getTaskExecutionCopy(TaskExecution taskExecution) {
|
||||
Date startTime = new Date(taskExecution.getStartTime().getTime());
|
||||
Date endTime = (taskExecution.getEndTime() == null) ? null : new Date(taskExecution.getEndTime().getTime());
|
||||
LocalDateTime startTime = taskExecution.getStartTime();
|
||||
LocalDateTime endTime = taskExecution.getEndTime();
|
||||
|
||||
return new TaskExecution(taskExecution.getExecutionId(), taskExecution.getExitCode(),
|
||||
taskExecution.getTaskName(), startTime, endTime, taskExecution.getExitMessage(),
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.task.repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -55,12 +55,12 @@ public class TaskExecution {
|
||||
/**
|
||||
* Time of when the task was started.
|
||||
*/
|
||||
private Date startTime;
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* Timestamp of when the task was completed/terminated.
|
||||
*/
|
||||
private Date endTime;
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* Message returned from the task or stacktrace.
|
||||
@@ -90,9 +90,9 @@ public class TaskExecution {
|
||||
this.arguments = new ArrayList<>();
|
||||
}
|
||||
|
||||
public TaskExecution(long executionId, Integer exitCode, String taskName, Date startTime, Date endTime,
|
||||
String exitMessage, List<String> arguments, String errorMessage, String externalExecutionId,
|
||||
Long parentExecutionId) {
|
||||
public TaskExecution(long executionId, Integer exitCode, String taskName, LocalDateTime startTime,
|
||||
LocalDateTime endTime, String exitMessage, List<String> arguments, String errorMessage,
|
||||
String externalExecutionId, Long parentExecutionId) {
|
||||
|
||||
Assert.notNull(arguments, "arguments must not be null");
|
||||
this.executionId = executionId;
|
||||
@@ -100,15 +100,16 @@ public class TaskExecution {
|
||||
this.taskName = taskName;
|
||||
this.exitMessage = exitMessage;
|
||||
this.arguments = new ArrayList<>(arguments);
|
||||
this.startTime = (startTime != null) ? (Date) startTime.clone() : null;
|
||||
this.endTime = (endTime != null) ? (Date) endTime.clone() : null;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.errorMessage = errorMessage;
|
||||
this.externalExecutionId = externalExecutionId;
|
||||
this.parentExecutionId = parentExecutionId;
|
||||
}
|
||||
|
||||
public TaskExecution(long executionId, Integer exitCode, String taskName, Date startTime, Date endTime,
|
||||
String exitMessage, List<String> arguments, String errorMessage, String externalExecutionId) {
|
||||
public TaskExecution(long executionId, Integer exitCode, String taskName, LocalDateTime startTime,
|
||||
LocalDateTime endTime, String exitMessage, List<String> arguments, String errorMessage,
|
||||
String externalExecutionId) {
|
||||
|
||||
this(executionId, exitCode, taskName, startTime, endTime, exitMessage, arguments, errorMessage,
|
||||
externalExecutionId, null);
|
||||
@@ -134,20 +135,20 @@ public class TaskExecution {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return (this.startTime != null) ? (Date) this.startTime.clone() : null;
|
||||
public LocalDateTime getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = (startTime != null) ? (Date) startTime.clone() : null;
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return (this.endTime != null) ? (Date) this.endTime.clone() : null;
|
||||
public LocalDateTime getEndTime() {
|
||||
return this.endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = (endTime != null) ? (Date) endTime.clone() : null;
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getExitMessage() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.task.repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -40,7 +40,7 @@ public interface TaskRepository {
|
||||
* @return the updated {@link TaskExecution}
|
||||
*/
|
||||
@Transactional("${spring.cloud.task.transaction-manager:springCloudTaskTransactionManager}")
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage);
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage);
|
||||
|
||||
/**
|
||||
* Notifies the repository that a taskExecution has completed.
|
||||
@@ -53,7 +53,7 @@ public interface TaskRepository {
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Transactional("${spring.cloud.task.transaction-manager:springCloudTaskTransactionManager}")
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage,
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage,
|
||||
String errorMessage);
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public interface TaskRepository {
|
||||
* @return TaskExecution created based on the parameters.
|
||||
*/
|
||||
@Transactional("${spring.cloud.task.transaction-manager:springCloudTaskTransactionManager}")
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId);
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ public interface TaskRepository {
|
||||
* a TaskExecution.
|
||||
*/
|
||||
@Transactional("${spring.cloud.task.transaction-manager:springCloudTaskTransactionManager}")
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@ package org.springframework.cloud.task.repository.dao;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -199,13 +200,13 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId) {
|
||||
return createTaskExecution(taskName, startTime, arguments, externalExecutionId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId) {
|
||||
long nextExecutionId = getNextExecutionId();
|
||||
|
||||
@@ -214,8 +215,9 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("taskExecutionId", nextExecutionId, Types.BIGINT).addValue("exitCode", null, Types.INTEGER)
|
||||
.addValue("startTime", startTime, Types.TIMESTAMP).addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", new Date(), Types.TIMESTAMP)
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("externalExecutionId", externalExecutionId, Types.VARCHAR)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT);
|
||||
|
||||
@@ -225,20 +227,21 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionId) {
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionId) {
|
||||
return startTaskExecution(executionId, taskName, startTime, arguments, externalExecutionId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId) {
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionId, Long parentExecutionId) {
|
||||
TaskExecution taskExecution = new TaskExecution(executionId, null, taskName, startTime, null, null, arguments,
|
||||
null, externalExecutionId, parentExecutionId);
|
||||
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource()
|
||||
.addValue("startTime", startTime, Types.TIMESTAMP).addValue("exitCode", null, Types.INTEGER)
|
||||
.addValue("taskName", taskName, Types.VARCHAR).addValue("lastUpdated", new Date(), Types.TIMESTAMP)
|
||||
.addValue("startTime", startTime == null ? null : Timestamp.valueOf(startTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", null, Types.INTEGER).addValue("taskName", taskName, Types.VARCHAR)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("parentExecutionId", parentExecutionId, Types.BIGINT)
|
||||
.addValue("taskExecutionId", executionId, Types.BIGINT);
|
||||
|
||||
@@ -258,7 +261,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeTaskExecution(long taskExecutionId, Integer exitCode, Date endTime, String exitMessage,
|
||||
public void completeTaskExecution(long taskExecutionId, Integer exitCode, LocalDateTime endTime, String exitMessage,
|
||||
String errorMessage) {
|
||||
final MapSqlParameterSource queryParameters = new MapSqlParameterSource().addValue("taskExecutionId",
|
||||
taskExecutionId, Types.BIGINT);
|
||||
@@ -271,17 +274,18 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
final MapSqlParameterSource parameters = new MapSqlParameterSource()
|
||||
.addValue("endTime", endTime, Types.TIMESTAMP).addValue("exitCode", exitCode, Types.INTEGER)
|
||||
.addValue("exitMessage", exitMessage, Types.VARCHAR)
|
||||
.addValue("endTime", endTime == null ? null : Timestamp.valueOf(endTime), Types.TIMESTAMP)
|
||||
.addValue("exitCode", exitCode, Types.INTEGER).addValue("exitMessage", exitMessage, Types.VARCHAR)
|
||||
.addValue("errorMessage", errorMessage, Types.VARCHAR)
|
||||
.addValue("lastUpdated", new Date(), Types.TIMESTAMP)
|
||||
.addValue("lastUpdated", Timestamp.valueOf(LocalDateTime.now()), Types.TIMESTAMP)
|
||||
.addValue("taskExecutionId", taskExecutionId, Types.BIGINT);
|
||||
|
||||
this.jdbcTemplate.update(getQuery(UPDATE_TASK_EXECUTION), parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeTaskExecution(long taskExecutionId, Integer exitCode, Date endTime, String exitMessage) {
|
||||
public void completeTaskExecution(long taskExecutionId, Integer exitCode, LocalDateTime endTime,
|
||||
String exitMessage) {
|
||||
completeTaskExecution(taskExecutionId, exitCode, endTime, exitMessage, null);
|
||||
}
|
||||
|
||||
@@ -582,9 +586,9 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
parentExecutionId = null;
|
||||
}
|
||||
return new TaskExecution(id, getNullableExitCode(rs), rs.getString("TASK_NAME"),
|
||||
rs.getTimestamp("START_TIME"), rs.getTimestamp("END_TIME"), rs.getString("EXIT_MESSAGE"),
|
||||
getTaskArguments(id), rs.getString("ERROR_MESSAGE"), rs.getString("EXTERNAL_EXECUTION_ID"),
|
||||
parentExecutionId);
|
||||
rs.getObject("START_TIME", LocalDateTime.class), rs.getObject("END_TIME", LocalDateTime.class),
|
||||
rs.getString("EXIT_MESSAGE"), getTaskArguments(id), rs.getString("ERROR_MESSAGE"),
|
||||
rs.getString("EXTERNAL_EXECUTION_ID"), parentExecutionId);
|
||||
}
|
||||
|
||||
private Integer getNullableExitCode(ResultSet rs) throws SQLException {
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.springframework.cloud.task.repository.dao;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -58,13 +58,13 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId) {
|
||||
return createTaskExecution(taskName, startTime, arguments, externalExecutionId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
public TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId) {
|
||||
long taskExecutionId = getNextExecutionId();
|
||||
TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName, startTime, null, null,
|
||||
@@ -74,14 +74,14 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionid) {
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionid) {
|
||||
return startTaskExecution(executionId, taskName, startTime, arguments, externalExecutionid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionid, Long parentExecutionId) {
|
||||
public TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionid, Long parentExecutionId) {
|
||||
TaskExecution taskExecution = this.taskExecutions.get(executionId);
|
||||
taskExecution.setTaskName(taskName);
|
||||
taskExecution.setStartTime(startTime);
|
||||
@@ -94,7 +94,7 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage,
|
||||
public void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage,
|
||||
String errorMessage) {
|
||||
if (!this.taskExecutions.containsKey(executionId)) {
|
||||
throw new IllegalStateException("Invalid TaskExecution, ID " + executionId + " not found.");
|
||||
@@ -108,7 +108,7 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage) {
|
||||
public void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage) {
|
||||
completeTaskExecution(executionId, exitCode, endTime, exitMessage, null);
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
|
||||
final TaskExecution tempTaskExecution = tempTaskExecutions
|
||||
.get(taskExecutionMapEntry.getValue().getTaskName());
|
||||
if (tempTaskExecution == null
|
||||
|| tempTaskExecution.getStartTime().before(taskExecutionMapEntry.getValue().getStartTime())
|
||||
|| tempTaskExecution.getStartTime().isBefore(taskExecutionMapEntry.getValue().getStartTime())
|
||||
|| (tempTaskExecution.getStartTime().equals(taskExecutionMapEntry.getValue().getStartTime())
|
||||
&& tempTaskExecution.getExecutionId() < taskExecutionMapEntry.getValue()
|
||||
.getExecutionId())) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.task.repository.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -42,7 +42,7 @@ public interface TaskExecutionDao {
|
||||
* @param externalExecutionId id assigned to the task by the platform
|
||||
* @return A fully qualified {@link TaskExecution} instance.
|
||||
*/
|
||||
TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId);
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public interface TaskExecutionDao {
|
||||
* @return A fully qualified {@link TaskExecution} instance.
|
||||
* @since 1.2.0
|
||||
*/
|
||||
TaskExecution createTaskExecution(String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution createTaskExecution(String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId);
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ public interface TaskExecutionDao {
|
||||
* start.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId);
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public interface TaskExecutionDao {
|
||||
* start.
|
||||
* @since 1.2.0
|
||||
*/
|
||||
TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List<String> arguments,
|
||||
TaskExecution startTaskExecution(long executionId, String taskName, LocalDateTime startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId);
|
||||
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ public interface TaskExecutionDao {
|
||||
* @param errorMessage error information available upon failure of a task.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage,
|
||||
void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage,
|
||||
String errorMessage);
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public interface TaskExecutionDao {
|
||||
* @param endTime the time the task completed.
|
||||
* @param exitMessage the message assigned to the task upon completion.
|
||||
*/
|
||||
void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage);
|
||||
void completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime, String exitMessage);
|
||||
|
||||
/**
|
||||
* Retrieves a task execution from the task repository.
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.task.repository.support;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -87,13 +87,14 @@ public class SimpleTaskRepository implements TaskRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage) {
|
||||
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime,
|
||||
String exitMessage) {
|
||||
return completeTaskExecution(executionId, exitCode, endTime, exitMessage, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage,
|
||||
String errorMessage) {
|
||||
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, LocalDateTime endTime,
|
||||
String exitMessage, String errorMessage) {
|
||||
initialize();
|
||||
|
||||
validateCompletedTaskExitInformation(executionId, exitCode, endTime);
|
||||
@@ -133,8 +134,8 @@ public class SimpleTaskRepository implements TaskRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionId) {
|
||||
public TaskExecution startTaskExecution(long executionid, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionId) {
|
||||
return startTaskExecution(executionid, taskName, startTime, arguments, externalExecutionId, null);
|
||||
}
|
||||
|
||||
@@ -145,8 +146,8 @@ public class SimpleTaskRepository implements TaskRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List<String> arguments,
|
||||
String externalExecutionId, Long parentExecutionId) {
|
||||
public TaskExecution startTaskExecution(long executionid, String taskName, LocalDateTime startTime,
|
||||
List<String> arguments, String externalExecutionId, Long parentExecutionId) {
|
||||
initialize();
|
||||
TaskExecution taskExecution = this.taskExecutionDao.startTaskExecution(executionid, taskName, startTime,
|
||||
arguments, externalExecutionId, parentExecutionId);
|
||||
@@ -187,7 +188,7 @@ public class SimpleTaskRepository implements TaskRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCompletedTaskExitInformation(long executionId, Integer exitCode, Date endTime) {
|
||||
private void validateCompletedTaskExitInformation(long executionId, Integer exitCode, LocalDateTime endTime) {
|
||||
Assert.notNull(exitCode, "exitCode should not be null");
|
||||
Assert.isTrue(exitCode >= 0, "exit code must be greater than or equal to zero");
|
||||
Assert.notNull(endTime, "TaskExecution endTime cannot be null.");
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
CREATE TABLE TASK_EXECUTION (
|
||||
TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
START_TIME TIMESTAMP DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
START_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
TASK_NAME VARCHAR(100) ,
|
||||
EXIT_CODE INTEGER ,
|
||||
EXIT_MESSAGE VARCHAR(2500) ,
|
||||
ERROR_MESSAGE VARCHAR(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
LAST_UPDATED TIMESTAMP(9),
|
||||
EXTERNAL_EXECUTION_ID VARCHAR(255),
|
||||
PARENT_EXECUTION_ID BIGINT
|
||||
);
|
||||
@@ -32,6 +32,6 @@ CREATE TABLE TASK_LOCK (
|
||||
LOCK_KEY CHAR(36) NOT NULL,
|
||||
REGION VARCHAR(100) NOT NULL,
|
||||
CLIENT_ID CHAR(36),
|
||||
CREATED_DATE TIMESTAMP NOT NULL,
|
||||
CREATED_DATE TIMESTAMP(9) NOT NULL,
|
||||
constraint LOCK_PK primary key (LOCK_KEY, REGION)
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
CREATE TABLE TASK_EXECUTION (
|
||||
TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
START_TIME TIMESTAMP DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
START_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
TASK_NAME VARCHAR(100) ,
|
||||
EXIT_CODE INTEGER ,
|
||||
EXIT_MESSAGE VARCHAR(2500) ,
|
||||
ERROR_MESSAGE VARCHAR(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
LAST_UPDATED TIMESTAMP(9),
|
||||
EXTERNAL_EXECUTION_ID VARCHAR(255),
|
||||
PARENT_EXECUTION_ID BIGINT
|
||||
);
|
||||
@@ -32,6 +32,6 @@ CREATE TABLE TASK_LOCK (
|
||||
LOCK_KEY CHAR(36) NOT NULL,
|
||||
REGION VARCHAR(100) NOT NULL,
|
||||
CLIENT_ID CHAR(36),
|
||||
CREATED_DATE TIMESTAMP NOT NULL,
|
||||
CREATED_DATE TIMESTAMP(9) NOT NULL,
|
||||
constraint LOCK_PK primary key (LOCK_KEY, REGION)
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
CREATE TABLE TASK_EXECUTION (
|
||||
TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
START_TIME TIMESTAMP DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
START_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
TASK_NAME VARCHAR(100) ,
|
||||
EXIT_CODE INTEGER ,
|
||||
EXIT_MESSAGE VARCHAR(2500) ,
|
||||
ERROR_MESSAGE VARCHAR(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
LAST_UPDATED TIMESTAMP(9),
|
||||
EXTERNAL_EXECUTION_ID VARCHAR(255),
|
||||
PARENT_EXECUTION_ID BIGINT
|
||||
);
|
||||
@@ -34,6 +34,6 @@ CREATE TABLE TASK_LOCK (
|
||||
LOCK_KEY CHAR(36) NOT NULL,
|
||||
REGION VARCHAR(100) NOT NULL,
|
||||
CLIENT_ID CHAR(36),
|
||||
CREATED_DATE TIMESTAMP NOT NULL,
|
||||
CREATED_DATE TIMESTAMP(9) NOT NULL,
|
||||
constraint LOCK_PK primary key (LOCK_KEY, REGION)
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
CREATE TABLE TASK_EXECUTION (
|
||||
TASK_EXECUTION_ID NUMBER NOT NULL PRIMARY KEY ,
|
||||
START_TIME TIMESTAMP DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
START_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP(9) DEFAULT NULL ,
|
||||
TASK_NAME VARCHAR2(100) ,
|
||||
EXIT_CODE INTEGER ,
|
||||
EXIT_MESSAGE VARCHAR2(2500) ,
|
||||
ERROR_MESSAGE VARCHAR2(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
LAST_UPDATED TIMESTAMP(9),
|
||||
EXTERNAL_EXECUTION_ID VARCHAR2(255),
|
||||
PARENT_EXECUTION_ID NUMBER
|
||||
);
|
||||
@@ -32,6 +32,6 @@ CREATE TABLE TASK_LOCK (
|
||||
LOCK_KEY VARCHAR2(36) NOT NULL,
|
||||
REGION VARCHAR2(100) NOT NULL,
|
||||
CLIENT_ID VARCHAR2(36),
|
||||
CREATED_DATE TIMESTAMP NOT NULL,
|
||||
CREATED_DATE TIMESTAMP(9) NOT NULL,
|
||||
constraint LOCK_PK primary key (LOCK_KEY, REGION)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user