public abstract class AbstractRedisStorage<T extends redis.clients.jedis.JedisCommands> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
CALENDAR_CLASS |
protected static String |
CALENDAR_JSON |
protected int |
lockTimeout |
protected UUID |
lockValue
The value of the currently held Redis lock (if any)
|
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
protected int |
misfireThreshold |
protected RedisJobStoreSchema |
redisSchema |
protected String |
schedulerInstanceId |
protected org.quartz.spi.SchedulerSignaler |
signaler |
protected static String |
TRIGGER_CLASS |
protected int |
TRIGGER_LOCK_TIMEOUT |
protected static String |
TRIGGER_NEXT_FIRE_TIME
The name of the trigger hash property which stores the trigger's next fire time
|
| Constructor and Description |
|---|
AbstractRedisStorage(RedisJobStoreSchema redisSchema,
com.fasterxml.jackson.databind.ObjectMapper mapper,
org.quartz.spi.SchedulerSignaler signaler,
String schedulerInstanceId,
int lockTimeout) |
| Modifier and Type | Method and Description |
|---|---|
List<org.quartz.spi.OperableTrigger> |
acquireNextTriggers(long noLaterThan,
int maxCount,
long timeWindow,
T jedis)
Get a handle to the next trigger to be fired, and mark it as 'reserved'
by the calling scheduler.
|
protected boolean |
applyMisfire(org.quartz.spi.OperableTrigger trigger,
T jedis)
Determine whether or not the given trigger has misfired.
|
boolean |
checkExists(org.quartz.JobKey jobKey,
T jedis)
Check if the job identified by the given key exists in storage
|
boolean |
checkExists(org.quartz.TriggerKey triggerKey,
T jedis)
Check if the trigger identified by the given key exists
|
void |
clearAllSchedulingData(T jedis)
Clear (delete!) all scheduling data - all
Jobs, Triggers Calendars. |
List<String> |
getCalendarNames(T jedis)
Get the names of all of the
s in the JobStore. |
List<String> |
getJobGroupNames(T jedis)
Get the names of all of the
groups. |
abstract Set<org.quartz.JobKey> |
getJobKeys(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> matcher,
T jedis)
Get the keys of all of the
s that have the given group name. |
protected long |
getLastTriggersReleaseTime(T jedis)
Retrieve the last time (in milliseconds) that orphaned triggers were released
|
int |
getNumberOfCalendars(T jedis)
Get the number of stored calendars
|
int |
getNumberOfJobs(T jedis)
Get the number of stored jobs
|
int |
getNumberOfTriggers(T jedis)
Get the number of stored triggers
|
Set<String> |
getPausedTriggerGroups(T jedis)
Retrieve all currently paused trigger groups
|
protected Map<String,String> |
getStringDataMap(org.quartz.JobDataMap jobDataMap)
Convert a
JobDataMap to a HashMap with String keys and values |
List<String> |
getTriggerGroupNames(T jedis)
Get the names of all of the
groups. |
abstract Set<org.quartz.TriggerKey> |
getTriggerKeys(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher,
T jedis)
Get the names of all of the
s that have the given group name. |
List<org.quartz.spi.OperableTrigger> |
getTriggersForJob(org.quartz.JobKey jobKey,
T jedis)
Retrieve triggers associated with the given job
|
abstract org.quartz.Trigger.TriggerState |
getTriggerState(org.quartz.TriggerKey triggerKey,
T jedis)
Get the current state of the identified
. |
protected boolean |
isJobConcurrentExecutionDisallowed(Class<? extends org.quartz.Job> jobClass)
Determine if the given job class disallows concurrent execution
|
protected boolean |
isNullOrEmpty(String string)
Check if a string is null or empty
|
protected boolean |
isPersistJobDataAfterExecution(Class<? extends org.quartz.Job> jobClass) |
boolean |
lock(T jedis)
Attempt to acquire a lock
|
protected boolean |
lockTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
Lock the trigger with the given key to the current jobstore instance
|
void |
pauseAll(T jedis)
Pause all triggers - equivalent of calling
pauseTriggerGroup(group) on every group. |
void |
pauseJob(org.quartz.JobKey jobKey,
T jedis)
Pause a job by pausing all of its triggers
|
abstract Collection<String> |
pauseJobs(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> groupMatcher,
T jedis)
Pause all of the
in the given group - by pausing all of their
Triggers. |
abstract void |
pauseTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
Pause the trigger with the given key
|
abstract Collection<String> |
pauseTriggers(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher,
T jedis)
Pause all of the
in the given group. |
protected int |
randomInt(int min,
int max)
Get a random integer within the specified bounds
|
void |
releaseAcquiredTrigger(org.quartz.spi.OperableTrigger trigger,
T jedis)
Inform the
JobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved). |
protected void |
releaseOrphanedTriggers(RedisTriggerState currentState,
RedisTriggerState newState,
T jedis)
Release triggers from the given current state to the new state if its locking scheduler has not
registered as alive in the last 10 minutes
|
protected void |
releaseTriggersCron(T jedis)
Release triggers currently held by schedulers which have ceased to function
|
abstract boolean |
removeCalendar(String calendarName,
T jedis)
Remove (delete) the
with the given name. |
abstract boolean |
removeJob(org.quartz.JobKey jobKey,
T jedis)
Remove the given job from Redis
|
protected abstract boolean |
removeTrigger(org.quartz.TriggerKey triggerKey,
boolean removeNonDurableJob,
T jedis)
Remove (delete) the
with the given key. |
boolean |
removeTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
Remove (delete) the
with the given key. |
boolean |
replaceTrigger(org.quartz.TriggerKey triggerKey,
org.quartz.spi.OperableTrigger newTrigger,
T jedis)
Remove (delete) the
with the
given key, and store the new given one - which must be associated
with the same job. |
void |
resumeAll(T jedis)
Resume (un-pause) all triggers - equivalent of calling
resumeTriggerGroup(group) on every group. |
void |
resumeJob(org.quartz.JobKey jobKey,
T jedis)
Resume (un-pause) the
with the given key. |
abstract Collection<String> |
resumeJobs(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> matcher,
T jedis)
Resume (un-pause) all of the
in the given group. |
abstract void |
resumeTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
Resume (un-pause) a
Trigger |
abstract Collection<String> |
resumeTriggers(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher,
T jedis)
Resume (un-pause) all of the
in the given group. |
org.quartz.Calendar |
retrieveCalendar(String name,
T jedis)
Retrieve a calendar
|
org.quartz.JobDetail |
retrieveJob(org.quartz.JobKey jobKey,
T jedis)
Retrieve a job from redis
|
org.quartz.spi.OperableTrigger |
retrieveTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
Retrieve a trigger from Redis
|
AbstractRedisStorage |
setMisfireThreshold(int misfireThreshold) |
protected void |
settLastTriggerReleaseTime(long time,
T jedis)
Set the last time at which orphaned triggers were released
|
boolean |
setTriggerState(RedisTriggerState state,
double score,
String triggerHashKey,
T jedis)
Set a trigger state by adding the trigger to the relevant sorted set, using its next fire time as the score.
|
abstract void |
storeCalendar(String name,
org.quartz.Calendar calendar,
boolean replaceExisting,
boolean updateTriggers,
T jedis)
Store a
Calendar |
abstract void |
storeJob(org.quartz.JobDetail jobDetail,
boolean replaceExisting,
T jedis)
Store a job in Redis
|
abstract void |
storeTrigger(org.quartz.spi.OperableTrigger trigger,
boolean replaceExisting,
T jedis)
Store a trigger in redis
|
abstract void |
triggeredJobComplete(org.quartz.spi.OperableTrigger trigger,
org.quartz.JobDetail jobDetail,
org.quartz.Trigger.CompletedExecutionInstruction triggerInstCode,
T jedis)
Inform the
JobStore that the scheduler has completed the
firing of the given Trigger (and the execution of its
associated Job completed, threw an exception, or was vetoed),
and that the
in the given JobDetail should be updated if the Job
is stateful. |
abstract List<org.quartz.spi.TriggerFiredResult> |
triggersFired(List<org.quartz.spi.OperableTrigger> triggers,
T jedis)
Inform the
JobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved). |
boolean |
unlock(T jedis)
Attempt to remove lock
|
abstract boolean |
unsetTriggerState(String triggerHashKey,
T jedis)
Unsets the state of the given trigger key by removing the trigger from all trigger state sets.
|
void |
waitForLock(T jedis)
Attempt to acquire lock.
|
protected static final String TRIGGER_CLASS
protected static final String CALENDAR_CLASS
protected static final String CALENDAR_JSON
protected static final String TRIGGER_NEXT_FIRE_TIME
protected final RedisJobStoreSchema redisSchema
protected final com.fasterxml.jackson.databind.ObjectMapper mapper
protected final org.quartz.spi.SchedulerSignaler signaler
protected final String schedulerInstanceId
protected final int lockTimeout
protected final int TRIGGER_LOCK_TIMEOUT
protected int misfireThreshold
protected UUID lockValue
public AbstractRedisStorage(RedisJobStoreSchema redisSchema, com.fasterxml.jackson.databind.ObjectMapper mapper, org.quartz.spi.SchedulerSignaler signaler, String schedulerInstanceId, int lockTimeout)
public AbstractRedisStorage setMisfireThreshold(int misfireThreshold)
public boolean lock(T jedis)
public void waitForLock(T jedis)
jedis - a thread-safe Redis connectionpublic boolean unlock(T jedis)
protected int randomInt(int min,
int max)
min - the minimum possible valuemax - the maximum possible valuepublic void clearAllSchedulingData(T jedis) throws org.quartz.JobPersistenceException, ClassNotFoundException
Jobs, Triggers Calendars.jedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionpublic abstract void storeJob(org.quartz.JobDetail jobDetail,
boolean replaceExisting,
T jedis)
throws org.quartz.ObjectAlreadyExistsException
jobDetail - the JobDetail object to be storedreplaceExisting - if true, any existing job with the same group and name as the given job will be overwrittenjedis - a thread-safe Redis connectionorg.quartz.ObjectAlreadyExistsExceptionprotected Map<String,String> getStringDataMap(org.quartz.JobDataMap jobDataMap)
JobDataMap to a HashMap with String keys and valuesjobDataMap - the job data map to be convertedpublic org.quartz.JobDetail retrieveJob(org.quartz.JobKey jobKey,
T jedis)
throws org.quartz.JobPersistenceException,
ClassNotFoundException
jobKey - the job key detailing the identity of the job to be retrievedjedis - a thread-safe Redis connectionJobDetail of the desired joborg.quartz.JobPersistenceException - if the desired job does not existClassNotFoundExceptionpublic abstract boolean removeJob(org.quartz.JobKey jobKey,
T jedis)
throws org.quartz.JobPersistenceException
jobKey - the job to be removedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract void storeTrigger(org.quartz.spi.OperableTrigger trigger,
boolean replaceExisting,
T jedis)
throws org.quartz.JobPersistenceException
trigger - the trigger to be storedreplaceExisting - true if an existing trigger with the same identity should be replacedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionorg.quartz.ObjectAlreadyExistsExceptionpublic boolean removeTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
throws org.quartz.JobPersistenceException,
ClassNotFoundException
Trigger with the given key.
If the associated job is non-durable and has no triggers after the given trigger is removed, the job will be
removed, as well.triggerKey - the key of the trigger to be removedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionprotected abstract boolean removeTrigger(org.quartz.TriggerKey triggerKey,
boolean removeNonDurableJob,
T jedis)
throws org.quartz.JobPersistenceException,
ClassNotFoundException
Trigger with the given key.triggerKey - the key of the trigger to be removedremoveNonDurableJob - if true, the job associated with the given trigger will be removed if it is non-durable
and has no other triggersjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionpublic boolean replaceTrigger(org.quartz.TriggerKey triggerKey,
org.quartz.spi.OperableTrigger newTrigger,
T jedis)
throws org.quartz.JobPersistenceException,
ClassNotFoundException
Trigger with the
given key, and store the new given one - which must be associated
with the same job.triggerKey - the key of the trigger to be replacednewTrigger - the replacement triggerjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionpublic org.quartz.spi.OperableTrigger retrieveTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
throws org.quartz.JobPersistenceException
triggerKey - the trigger keyjedis - a thread-safe Redis connectionOperableTrigger if it exists; null if it does notorg.quartz.JobPersistenceException - if the job associated with the retrieved trigger does not existpublic List<org.quartz.spi.OperableTrigger> getTriggersForJob(org.quartz.JobKey jobKey, T jedis) throws org.quartz.JobPersistenceException
jobKey - the job for which to retrieve triggersjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract boolean unsetTriggerState(String triggerHashKey, T jedis) throws org.quartz.JobPersistenceException
triggerHashKey - the redis key of the desired trigger hashjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceException - if the unset operation failedpublic boolean setTriggerState(RedisTriggerState state, double score, String triggerHashKey, T jedis) throws org.quartz.JobPersistenceException
state - the new state to be setscore - the trigger's next fire timetriggerHashKey - the trigger hash keyjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceException - if the set operation failspublic boolean checkExists(org.quartz.JobKey jobKey,
T jedis)
jobKey - the key of the desired jobjedis - a thread-safe Redis connectionpublic boolean checkExists(org.quartz.TriggerKey triggerKey,
T jedis)
triggerKey - the key of the desired triggerjedis - a thread-safe Redis connectionpublic abstract void storeCalendar(String name, org.quartz.Calendar calendar, boolean replaceExisting, boolean updateTriggers, T jedis) throws org.quartz.JobPersistenceException
Calendarname - the name of the calendarcalendar - the calendar object to be storedreplaceExisting - if true, any existing calendar with the same name will be overwrittenupdateTriggers - if true, any existing triggers associated with the calendar will be updatedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract boolean removeCalendar(String calendarName, T jedis) throws org.quartz.JobPersistenceException
Calendar with the given name.calendarName - the name of the calendar to be removedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic org.quartz.Calendar retrieveCalendar(String name, T jedis) throws org.quartz.JobPersistenceException
name - the name of the calendar to be retrievedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic int getNumberOfJobs(T jedis)
jedis - a thread-safe Redis connectionpublic int getNumberOfTriggers(T jedis)
jedis - a thread-safe Redis connectionpublic int getNumberOfCalendars(T jedis)
jedis - a thread-safe Redis connectionpublic abstract Set<org.quartz.JobKey> getJobKeys(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> matcher, T jedis)
Job s that have the given group name.matcher - the matcher with which to compare group namesjedis - a thread-safe Redis connectionpublic abstract Set<org.quartz.TriggerKey> getTriggerKeys(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher, T jedis)
Trigger s that have the given group name.matcher - the matcher with which to compare group namesjedis - a thread-safe Redis connectionpublic List<String> getJobGroupNames(T jedis)
Job groups.jedis - a thread-safe Redis connectionpublic List<String> getTriggerGroupNames(T jedis)
Trigger groups.jedis - a thread-safe Redis connectionpublic List<String> getCalendarNames(T jedis)
Calendar s in the JobStore.jedis - a thread-safe Redis connectionpublic abstract org.quartz.Trigger.TriggerState getTriggerState(org.quartz.TriggerKey triggerKey,
T jedis)
Trigger.triggerKey - the key of the desired triggerjedis - a thread-safe Redis connectionpublic abstract void pauseTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
throws org.quartz.JobPersistenceException
triggerKey - the key of the trigger to be pausedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceException - if the desired trigger does not existpublic abstract Collection<String> pauseTriggers(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher, T jedis) throws org.quartz.JobPersistenceException
Triggers in the given group.matcher - matcher for the trigger groups to be pausedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic void pauseJob(org.quartz.JobKey jobKey,
T jedis)
throws org.quartz.JobPersistenceException
jobKey - the key of the job to be pausedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract Collection<String> pauseJobs(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> groupMatcher, T jedis) throws org.quartz.JobPersistenceException
Jobs in the given group - by pausing all of their
Triggers.groupMatcher - the mather which will determine which job group should be pausedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract void resumeTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
throws org.quartz.JobPersistenceException
TriggertriggerKey - the key of the trigger to be resumedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionprotected boolean applyMisfire(org.quartz.spi.OperableTrigger trigger,
T jedis)
throws org.quartz.JobPersistenceException
SchedulerSignaler and update the trigger.trigger - the trigger to check for misfirejedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract Collection<String> resumeTriggers(org.quartz.impl.matchers.GroupMatcher<org.quartz.TriggerKey> matcher, T jedis) throws org.quartz.JobPersistenceException
Triggers in the given group.matcher - matcher for the trigger groups to be resumedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic Set<String> getPausedTriggerGroups(T jedis)
jedis - a thread-safe Redis connectionpublic void resumeJob(org.quartz.JobKey jobKey,
T jedis)
throws org.quartz.JobPersistenceException
Job with the given key.jobKey - the key of the job to be resumedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract Collection<String> resumeJobs(org.quartz.impl.matchers.GroupMatcher<org.quartz.JobKey> matcher, T jedis) throws org.quartz.JobPersistenceException
Jobs in the given group.matcher - the matcher with which to compare job group namesjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic void pauseAll(T jedis) throws org.quartz.JobPersistenceException
pauseTriggerGroup(group) on every group.jedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic void resumeAll(T jedis) throws org.quartz.JobPersistenceException
resumeTriggerGroup(group) on every group.jedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionprotected void releaseOrphanedTriggers(RedisTriggerState currentState, RedisTriggerState newState, T jedis) throws org.quartz.JobPersistenceException
currentState - the current state of the orphaned triggernewState - the new state of the orphaned triggerjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionprotected void releaseTriggersCron(T jedis) throws org.quartz.JobPersistenceException
jedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionprotected long getLastTriggersReleaseTime(T jedis)
jedis - a thread-safe Redis connectionprotected void settLastTriggerReleaseTime(long time,
T jedis)
time - a unix timestamp in millisecondsjedis - a thread-safe Redis connectionprotected boolean isJobConcurrentExecutionDisallowed(Class<? extends org.quartz.Job> jobClass)
jobClass - the job class in questionprotected boolean lockTrigger(org.quartz.TriggerKey triggerKey,
T jedis)
triggerKey - the key of the desired triggerjedis - a thread-safe Redis connectionpublic List<org.quartz.spi.OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow, T jedis) throws org.quartz.JobPersistenceException, ClassNotFoundException
noLaterThan - If > 0, the JobStore should only return a Trigger
that will fire no later than the time represented in this value as
milliseconds.maxCount - the maximum number of triggers to returntimeWindow - the time window within which the triggers must fire nextjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionpublic void releaseAcquiredTrigger(org.quartz.spi.OperableTrigger trigger,
T jedis)
throws org.quartz.JobPersistenceException
JobStore that the scheduler no longer plans to
fire the given Trigger, that it had previously acquired
(reserved).trigger - the trigger to be releasedjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionpublic abstract List<org.quartz.spi.TriggerFiredResult> triggersFired(List<org.quartz.spi.OperableTrigger> triggers, T jedis) throws org.quartz.JobPersistenceException, ClassNotFoundException
JobStore that the scheduler is now firing the
given Trigger (executing its associated Job),
that it had previously acquired (reserved).triggers - a list of triggersjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionprotected boolean isPersistJobDataAfterExecution(Class<? extends org.quartz.Job> jobClass)
public abstract void triggeredJobComplete(org.quartz.spi.OperableTrigger trigger,
org.quartz.JobDetail jobDetail,
org.quartz.Trigger.CompletedExecutionInstruction triggerInstCode,
T jedis)
throws org.quartz.JobPersistenceException,
ClassNotFoundException
JobStore that the scheduler has completed the
firing of the given Trigger (and the execution of its
associated Job completed, threw an exception, or was vetoed),
and that the JobDataMap
in the given JobDetail should be updated if the Job
is stateful.trigger - the trigger which was completedjobDetail - the job which was completedtriggerInstCode - the status of the completed jobjedis - a thread-safe Redis connectionorg.quartz.JobPersistenceExceptionClassNotFoundExceptionprotected boolean isNullOrEmpty(String string)
string - a string to checkCopyright © 2018. All rights reserved.