Class JdbcTaskRepository
- java.lang.Object
-
- com.github.kagkarlsson.scheduler.jdbc.JdbcTaskRepository
-
- All Implemented Interfaces:
TaskRepository
public class JdbcTaskRepository extends Object implements TaskRepository
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TABLE_NAME
-
Constructor Summary
Constructors Modifier Constructor Description protectedJdbcTaskRepository(JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, Serializer serializer, JdbcRunner jdbcRunner, boolean orderByPriority, Clock clock)JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, boolean orderByPriority, Clock clock)JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, Serializer serializer, boolean orderByPriority, Clock clock)JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, boolean orderByPriority, Clock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateBatch(List<ScheduledTaskInstance> executions)booleancreateIfNotExists(SchedulableInstance instance)Prefer ScheduledTaskInstance which has a fixed execution-timebooleancreateIfNotExists(ScheduledTaskInstance instance)List<Execution>getDeadExecutions(Instant olderThan)List<Execution>getDue(Instant now, int limit)Optional<Execution>getExecution(TaskInstance taskInstance)Optional<Execution>getExecution(String taskName, String taskInstanceId)List<Execution>getExecutionsFailingLongerThan(Duration interval)voidgetScheduledExecutions(ScheduledExecutionsFilter filter, String taskName, Consumer<Execution> consumer)voidgetScheduledExecutions(ScheduledExecutionsFilter filter, Consumer<Execution> consumer)List<Execution>lockAndFetchGeneric(Instant now, int limit)List<Execution>lockAndGetDue(Instant now, int limit)Optional<Execution>pick(Execution e, Instant timePicked)voidremove(Execution execution)intremoveExecutions(String taskName)Instantreplace(Execution toBeReplaced, SchedulableInstance newInstance)Prefer ScheduledTaskInstance which has a fixed execution-timeInstantreplace(Execution toBeReplaced, ScheduledTaskInstance newInstance)Instead of doing delete+insert, we allow updating an existing execution will all new fieldsbooleanreschedule(Execution execution, Instant nextExecutionTime, Object newData, Instant lastSuccess, Instant lastFailure, int consecutiveFailures)booleanreschedule(Execution execution, Instant nextExecutionTime, Instant lastSuccess, Instant lastFailure, int consecutiveFailures)booleanupdateHeartbeat(Execution e, Instant newHeartbeat)booleanupdateHeartbeatWithRetry(Execution execution, Instant newHeartbeat, int tries)voidverifySupportsLockAndFetch()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.kagkarlsson.scheduler.TaskRepository
getExecution
-
-
-
-
Field Detail
-
DEFAULT_TABLE_NAME
public static final String DEFAULT_TABLE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JdbcTaskRepository
public JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, boolean orderByPriority, Clock clock)
-
JdbcTaskRepository
public JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, boolean orderByPriority, Clock clock)
-
JdbcTaskRepository
public JdbcTaskRepository(DataSource dataSource, boolean commitWhenAutocommitDisabled, JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, Serializer serializer, boolean orderByPriority, Clock clock)
-
JdbcTaskRepository
protected JdbcTaskRepository(JdbcCustomization jdbcCustomization, String tableName, TaskResolver taskResolver, SchedulerName schedulerSchedulerName, Serializer serializer, JdbcRunner jdbcRunner, boolean orderByPriority, Clock clock)
-
-
Method Detail
-
createIfNotExists
public boolean createIfNotExists(SchedulableInstance instance)
Description copied from interface:TaskRepositoryPrefer ScheduledTaskInstance which has a fixed execution-time- Specified by:
createIfNotExistsin interfaceTaskRepository
-
createIfNotExists
public boolean createIfNotExists(ScheduledTaskInstance instance)
- Specified by:
createIfNotExistsin interfaceTaskRepository
-
createBatch
public void createBatch(List<ScheduledTaskInstance> executions)
- Specified by:
createBatchin interfaceTaskRepository
-
replace
public Instant replace(Execution toBeReplaced, SchedulableInstance newInstance)
Description copied from interface:TaskRepositoryPrefer ScheduledTaskInstance which has a fixed execution-time- Specified by:
replacein interfaceTaskRepository
-
replace
public Instant replace(Execution toBeReplaced, ScheduledTaskInstance newInstance)
Instead of doing delete+insert, we allow updating an existing execution will all new fields- Specified by:
replacein interfaceTaskRepository- Returns:
- the execution-time of the new execution
-
getScheduledExecutions
public void getScheduledExecutions(ScheduledExecutionsFilter filter, Consumer<Execution> consumer)
- Specified by:
getScheduledExecutionsin interfaceTaskRepository
-
getScheduledExecutions
public void getScheduledExecutions(ScheduledExecutionsFilter filter, String taskName, Consumer<Execution> consumer)
- Specified by:
getScheduledExecutionsin interfaceTaskRepository
-
getDue
public List<Execution> getDue(Instant now, int limit)
- Specified by:
getDuein interfaceTaskRepository
-
lockAndFetchGeneric
public List<Execution> lockAndFetchGeneric(Instant now, int limit)
- Specified by:
lockAndFetchGenericin interfaceTaskRepository
-
lockAndGetDue
public List<Execution> lockAndGetDue(Instant now, int limit)
- Specified by:
lockAndGetDuein interfaceTaskRepository
-
remove
public void remove(Execution execution)
- Specified by:
removein interfaceTaskRepository
-
reschedule
public boolean reschedule(Execution execution, Instant nextExecutionTime, Instant lastSuccess, Instant lastFailure, int consecutiveFailures)
- Specified by:
reschedulein interfaceTaskRepository
-
reschedule
public boolean reschedule(Execution execution, Instant nextExecutionTime, Object newData, Instant lastSuccess, Instant lastFailure, int consecutiveFailures)
- Specified by:
reschedulein interfaceTaskRepository
-
pick
public Optional<Execution> pick(Execution e, Instant timePicked)
- Specified by:
pickin interfaceTaskRepository
-
getDeadExecutions
public List<Execution> getDeadExecutions(Instant olderThan)
- Specified by:
getDeadExecutionsin interfaceTaskRepository
-
updateHeartbeatWithRetry
public boolean updateHeartbeatWithRetry(Execution execution, Instant newHeartbeat, int tries)
- Specified by:
updateHeartbeatWithRetryin interfaceTaskRepository
-
updateHeartbeat
public boolean updateHeartbeat(Execution e, Instant newHeartbeat)
- Specified by:
updateHeartbeatin interfaceTaskRepository
-
getExecutionsFailingLongerThan
public List<Execution> getExecutionsFailingLongerThan(Duration interval)
- Specified by:
getExecutionsFailingLongerThanin interfaceTaskRepository
-
getExecution
public Optional<Execution> getExecution(TaskInstance taskInstance)
-
getExecution
public Optional<Execution> getExecution(String taskName, String taskInstanceId)
- Specified by:
getExecutionin interfaceTaskRepository
-
removeExecutions
public int removeExecutions(String taskName)
- Specified by:
removeExecutionsin interfaceTaskRepository
-
verifySupportsLockAndFetch
public void verifySupportsLockAndFetch()
- Specified by:
verifySupportsLockAndFetchin interfaceTaskRepository
-
-