Class SchedulerRepositoryImpl
- java.lang.Object
-
- io.opensw.scheduler.core.domain.scheduler.SchedulerRepositoryImpl
-
- All Implemented Interfaces:
SchedulerRepository
@Component public class SchedulerRepositoryImpl extends java.lang.Object implements SchedulerRepository
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringH2_INSERT_QUERYprotected static java.lang.StringH2_SELECT_QUERYprotected static java.lang.StringH2_UPDATE_NOT_RUN_QUERYprotected static java.lang.StringH2_UPDATE_QUERYprotected static java.lang.StringH2_UPDATE_RECURRING_QUERYprotected static java.lang.StringMSSQL_INSERT_QUERYprotected static java.lang.StringMSSQL_SELECT_QUERYprotected static java.lang.StringMSSQL_UPDATE_NOT_RUN_QUERYprotected static java.lang.StringMSSQL_UPDATE_QUERYprotected static java.lang.StringMSSQL_UPDATE_RECURRING_QUERYprotected static java.lang.StringMYSQL_INSERT_QUERYprotected static java.lang.StringMYSQL_SELECT_QUERYprotected static java.lang.StringMYSQL_UPDATE_NOT_RUN_QUERYprotected static java.lang.StringMYSQL_UPDATE_QUERYprotected static java.lang.StringMYSQL_UPDATE_RECURRING_QUERYprotected static java.lang.StringPOSTGRE_INSERT_QUERYprotected static java.lang.StringPOSTGRE_SELECT_QUERYprotected static java.lang.StringPOSTGRE_UPDATE_NOT_RUN_QUERYprotected static java.lang.StringPOSTGRE_UPDATE_QUERYprotected static java.lang.StringPOSTGRE_UPDATE_RECURRING_QUERY
-
Constructor Summary
Constructors Constructor Description SchedulerRepositoryImpl(javax.sql.DataSource dataSource, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleaninsertTask(Task task)Save task on databasebooleaninsertTask(Task task, boolean picked, java.lang.String server)Save task on databasejava.util.List<Task>loadTasksToRun(java.lang.String server, long pollingInterval)Load tasks to runbooleanupdateNotRunnedTask(java.lang.String server)Update not runned tasks to make them available to be picked by another serversbooleanupdateRecurringTask(RecurringTask task, boolean picked, java.lang.String pickedBy)Update recurring task data after run This update running fields to put task available to run another time Changed fields: picked = false, picked_by = null and end_run = nullbooleanupdateTask(java.lang.String key, java.time.Instant end)Update task data after run
-
-
-
Field Detail
-
MYSQL_INSERT_QUERY
protected static final java.lang.String MYSQL_INSERT_QUERY
- See Also:
- Constant Field Values
-
POSTGRE_INSERT_QUERY
protected static final java.lang.String POSTGRE_INSERT_QUERY
- See Also:
- Constant Field Values
-
MSSQL_INSERT_QUERY
protected static final java.lang.String MSSQL_INSERT_QUERY
- See Also:
- Constant Field Values
-
H2_INSERT_QUERY
protected static final java.lang.String H2_INSERT_QUERY
- See Also:
- Constant Field Values
-
MYSQL_SELECT_QUERY
protected static final java.lang.String MYSQL_SELECT_QUERY
- See Also:
- Constant Field Values
-
POSTGRE_SELECT_QUERY
protected static final java.lang.String POSTGRE_SELECT_QUERY
- See Also:
- Constant Field Values
-
MSSQL_SELECT_QUERY
protected static final java.lang.String MSSQL_SELECT_QUERY
- See Also:
- Constant Field Values
-
H2_SELECT_QUERY
protected static final java.lang.String H2_SELECT_QUERY
- See Also:
- Constant Field Values
-
MYSQL_UPDATE_QUERY
protected static final java.lang.String MYSQL_UPDATE_QUERY
- See Also:
- Constant Field Values
-
POSTGRE_UPDATE_QUERY
protected static final java.lang.String POSTGRE_UPDATE_QUERY
- See Also:
- Constant Field Values
-
MSSQL_UPDATE_QUERY
protected static final java.lang.String MSSQL_UPDATE_QUERY
- See Also:
- Constant Field Values
-
H2_UPDATE_QUERY
protected static final java.lang.String H2_UPDATE_QUERY
- See Also:
- Constant Field Values
-
MYSQL_UPDATE_RECURRING_QUERY
protected static final java.lang.String MYSQL_UPDATE_RECURRING_QUERY
- See Also:
- Constant Field Values
-
POSTGRE_UPDATE_RECURRING_QUERY
protected static final java.lang.String POSTGRE_UPDATE_RECURRING_QUERY
- See Also:
- Constant Field Values
-
MSSQL_UPDATE_RECURRING_QUERY
protected static final java.lang.String MSSQL_UPDATE_RECURRING_QUERY
- See Also:
- Constant Field Values
-
H2_UPDATE_RECURRING_QUERY
protected static final java.lang.String H2_UPDATE_RECURRING_QUERY
- See Also:
- Constant Field Values
-
POSTGRE_UPDATE_NOT_RUN_QUERY
protected static final java.lang.String POSTGRE_UPDATE_NOT_RUN_QUERY
- See Also:
- Constant Field Values
-
MYSQL_UPDATE_NOT_RUN_QUERY
protected static final java.lang.String MYSQL_UPDATE_NOT_RUN_QUERY
- See Also:
- Constant Field Values
-
MSSQL_UPDATE_NOT_RUN_QUERY
protected static final java.lang.String MSSQL_UPDATE_NOT_RUN_QUERY
- See Also:
- Constant Field Values
-
H2_UPDATE_NOT_RUN_QUERY
protected static final java.lang.String H2_UPDATE_NOT_RUN_QUERY
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadTasksToRun
public java.util.List<Task> loadTasksToRun(java.lang.String server, long pollingInterval) throws DatabaseException
Description copied from interface:SchedulerRepositoryLoad tasks to run- Specified by:
loadTasksToRunin interfaceSchedulerRepository- Parameters:
server- identifierpollingInterval- interval in milliseconds to pull tasks- Returns:
- list of tasks to run
- Throws:
DatabaseException- exception thrown when database no configured well
-
insertTask
public boolean insertTask(Task task) throws DatabaseException
Description copied from interface:SchedulerRepositorySave task on database- Specified by:
insertTaskin interfaceSchedulerRepository- Parameters:
task- to save on database- Returns:
- result of operation
- Throws:
DatabaseException- thrown when database not configured well
-
insertTask
public boolean insertTask(Task task, boolean picked, java.lang.String server) throws DatabaseException
Description copied from interface:SchedulerRepositorySave task on database- Specified by:
insertTaskin interfaceSchedulerRepository- Parameters:
task- to save on databasepicked- boolean with picked statusserver- is the name/identifier of server- Returns:
- result of operation
- Throws:
DatabaseException- thrown when database not configured well
-
updateTask
public boolean updateTask(java.lang.String key, java.time.Instant end) throws DatabaseExceptionDescription copied from interface:SchedulerRepositoryUpdate task data after run- Specified by:
updateTaskin interfaceSchedulerRepository- Parameters:
key- task identifierend- time- Returns:
- result of operation
- Throws:
DatabaseException- thrown when database not configured well
-
updateRecurringTask
public boolean updateRecurringTask(RecurringTask task, boolean picked, java.lang.String pickedBy) throws DatabaseException
Description copied from interface:SchedulerRepositoryUpdate recurring task data after run This update running fields to put task available to run another time Changed fields: picked = false, picked_by = null and end_run = null- Specified by:
updateRecurringTaskin interfaceSchedulerRepository- Parameters:
task- to updatepicked- if task was picked by this instancepickedBy- server name- Returns:
- result of operation
- Throws:
DatabaseException- thrown when database not configured well
-
updateNotRunnedTask
public boolean updateNotRunnedTask(java.lang.String server) throws DatabaseExceptionDescription copied from interface:SchedulerRepositoryUpdate not runned tasks to make them available to be picked by another servers- Specified by:
updateNotRunnedTaskin interfaceSchedulerRepository- Parameters:
server- identifier- Returns:
- result of operation
- Throws:
DatabaseException- thrown when database not configured well
-
-