本文整理汇总了Java中org.quartz.impl.matchers.GroupMatcher类的典型用法代码示例。如果您正苦于以下问题:Java GroupMatcher类的具体用法?Java GroupMatcher怎么用?Java GroupMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupMatcher类属于org.quartz.impl.matchers包,在下文中一共展示了GroupMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllJob
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* 获取所有计划中的任务列表
*
* @return
* @throws SchedulerException
*/
public List<ScheduleJob> getAllJob() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();
Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
List<ScheduleJob> jobList = new ArrayList<ScheduleJob>();
for (JobKey jobKey : jobKeys) {
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers) {
ScheduleJob job = new ScheduleJob();
job.setName(jobKey.getName());
job.setGroup(jobKey.getGroup());
job.setDescription("触发器:" + trigger.getKey());
Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger) trigger;
String cronExpression = cronTrigger.getCronExpression();
job.setCron(cronExpression);
}
jobList.add(job);
}
}
return jobList;
}
示例2: getScheduledJobIds
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Set<String> getScheduledJobIds() throws KairosDBException
{
Set<String> scheduledJobs = new HashSet<String>();
try
{
for (String groupName : scheduler.getJobGroupNames())
{
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)))
{
scheduledJobs.add(jobKey.getName());
}
}
}
catch (SchedulerException e)
{
throw new KairosDBException("Could not get scheduled jobs." + e);
}
return scheduledJobs;
}
示例3: pauseJobs
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <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() });
}
示例4: resumeTriggers
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <p>
* Resume (un-pause) all of the <code>{@link Trigger}s</code> in the given group.
* </p>
* <p>
* If any <code>Trigger</code> missed one or more fire-times, then the <code>Trigger</code>'s misfire instruction will
* be applied.
* </p>
*/
@Override
public Collection<String> resumeTriggers(GroupMatcher<TriggerKey> matcher) throws JobPersistenceException {
Collection<String> groups = new HashSet<String>();
lock();
try {
Set<TriggerKey> triggerKeys = getTriggerKeys(matcher);
for (TriggerKey triggerKey : triggerKeys) {
TriggerWrapper tw = triggerFacade.get(triggerKey);
if (tw != null) {
String jobGroup = tw.getJobKey().getGroup();
if (jobFacade.pausedGroupsContain(jobGroup)) {
continue;
}
groups.add(triggerKey.getGroup());
}
resumeTrigger(triggerKey);
}
triggerFacade.removeAllPausedGroups(groups);
} finally {
unlock();
}
return groups;
}
示例5: resumeAll
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <p>
* Resume (un-pause) all triggers - equivalent of calling <code>resumeTriggerGroup(group)</code> on every group.
* </p>
* <p>
* If any <code>Trigger</code> missed one or more fire-times, then the <code>Trigger</code>'s misfire instruction will
* be applied.
* </p>
*
* @see #pauseAll()
*/
@Override
public void resumeAll() throws JobPersistenceException {
lock();
try {
jobFacade.clearPausedJobGroups();
List<String> names = getTriggerGroupNames();
for (String name : names) {
resumeTriggers(GroupMatcher.triggerGroupEquals(name));
}
} finally {
unlock();
}
}
示例6: resumeTriggers
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <p>
* Resume (un-pause) all of the <code>{@link Trigger}s</code> in the
* given group.
* </p>
*
* <p>
* If any <code>Trigger</code> missed one or more fire-times, then the
* <code>Trigger</code>'s misfire instruction will be applied.
* </p>
*
*/
public List<String> resumeTriggers(GroupMatcher<TriggerKey> matcher) {
Set<String> groups = new HashSet<String>();
synchronized (lock) {
Set<TriggerKey> keys = getTriggerKeys(matcher);
for (TriggerKey triggerKey: keys) {
groups.add(triggerKey.getGroup());
if(triggersByKey.get(triggerKey) != null) {
String jobGroup = triggersByKey.get(triggerKey).jobKey.getGroup();
if(pausedJobGroups.contains(jobGroup)) {
continue;
}
}
resumeTrigger(triggerKey);
}
for (String group : groups) {
pausedTriggerGroups.remove(group);
}
}
return new ArrayList<String>(groups);
}
示例7: getTaskList
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* Returns all Jobs from the Scheduler.
*
* @return all Jobs from the Scheduler.
* @throws FrameworkException in case any internal error occurs.
* @throws ApplicationExceptions Indicates application error(s).
*/
private List<ScheduledTask> getTaskList() throws FrameworkException,
ApplicationExceptions {
List<ScheduledTask> tasks = null;
try {
final List<String> names = scheduler.getJobGroupNames();
if (names != null && 0 < names.size()) {
tasks = new LinkedList<ScheduledTask>();
for (final String groupName : names) {
for (final JobKey jobKey : scheduler.getJobKeys(GroupMatcher
.jobGroupEquals(groupName))) {
final JobDetail jobDetail = scheduler.getJobDetail(jobKey);
final List<? extends Trigger> triggers = scheduler
.getTriggersOfJob(jobKey);
final ScheduledTask task = jobAndTriggerToTask(jobDetail, triggers);
tasks.add(task);
}
}
}
return tasks;
} catch (SchedulerException e) {
LOGGER.error("Error in retriving Jobs from the Scheduler", e);
throw new JaffaSchedulerFrameworkException(
JaffaSchedulerFrameworkException.TASK_RETRIEVE_ERROR, null, e);
}
}
示例8: pauseAll
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <p>
* Pause all triggers - equivalent of calling <code>pauseTriggerGroup(group)</code>
* on every group.
* </p>
*
* <p>
* When <code>resumeAll()</code> is called (to un-pause), trigger misfire
* instructions WILL be applied.
* </p>
*
* @see #resumeAll(Connection)
* @see #pauseTriggerGroup(java.sql.Connection, org.quartz.impl.matchers.GroupMatcher)
*/
public void pauseAll(Connection conn)
throws JobPersistenceException {
List<String> names = getTriggerGroupNames(conn);
for (String name: names) {
pauseTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name));
}
try {
if (!getDelegate().isTriggerGroupPaused(conn, ALL_GROUPS_PAUSED)) {
getDelegate().insertPausedTriggerGroup(conn, ALL_GROUPS_PAUSED);
}
} catch (SQLException e) {
throw new JobPersistenceException(
"Couldn't pause all trigger groups: " + e.getMessage(), e);
}
}
示例9: resumeAll
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* protected
* <p>
* Resume (un-pause) all triggers - equivalent of calling <code>resumeTriggerGroup(group)</code>
* on every group.
* </p>
*
* <p>
* If any <code>Trigger</code> missed one or more fire-times, then the
* <code>Trigger</code>'s misfire instruction will be applied.
* </p>
*
* @see #pauseAll(Connection)
*/
public void resumeAll(Connection conn)
throws JobPersistenceException {
List<String> names = getTriggerGroupNames(conn);
for (String name: names) {
resumeTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name));
}
try {
getDelegate().deletePausedTriggerGroup(conn, ALL_GROUPS_PAUSED);
} catch (SQLException e) {
throw new JobPersistenceException(
"Couldn't resume all trigger groups: " + e.getMessage(), e);
}
}
示例10: updateTriggerGroupStateFromOtherState
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
/**
* <p>
* Update all of the triggers of the given group to the given new state, if
* they are in the given old state.
* </p>
*
* @param conn
* the DB connection
* @param matcher
* the groupMatcher to evaluate the triggers against
* @param newState
* the new state for the trigger group
* @param oldState
* the old state the triggers must be in
* @return int the number of rows updated
* @throws SQLException
*/
public int updateTriggerGroupStateFromOtherState(Connection conn,
GroupMatcher<TriggerKey> matcher, String newState, String oldState)
throws SQLException {
PreparedStatement ps = null;
try {
ps = conn
.prepareStatement(rtp(UPDATE_TRIGGER_GROUP_STATE_FROM_STATE));
ps.setString(1, newState);
ps.setString(2, toSqlLikeClause(matcher));
ps.setString(3, oldState);
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例11: selectTriggerGroups
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
public List<String> selectTriggerGroups(Connection conn, GroupMatcher<TriggerKey> matcher) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(rtp(SELECT_TRIGGER_GROUPS_FILTERED));
ps.setString(1, toSqlLikeClause(matcher));
rs = ps.executeQuery();
LinkedList<String> list = new LinkedList<String>();
while (rs.next()) {
list.add(rs.getString(1));
}
return list;
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例12: getAllJobList
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
public List<ScheduleJob> getAllJobList(){
List<ScheduleJob> jobList = new ArrayList<>();
try {
GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();
Set<JobKey> jobKeySet = scheduler.getJobKeys(matcher);
for (JobKey jobKey : jobKeySet){
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers){
ScheduleJob scheduleJob = new ScheduleJob();
this.wrapScheduleJob(scheduleJob,scheduler,jobKey,trigger);
jobList.add(scheduleJob);
}
}
} catch (SchedulerException e) {
e.printStackTrace();
}
return jobList;
}
示例13: getTriggersForGroup
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
private List<TriggerDefinition> getTriggersForGroup(GroupMatcher<TriggerKey> groupMatcher) {
try {
return scheduler.getTriggerKeys(groupMatcher).stream()
.map(this::getTriggerSafe)
.filter(trigger -> trigger != null)
.map(quartzToCronyxSelector::convert)
.map(this::enhanceTriggerDefinition)
.collect(Collectors.toList());
} catch (SchedulerException e) {
throw new SchedulingException(e);
}
}
示例14: getJobNames
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
public List<String> getJobNames(String groupName) throws Exception {
try {
List<String> jobNames = new ArrayList<String>();
for(JobKey key: scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
jobNames.add(key.getName());
}
return jobNames;
} catch (Exception e) {
throw newPlainException(e);
}
}
示例15: getAllJobDetail
import org.quartz.impl.matchers.GroupMatcher; //导入依赖的package包/类
public List<TaskScheduled> getAllJobDetail() {
List<TaskScheduled> result = new LinkedList<TaskScheduled>();
try {
GroupMatcher<JobKey> matcher = GroupMatcher.jobGroupContains("");
Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);
for (JobKey jobKey : jobKeys) {
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
for (Trigger trigger : triggers) {
TaskScheduled job = new TaskScheduled();
job.setTaskName(jobKey.getName());
job.setTaskGroup(jobKey.getGroup());
TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setStatus(triggerState.name());
if (trigger instanceof CronTrigger) {
CronTrigger cronTrigger = (CronTrigger)trigger;
String cronExpression = cronTrigger.getCronExpression();
job.setTaskCron(cronExpression);
}
job.setPreviousFireTime(trigger.getPreviousFireTime());
job.setNextFireTime(trigger.getNextFireTime());
JobDataMap jobDataMap = trigger.getJobDataMap();
job.setTaskType(jobDataMap.getString("taskType"));
job.setTargetSystem(jobDataMap.getString("targetSystem"));
job.setTargetObject(jobDataMap.getString("targetObject"));
job.setTargetMethod(jobDataMap.getString("targetMethod"));
job.setContactName(jobDataMap.getString("contactName"));
job.setContactEmail(jobDataMap.getString("contactEmail"));
job.setTaskDesc(jobDetail.getDescription());
String jobClass = jobDetail.getJobClass().getSimpleName();
if (jobClass.equals("StatefulJob")) {
job.setJobType("statefulJob");
} else if (jobClass.equals("DefaultJob")) {
job.setJobType("job");
}
result.add(job);
}
}
} catch (Exception e) {
logger.error("Try to load All JobDetail cause error : ", e);
}
return result;
}