Java 类org.quartz.impl.matchers.StringMatcher 实例源码

项目:lams    文件:DefaultClusteredJobStore.java   
/**
 * <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;
}
项目:lams    文件:DefaultClusteredJobStore.java   
/**
 * <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;
}
项目:lams    文件:RAMJobStore.java   
/**
 * <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;
}
项目:lams    文件:RAMJobStore.java   
/**
 * <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;
}
项目:lams    文件:RemoteMBeanScheduler.java   
/**
 * <p>
 * Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
 * passing the <code>SchedulingContext</code> associated with this
 * instance.
 * </p>
 */
@SuppressWarnings("unchecked")
public Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws SchedulerException {
    if (matcher.getCompareWithOperator().equals(StringMatcher.StringOperatorName.EQUALS)) {
        List<JobKey> keys = (List<JobKey>)invoke(
                "getJobNames",
                new Object[] { matcher.getCompareToValue() },
                new String[] { String.class.getName() });

        return new HashSet<JobKey>(keys);
    } else {
        throw new SchedulerException("Only equals matcher are supported for looking up JobKeys");
    }
}
项目:lams    文件:JobStoreSupport.java   
/**
 * <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);
    }
}
项目:quartz-scheduler-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public Collection<String> pauseTriggers(GroupMatcher<TriggerKey> matcher)
  throws JobPersistenceException {

  List<String> pausedGroups = new LinkedList<>();
  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;
}
项目:quartz-scheduler-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public Collection<String> pauseJobs(GroupMatcher<JobKey> groupMatcher)
  throws JobPersistenceException {

  List<String> pausedGroups = new LinkedList<>();
  StringMatcher.StringOperatorName operator = groupMatcher
      .getCompareWithOperator();
  switch (operator) {
    case EQUALS:
      if (pausedJobGroups.add(groupMatcher.getCompareToValue())) {
        pausedGroups.add(groupMatcher.getCompareToValue());
      }
      break;
    default:
      for (String jobGroup : jobsByGroup.keySet()) {
        if (operator.evaluate(jobGroup, groupMatcher.getCompareToValue())) {
          if (pausedJobGroups.add(jobGroup)) {
            pausedGroups.add(jobGroup);
          }
        }
      }
  }

  for (String groupName : pausedGroups) {
    for (JobKey jobKey : getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
      pauseJob(jobKey);
    }
  }
  return pausedGroups;
}
项目:quartz-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public Collection<String> pauseTriggers(GroupMatcher<TriggerKey> matcher)
    throws JobPersistenceException {
  List<String> pausedGroups = new LinkedList<>();
  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;
}
项目:quartz-hazelcast-jobstore    文件:HazelcastJobStore.java   
@Override
public Collection<String> pauseJobs(GroupMatcher<JobKey> groupMatcher)
    throws JobPersistenceException {
  List<String> pausedGroups = new LinkedList<>();
  StringMatcher.StringOperatorName operator = groupMatcher
      .getCompareWithOperator();
  switch (operator) {
    case EQUALS:
      if (pausedJobGroups.add(groupMatcher.getCompareToValue())) {
        pausedGroups.add(groupMatcher.getCompareToValue());
      }
      break;
    default:
      for (String jobGroup : jobsByGroup.keySet()) {
        if (operator.evaluate(jobGroup, groupMatcher.getCompareToValue())) {
          if (pausedJobGroups.add(jobGroup)) {
            pausedGroups.add(jobGroup);
          }
        }
      }
  }

  for (String groupName : pausedGroups) {
    for (JobKey jobKey : getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
      pauseJob(jobKey);
    }
  }
  return pausedGroups;
}
项目:lams    文件:RAMJobStore.java   
/**
 * <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;
}
项目:lams    文件:RAMJobStore.java   
/**
 * <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;
}
项目:lams    文件:StdJDBCDelegate.java   
protected boolean isMatcherEquals(final GroupMatcher<?> matcher) {
    return matcher.getCompareWithOperator().equals(StringMatcher.StringOperatorName.EQUALS);
}