Java Code Examples for org.quartz.impl.matchers.GroupMatcher#getCompareWithOperator()
The following examples show how to use
org.quartz.impl.matchers.GroupMatcher#getCompareWithOperator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultClusteredJobStore.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Pause all of the <code>{@link Trigger}s</code> in the given group. * </p> * <p> * The JobStore should "remember" that the group is paused, and impose the pause on any new triggers that are added to * the group while the group is paused. * </p> */ @Override public Collection<String> pauseTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException { HashSet<String> pausedGroups = new HashSet<String>(); lock(); try { Set<TriggerKey> triggerKeys = getTriggerKeys(matcher); for (TriggerKey key : triggerKeys) { triggerFacade.addPausedGroup(key.getGroup()); pausedGroups.add(key.getGroup()); pauseTrigger(key); } // make sure to account for an exact group match for a group that doesn't yet exist StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); if (operator.equals(StringOperatorName.EQUALS)) { triggerFacade.addPausedGroup(matcher.getCompareToValue()); pausedGroups.add(matcher.getCompareToValue()); } } finally { unlock(); } return pausedGroups; }
Example 2
Source File: DefaultClusteredJobStore.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Pause all of the <code>{@link org.quartz.JobDetail}s</code> in the given group - by pausing all of their * <code>Trigger</code>s. * </p> * <p> * The JobStore should "remember" that the group is paused, and impose the pause on any new jobs that are added to the * group while the group is paused. * </p> */ @Override public Collection<String> pauseJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException { Collection<String> pausedGroups = new HashSet<String>(); lock(); try { Set<JobKey> jobKeys = getJobKeys(matcher); for (JobKey jobKey : jobKeys) { for (OperableTrigger trigger : getTriggersForJob(jobKey)) { pauseTrigger(trigger.getKey()); } pausedGroups.add(jobKey.getGroup()); } // make sure to account for an exact group match for a group that doesn't yet exist StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); if (operator.equals(StringOperatorName.EQUALS)) { jobFacade.addPausedGroup(matcher.getCompareToValue()); pausedGroups.add(matcher.getCompareToValue()); } } finally { unlock(); } return pausedGroups; }
Example 3
Source File: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
@Override public Collection<String> pauseJobs(GroupMatcher<JobKey> groupMatcher) throws JobPersistenceException { if (groupMatcher.getCompareWithOperator() != StringOperatorName.EQUALS) throw new UnsupportedOperationException(); Set<String> pausedJobGroups = new HashSet<>(); String jobGroupSetKey = createJobGroupSetKey(groupMatcher.getCompareToValue()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if (jedis.sadd(PAUSED_JOB_GROUPS_SET, jobGroupSetKey) > 0) { pausedJobGroups.add(jobGroupSetKey); Set<String> jobs = jedis.smembers(jobGroupSetKey); for (String job : jobs) pauseJob(job, jedis); } } catch (Exception ex) { log.error("could not pause job group: " + jobGroupSetKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } return pausedJobGroups; }
Example 4
Source File: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
@Override public Collection<String> pauseTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException { if (matcher.getCompareWithOperator() != StringOperatorName.EQUALS) throw new UnsupportedOperationException(); Set<String> pausedTriggerdGroups = new HashSet<>(); String triggerGroupSetKey = createTriggerGroupSetKey(matcher.getCompareToValue()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if (pauseTriggers(triggerGroupSetKey, jedis)) pausedTriggerdGroups.add(triggerGroupSetKey); // as we currently support only EQUALS matcher's operator, the paused group set will consist of one paused group only. } catch (Exception ex) { log.error("could not pause triggers group: " + triggerGroupSetKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } return pausedTriggerdGroups; }
Example 5
Source File: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
@Override public Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException { if (matcher.getCompareWithOperator() != StringOperatorName.EQUALS) throw new UnsupportedOperationException(); Set<TriggerKey> triggerKeys = new HashSet<>(); String triggerGroupSetKey = createTriggerGroupSetKey(matcher.getCompareToValue()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if(jedis.sismember(TRIGGER_GROUPS_SET, triggerGroupSetKey)) { Set<String> triggers = jedis.smembers(triggerGroupSetKey); for(String trigger : triggers) triggerKeys.add(new TriggerKey(trigger.split(":")[2], trigger.split(":")[1])); } } catch (Exception ex) { log.error("could not get trigger keys for trigger group: " + triggerGroupSetKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } return triggerKeys; }
Example 6
Source File: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
@Override public Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws JobPersistenceException { if (matcher.getCompareWithOperator() != StringOperatorName.EQUALS) throw new UnsupportedOperationException(); Set<JobKey> jobKeys = new HashSet<>(); String jobGroupSetKey = createJobGroupSetKey(matcher.getCompareToValue()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if(jedis.sismember(JOB_GROUPS_SET, jobGroupSetKey)) { Set<String> jobs = jedis.smembers(jobGroupSetKey); for(String job : jobs) jobKeys.add(new JobKey(job.split(":")[2], job.split(":")[1])); } } catch (Exception ex) { log.error("could not get job keys for job group: " + jobGroupSetKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } return jobKeys; }
Example 7
Source File: StdJDBCDelegate.java From lams with GNU General Public License v2.0 | 6 votes |
protected String toSqlLikeClause(final GroupMatcher<?> matcher) { String groupName; switch(matcher.getCompareWithOperator()) { case EQUALS: groupName = matcher.getCompareToValue(); break; case CONTAINS: groupName = "%" + matcher.getCompareToValue() + "%"; break; case ENDS_WITH: groupName = "%" + matcher.getCompareToValue(); break; case STARTS_WITH: groupName = matcher.getCompareToValue() + "%"; break; case ANYTHING: groupName = "%"; break; default: throw new UnsupportedOperationException("Don't know how to translate " + matcher.getCompareWithOperator() + " into SQL"); } return groupName; }
Example 8
Source File: RemoteMBeanScheduler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>, * passing the <code>SchedulingContext</code> associated with this * instance. * </p> */ public void pauseJobs(GroupMatcher<JobKey> matcher) throws SchedulerException { String operation = null; switch (matcher.getCompareWithOperator()) { case EQUALS: operation = "pauseJobGroup"; break; case STARTS_WITH: operation = "pauseJobsStartingWith"; break; case ENDS_WITH: operation = "pauseJobsEndingWith"; break; case CONTAINS: operation = "pauseJobsContaining"; case ANYTHING: operation = "pauseJobsAll"; } invoke( operation, new Object[] { matcher.getCompareToValue() }, new String[] { String.class.getName() }); }
Example 9
Source File: RemoteMBeanScheduler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>, * passing the <code>SchedulingContext</code> associated with this * instance. * </p> */ public void resumeJobs(GroupMatcher<JobKey> matcher) throws SchedulerException { String operation = null; switch (matcher.getCompareWithOperator()) { case EQUALS: operation = "resumeJobGroup"; break; case STARTS_WITH: operation = "resumeJobsStartingWith"; break; case ENDS_WITH: operation = "resumeJobsEndingWith"; break; case CONTAINS: operation = "resumeJobsContaining"; case ANYTHING: operation = "resumeJobsAll"; } invoke( operation, new Object[] { matcher.getCompareToValue() }, new String[] { String.class.getName() }); }
Example 10
Source File: RedisJobStore.java From redis-quartz with MIT License | 5 votes |
@Override public Collection<String> resumeJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException { if (matcher.getCompareWithOperator() != StringOperatorName.EQUALS) throw new UnsupportedOperationException(); Set<String> resumedJobGroups = new HashSet<>(); String jobGroupSetKey = createJobGroupSetKey(matcher.getCompareToValue()); try (Jedis jedis = pool.getResource()) { lockPool.acquire(); if(!jedis.sismember(JOB_GROUPS_SET, jobGroupSetKey)) throw new JobPersistenceException("job group: " + jobGroupSetKey + " does not exist"); if (jedis.srem(PAUSED_JOB_GROUPS_SET, jobGroupSetKey) > 0) resumedJobGroups.add(jobGroupSetKey); Set<String> jobs = jedis.smembers(jobGroupSetKey); for (String job : jobs) resumeJob(new JobKey(job.split(":")[2], job.split(":")[1]), jedis); } catch (Exception ex) { log.error("could not resume job group: " + jobGroupSetKey, ex); throw new JobPersistenceException(ex.getMessage(), ex.getCause()); } finally { lockPool.release(); } return resumedJobGroups; }
Example 11
Source File: DefaultClusteredJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Get the names of all of the <code>{@link org.quartz.Job}</code> s that have the given group name. * </p> */ @Override public Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws JobPersistenceException { lock(); try { Set<String> matchingGroups = new HashSet<String>(); switch (matcher.getCompareWithOperator()) { case EQUALS: matchingGroups.add(matcher.getCompareToValue()); break; default: for (String group : jobFacade.getAllGroupNames()) { if (matcher.getCompareWithOperator().evaluate(group, matcher.getCompareToValue())) { matchingGroups.add(group); } } } Set<JobKey> out = new HashSet<JobKey>(); for (String matchingGroup : matchingGroups) { Set<String> grpJobNames = toolkitDSHolder.getOrCreateJobsGroupMap(matchingGroup); for (String jobName : grpJobNames) { JobKey jobKey = new JobKey(jobName, matchingGroup); if (jobFacade.containsKey(jobKey)) { out.add(jobKey); } } } return out; } finally { unlock(); } }
Example 12
Source File: JobStoreSupport.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Pause all of the <code>{@link org.quartz.Trigger}s</code> matching the * given groupMatcher. * </p> * * @see #resumeTriggerGroup(java.sql.Connection, org.quartz.impl.matchers.GroupMatcher) */ public Set<String> pauseTriggerGroup(Connection conn, GroupMatcher<TriggerKey> matcher) throws JobPersistenceException { try { getDelegate().updateTriggerGroupStateFromOtherStates( conn, matcher, STATE_PAUSED, STATE_ACQUIRED, STATE_WAITING, STATE_WAITING); getDelegate().updateTriggerGroupStateFromOtherState( conn, matcher, STATE_PAUSED_BLOCKED, STATE_BLOCKED); List<String> groups = getDelegate().selectTriggerGroups(conn, matcher); // make sure to account for an exact group match for a group that doesn't yet exist StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); if (operator.equals(StringOperatorName.EQUALS) && !groups.contains(matcher.getCompareToValue())) { groups.add(matcher.getCompareToValue()); } for (String group : groups) { if (!getDelegate().isTriggerGroupPaused(conn, group)) { getDelegate().insertPausedTriggerGroup(conn, group); } } return new HashSet<String>(groups); } catch (SQLException e) { throw new JobPersistenceException("Couldn't pause trigger group '" + matcher + "': " + e.getMessage(), e); } }
Example 13
Source File: RemoteMBeanScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>, * passing the <code>SchedulingContext</code> associated with this * instance. * </p> */ public void resumeTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException { String operation = null; switch (matcher.getCompareWithOperator()) { case EQUALS: operation = "resumeTriggerGroup"; break; case CONTAINS: operation = "resumeTriggersContaining"; break; case STARTS_WITH: operation = "resumeTriggersStartingWith"; break; case ENDS_WITH: operation = "resumeTriggersEndingWith"; case ANYTHING: operation = "resumeTriggersAll"; } if (operation != null) { invoke( operation, new Object[] { matcher.getCompareToValue() }, new String[] { String.class.getName() }); } else { throw new SchedulerException("Unsupported GroupMatcher kind for resuming triggers: " + matcher.getCompareWithOperator()); } }
Example 14
Source File: RemoteMBeanScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>, * passing the <code>SchedulingContext</code> associated with this * instance. * </p> */ public void pauseTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException { String operation = null; switch (matcher.getCompareWithOperator()) { case EQUALS: operation = "pauseTriggerGroup"; break; case CONTAINS: operation = "pauseTriggersContaining"; break; case STARTS_WITH: operation = "pauseTriggersStartingWith"; break; case ENDS_WITH: operation = "pauseTriggersEndingWith"; case ANYTHING: operation = "pauseTriggersAll"; } if (operation != null) { invoke( operation, new Object[] { matcher.getCompareToValue() }, new String[] { String.class.getName() }); } else { throw new SchedulerException("Unsupported GroupMatcher kind for pausing triggers: " + matcher.getCompareWithOperator()); } }
Example 15
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Pause all of the <code>{@link org.quartz.JobDetail}s</code> in the * given group - by pausing all of their <code>Trigger</code>s. * </p> * * * <p> * The JobStore should "remember" that the group is paused, and impose the * pause on any new jobs that are added to the group while the group is * paused. * </p> */ public List<String> pauseJobs(GroupMatcher<JobKey> matcher) { List<String> pausedGroups = new LinkedList<String>(); synchronized (lock) { StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); switch (operator) { case EQUALS: if (pausedJobGroups.add(matcher.getCompareToValue())) { pausedGroups.add(matcher.getCompareToValue()); } break; default : for (String group : jobsByGroup.keySet()) { if(operator.evaluate(group, matcher.getCompareToValue())) { if (pausedJobGroups.add(group)) { pausedGroups.add(group); } } } } for (String groupName : pausedGroups) { for (JobKey jobKey: getJobKeys(GroupMatcher.jobGroupEquals(groupName))) { List<OperableTrigger> triggersOfJob = getTriggersForJob(jobKey); for (OperableTrigger trigger: triggersOfJob) { pauseTrigger(trigger.getKey()); } } } } return pausedGroups; }
Example 16
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Pause all of the known <code>{@link Trigger}s</code> matching. * </p> * * <p> * The JobStore should "remember" the groups paused, and impose the * pause on any new triggers that are added to one of these groups while the group is * paused. * </p> * */ public List<String> pauseTriggers(GroupMatcher<TriggerKey> matcher) { List<String> pausedGroups; synchronized (lock) { pausedGroups = new LinkedList<String>(); StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); switch (operator) { case EQUALS: if(pausedTriggerGroups.add(matcher.getCompareToValue())) { pausedGroups.add(matcher.getCompareToValue()); } break; default : for (String group : triggersByGroup.keySet()) { if(operator.evaluate(group, matcher.getCompareToValue())) { if(pausedTriggerGroups.add(matcher.getCompareToValue())) { pausedGroups.add(group); } } } } for (String pausedGroup : pausedGroups) { Set<TriggerKey> keys = getTriggerKeys(GroupMatcher.triggerGroupEquals(pausedGroup)); for (TriggerKey key: keys) { pauseTrigger(key); } } } return pausedGroups; }
Example 17
Source File: DefaultClusteredJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Get the names of all of the <code>{@link org.quartz.Trigger}</code> s that have the given group name. * </p> */ @Override public Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException { lock(); try { Set<String> groupNames = new HashSet<String>(); switch (matcher.getCompareWithOperator()) { case EQUALS: groupNames.add(matcher.getCompareToValue()); break; default: for (String group : triggerFacade.allTriggersGroupNames()) { if (matcher.getCompareWithOperator().evaluate(group, matcher.getCompareToValue())) { groupNames.add(group); } } } Set<TriggerKey> out = new HashSet<TriggerKey>(); for (String groupName : groupNames) { Set<String> grpSet = toolkitDSHolder.getOrCreateTriggersGroupMap(groupName); for (String key : grpSet) { TriggerKey triggerKey = new TriggerKey(key, groupName); TriggerWrapper tw = triggerFacade.get(triggerKey); if (tw != null) { out.add(triggerKey); } } } return out; } finally { unlock(); } }
Example 18
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 4 votes |
/** * <p> * Get the names of all of the <code>{@link org.quartz.Trigger}</code> s * that match the given groupMatcher. * </p> */ public Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) { Set<TriggerKey> outList = null; synchronized (lock) { StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); String compareToValue = matcher.getCompareToValue(); switch(operator) { case EQUALS: HashMap<TriggerKey, TriggerWrapper> grpMap = triggersByGroup.get(compareToValue); if (grpMap != null) { outList = new HashSet<TriggerKey>(); for (TriggerWrapper tw : grpMap.values()) { if (tw != null) { outList.add(tw.trigger.getKey()); } } } break; default: for (Map.Entry<String, HashMap<TriggerKey, TriggerWrapper>> entry : triggersByGroup.entrySet()) { if(operator.evaluate(entry.getKey(), compareToValue) && entry.getValue() != null) { if(outList == null) { outList = new HashSet<TriggerKey>(); } for (TriggerWrapper triggerWrapper : entry.getValue().values()) { if(triggerWrapper != null) { outList.add(triggerWrapper.trigger.getKey()); } } } } } } return outList == null ? Collections.<TriggerKey>emptySet() : outList; }
Example 19
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 4 votes |
/** * <p> * Get the names of all of the <code>{@link org.quartz.Job}</code> s that * match the given groupMatcher. * </p> */ public Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) { Set<JobKey> outList = null; synchronized (lock) { StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator(); String compareToValue = matcher.getCompareToValue(); switch(operator) { case EQUALS: HashMap<JobKey, JobWrapper> grpMap = jobsByGroup.get(compareToValue); if (grpMap != null) { outList = new HashSet<JobKey>(); for (JobWrapper jw : grpMap.values()) { if (jw != null) { outList.add(jw.jobDetail.getKey()); } } } break; default: for (Map.Entry<String, HashMap<JobKey, JobWrapper>> entry : jobsByGroup.entrySet()) { if(operator.evaluate(entry.getKey(), compareToValue) && entry.getValue() != null) { if(outList == null) { outList = new HashSet<JobKey>(); } for (JobWrapper jobWrapper : entry.getValue().values()) { if(jobWrapper != null) { outList.add(jobWrapper.jobDetail.getKey()); } } } } } } return outList == null ? java.util.Collections.<JobKey>emptySet() : outList; }