public class DBJobTriggerService extends Object
| Constructor and Description |
|---|
DBJobTriggerService(MongoConnection mongoConnection,
MongoJackObjectMapperProvider mapper,
NodeId nodeId,
JobSchedulerClock clock) |
| Modifier and Type | Method and Description |
|---|---|
List<JobTriggerDto> |
all()
Loads all existing records and returns them.
|
JobTriggerDto |
create(JobTriggerDto trigger)
Creates a new record in the database.
|
boolean |
delete(String triggerId)
Deletes the trigger with the given ID.
|
int |
deleteCompletedOnceSchedulesOlderThan(long timeValue,
TimeUnit unit)
Deletes completed
OnceJobSchedule triggers that are older than the provided time |
int |
forceReleaseOwnedTriggers()
WARNING: This should only be called before the job scheduler is started! Calling this
while the scheduler is running might result in data corruption or inconsistencies!
|
Optional<JobTriggerDto> |
get(String id)
Loads the record for the given ID.
|
List<JobTriggerDto> |
getForJob(String jobDefinitionId)
Returns all job triggers for the given job definition ID.
|
Map<String,List<JobTriggerDto>> |
getForJobs(Collection<String> jobDefinitionIds)
Returns all job triggers for the given job definition IDs, grouped by job definition ID.
|
Optional<JobTriggerDto> |
nextRunnableTrigger()
Locks and returns the next runnable trigger.
|
boolean |
releaseTrigger(JobTriggerDto trigger,
JobTriggerUpdate triggerUpdate)
Releases a locked trigger.
|
boolean |
setTriggerError(JobTriggerDto trigger)
Mark the given trigger as defective to make sure it will not be scheduled anymore.
|
boolean |
update(JobTriggerDto trigger)
Updates the given trigger record in the database.
|
@Inject public DBJobTriggerService(MongoConnection mongoConnection, MongoJackObjectMapperProvider mapper, NodeId nodeId, JobSchedulerClock clock)
public List<JobTriggerDto> all()
public Optional<JobTriggerDto> get(String id)
id - record ID to loadpublic List<JobTriggerDto> getForJob(String jobDefinitionId)
jobDefinitionId - the job definition IDpublic Map<String,List<JobTriggerDto>> getForJobs(Collection<String> jobDefinitionIds)
jobDefinitionIds - the job definition IDspublic JobTriggerDto create(JobTriggerDto trigger)
JobTriggerDto object must not have an ID to make
sure a new record is created.trigger - the new trigger object (without an ID set)IllegalArgumentException - if the passed trigger has an ID setpublic boolean update(JobTriggerDto trigger)
trigger - the trigger to updateIllegalArgumentException - if the passed trigger doesn't have an ID setpublic boolean delete(String triggerId)
triggerId - the trigger ID to deletepublic int deleteCompletedOnceSchedulesOlderThan(long timeValue,
TimeUnit unit)
OnceJobSchedule triggers that are older than the provided timetimeValue - the time range of triggers to be removedunit - the unit of the provided timeValuepublic Optional<JobTriggerDto> nextRunnableTrigger()
Optional otherwisepublic boolean releaseTrigger(JobTriggerDto trigger, JobTriggerUpdate triggerUpdate)
trigger - trigger that should be releasedtriggerUpdate - update to apply to the triggerpublic int forceReleaseOwnedTriggers()
RUNNING status after an unclean JVM or Graylog server shutdown.public boolean setTriggerError(JobTriggerDto trigger)
trigger - trigger that should be marked as defectiveCopyright © 2012–2021 Graylog, Inc.. All rights reserved.