本文整理了Java中org.quartz.Scheduler.getJobNames()
方法的一些代码示例,展示了Scheduler.getJobNames()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.getJobNames()
方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:getJobNames
[英]Get the names of all the org.quartz.JobDetails
in the given group.
[中]获取给定组中所有org.quartz.JobDetails
的名称。
代码示例来源:origin: javamelody/javamelody
List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException {
final List<JobDetail> result = new ArrayList<JobDetail>();
for (final String jobGroupName : scheduler.getJobGroupNames()) {
for (final String jobName : scheduler.getJobNames(jobGroupName)) {
final JobDetail jobDetail;
try {
jobDetail = scheduler.getJobDetail(jobName, jobGroupName);
// le job peut être terminé et supprimé depuis la ligne ci-dessus
if (jobDetail != null) {
result.add(jobDetail);
}
} catch (final Exception e) {
// si les jobs sont persistés en base de données, il peut y avoir une exception
// dans getJobDetail, par exemple si la classe du job n'existe plus dans l'application
LOG.debug(e.toString(), e);
}
}
}
return result;
}
代码示例来源:origin: org.rhq/rhq-enterprise-server
public String[] getJobNames(String groupName) throws SchedulerException {
return scheduler.getJobNames(groupName);
}
代码示例来源:origin: org.rhq/rhq-enterprise-server
public String[] getJobNames(String groupName) throws SchedulerException {
return this.scheduler.getJobNames(groupName);
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1
Collection<JobRunnerKey> getJobRunnerKeys() {
try {
return transform(asList(getScheduler().getJobNames(QUARTZ_JOB_GROUP)), new Function<String, JobRunnerKey>() {
@SuppressWarnings("NullableProblems") // Guava should not have stuck @Nullable on this...
@Override
public JobRunnerKey apply(String jobName) {
return JobRunnerKey.of(jobName);
}
});
} catch (SchedulerException se) {
throw unchecked("Could not get the triggers from Quartz", se);
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public void reinitializeScheduledJobs() {
try {
for (String scheduledJobName : scheduler.getJobNames(SCHEDULED_GROUP)) {
if (scheduler.getTriggersOfJob(scheduledJobName, SCHEDULED_GROUP).length == 0) {
// jobs that have their own triggers will not be reinited
updateStatus(SCHEDULED_GROUP, scheduledJobName, null);
}
}
}
catch (Exception e) {
LOG.error("Error occurred while trying to reinitialize jobs", e);
}
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* @see org.kuali.kfs.sys.batch.service.SchedulerService#logScheduleResults()
*/
public void logScheduleResults() {
StringBuffer scheduleResults = new StringBuffer("The schedule completed.");
try {
for (String scheduledJobName : scheduler.getJobNames(SCHEDULED_GROUP)) {
JobDetail jobDetail = getScheduledJobDetail(scheduledJobName);
if ( jobDetail != null && !SCHEDULE_JOB_NAME.equals(jobDetail.getName())) {
scheduleResults.append("\n\t").append(jobDetail.getName()).append("=").append(getStatus(jobDetail));
}
}
}
catch (SchedulerException e) {
throw new RuntimeException("Caught exception while trying to logs schedule results", e);
}
LOG.info(scheduleResults);
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public List<BatchJobStatus> getJobs(String groupName) {
ArrayList<BatchJobStatus> jobs = new ArrayList<BatchJobStatus>();
try {
for (String jobName : scheduler.getJobNames(groupName)) {
try {
JobDescriptor jobDescriptor = retrieveJobDescriptor(jobName);
JobDetail jobDetail = scheduler.getJobDetail(jobName, groupName);
jobs.add(new BatchJobStatus(jobDescriptor, jobDetail));
}
catch (NoSuchBeanDefinitionException ex) {
// do nothing, ignore jobs not defined in spring
LOG.warn("Attempt to find bean " + groupName + "." + jobName + " failed - not in Spring context");
}
}
}
catch (SchedulerException ex) {
throw new RuntimeException("Exception while obtaining job list", ex);
}
return jobs;
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* @see org.kuali.kfs.sys.batch.service.SchedulerService#hasIncompleteJob()
*/
public boolean hasIncompleteJob() {
try {
StringBuffer log = new StringBuffer("The schedule has incomplete jobs.");
boolean hasIncompleteJob = false;
for (String scheduledJobName : scheduler.getJobNames(SCHEDULED_GROUP)) {
JobDetail scheduledJobDetail = getScheduledJobDetail(scheduledJobName);
boolean jobIsIncomplete = isIncomplete(scheduledJobDetail);
if (jobIsIncomplete) {
log.append("\n\t").append(scheduledJobDetail.getFullName());
hasIncompleteJob = true;
}
}
if (hasIncompleteJob) {
LOG.info(log);
}
return hasIncompleteJob;
}
catch (SchedulerException e) {
throw new RuntimeException("Caught exception while getting list of jobs to check for incompletes", e);
}
}
代码示例来源:origin: net.bull.javamelody/javamelody-core
List<JobDetail> getAllJobsOfScheduler(Scheduler scheduler) throws SchedulerException {
final List<JobDetail> result = new ArrayList<JobDetail>();
for (final String jobGroupName : scheduler.getJobGroupNames()) {
for (final String jobName : scheduler.getJobNames(jobGroupName)) {
final JobDetail jobDetail;
try {
jobDetail = scheduler.getJobDetail(jobName, jobGroupName);
// le job peut être terminé et supprimé depuis la ligne ci-dessus
if (jobDetail != null) {
result.add(jobDetail);
}
} catch (final Exception e) {
// si les jobs sont persistés en base de données, il peut y avoir une exception
// dans getJobDetail, par exemple si la classe du job n'existe plus dans l'application
LOG.debug(e.toString(), e);
}
}
}
return result;
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public List<BatchJobStatus> getJobs() {
ArrayList<BatchJobStatus> jobs = new ArrayList<BatchJobStatus>();
try {
for (String jobGroup : scheduler.getJobGroupNames()) {
for (String jobName : scheduler.getJobNames(jobGroup)) {
try {
JobDescriptor jobDescriptor = retrieveJobDescriptor(jobName);
JobDetail jobDetail = scheduler.getJobDetail(jobName, jobGroup);
jobs.add(new BatchJobStatus(jobDescriptor, jobDetail));
}
catch (NoSuchBeanDefinitionException ex) {
// do nothing, ignore jobs not defined in spring
LOG.warn("Attempt to find bean " + jobGroup + "." + jobName + " failed - not in Spring context");
}
}
}
}
catch (SchedulerException ex) {
throw new RuntimeException("Exception while obtaining job list", ex);
}
return jobs;
}
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
boolean isConsiderCalId = (hrCalendarId != null && !hrCalendarId.trim().isEmpty()) ? true : false;
for (String jobGroup : scheduler.getJobGroupNames()) {
for (String jobName : scheduler.getJobNames(jobGroup)) {
try {
if(isConsiderJobNm) {
代码示例来源:origin: glon/sandra-scheduler
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
Scheduler scheduler = jobExecutionContext.getScheduler();
String[] groups = scheduler.getJobGroupNames();
for (String group : groups) {
String[] jobNames = scheduler.getJobNames(group);
for (String jobName : jobNames) {
if (!jobName.equals(LOGGER_JOB)) {
Trigger trigger = scheduler.getTrigger(jobName, group);
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
String msg = "[" + jobName + "] " + dateFormat.format(trigger.getNextFireTime());
int triggerState = scheduler.getTriggerState(jobName, group);
switch (triggerState) {
case Trigger.STATE_BLOCKED : msg += " is blocked"; break;
case Trigger.STATE_COMPLETE : msg += " is completed"; break;
case Trigger.STATE_ERROR : msg += " is on error"; break;
case Trigger.STATE_NONE : msg += " is none"; break;
case Trigger.STATE_NORMAL : msg += " is normal"; break;
case Trigger.STATE_PAUSED : msg += " is in pause"; break;
}
log.info(msg);
}
}
}
} catch (SchedulerException e) {
log.info("Failled to get all jobs");
}
}
}
代码示例来源:origin: com.glon/sandra-scheduler
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
Scheduler scheduler = jobExecutionContext.getScheduler();
String[] groups = scheduler.getJobGroupNames();
for (String group : groups) {
String[] jobNames = scheduler.getJobNames(group);
for (String jobName : jobNames) {
if (!jobName.equals(LOGGER_JOB)) {
Trigger trigger = scheduler.getTrigger(jobName, group);
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
String msg = "[" + jobName + "] " + dateFormat.format(trigger.getNextFireTime());
int triggerState = scheduler.getTriggerState(jobName, group);
switch (triggerState) {
case Trigger.STATE_BLOCKED : msg += " is blocked"; break;
case Trigger.STATE_COMPLETE : msg += " is completed"; break;
case Trigger.STATE_ERROR : msg += " is on error"; break;
case Trigger.STATE_NONE : msg += " is none"; break;
case Trigger.STATE_NORMAL : msg += " is normal"; break;
case Trigger.STATE_PAUSED : msg += " is in pause"; break;
}
log.info(msg);
}
}
}
} catch (SchedulerException e) {
log.info("Failled to get all jobs");
}
}
}
代码示例来源:origin: org.jmxtrans/jmxtrans-core
private void deleteAllJobs() throws Exception {
List<JobDetail> allJobs = new ArrayList<>();
String[] jobGroups = serverScheduler.getJobGroupNames();
for (String jobGroup : jobGroups) {
String[] jobNames = serverScheduler.getJobNames(jobGroup);
for (String jobName : jobNames) {
allJobs.add(serverScheduler.getJobDetail(jobName, jobGroup));
}
}
for (JobDetail jd : allJobs) {
serverScheduler.deleteJob(jd.getName(), jd.getGroup());
if (log.isDebugEnabled()) {
log.debug("Deleted scheduled job: " + jd.getName() + " group: " + jd.getGroup());
}
}
}
代码示例来源:origin: tzolov/geode-dashboard
private void deleteAllJobs() throws Exception {
List<JobDetail> allJobs = new ArrayList<>();
String[] jobGroups = serverScheduler.getJobGroupNames();
for (String jobGroup : jobGroups) {
String[] jobNames = serverScheduler.getJobNames(jobGroup);
for (String jobName : jobNames) {
allJobs.add(serverScheduler.getJobDetail(jobName, jobGroup));
}
}
for (JobDetail jd : allJobs) {
serverScheduler.deleteJob(jd.getName(), jd.getGroup());
if (log.isDebugEnabled()) {
log.debug("Deleted scheduled job: " + jd.getName() + " group: " + jd.getGroup());
}
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* @see org.kuali.kfs.sys.batch.service.SchedulerService#processWaitingJobs()
*/
public void processWaitingJobs() {
try {
for (String scheduledJobName : scheduler.getJobNames(SCHEDULED_GROUP)) {
JobDetail jobDetail = getScheduledJobDetail(scheduledJobName);
if (isPending(jobDetail)) {
if (shouldScheduleJob(jobDetail)) {
scheduleJob(SCHEDULED_GROUP, scheduledJobName, 0, 0, new Date(), null);
}
if (shouldCancelJob(jobDetail)) {
updateStatus(SCHEDULED_GROUP, scheduledJobName, CANCELLED_JOB_STATUS_CODE);
}
}
}
}
catch (SchedulerException e) {
throw new RuntimeException("Caught exception while trying processing waiting jobs", e);
}
}
代码示例来源:origin: org.rhq/rhq-enterprise-server
String[] jobNames = scheduler.getJobNames(groupName);
if (jobNames != null) {
for (String jobName : jobNames) {
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
@SuppressWarnings("unchecked")
private void scheduleJob(Class<?> jobClass, DateTime jobDate, Map<String, String> jobGroupDataMap, Map<String, String> jobDataMap) throws SchedulerException {
if(jobDate == null) {
return;
}
String jobGroupName = BatchJobUtil.getJobGroupName(jobClass, jobGroupDataMap);
String jobName = BatchJobUtil.getJobName(jobClass, jobDataMap);
String[] jobNames = getScheduler().getJobNames(jobGroupName);
if (!ArrayUtils.contains(jobNames, jobName)) {
jobDataMap.put("date", jobDate.toString());
Map<String, String> mergedDataMap = MapUtils.merge(jobGroupDataMap, jobDataMap);
JobDetail jobDetail = new JobDetail(jobName, jobGroupName, jobClass, false, true, false);
jobDetail.setJobDataMap(new JobDataMap(mergedDataMap));
String triggerGroupName = BatchJobUtil.getTriggerGroupName(jobClass, MapUtils.merge(jobGroupDataMap, jobDataMap));
String triggerName = BatchJobUtil.getTriggerName(jobClass, jobDate);
Trigger trigger = new SimpleTrigger(triggerName, triggerGroupName, jobDate.toDate());
trigger.setJobGroup(jobGroupName);
trigger.setJobName(jobName);
LOG.info("Scheduling " + jobDetail.getFullName() + " to be run on " + jobDate);
this.updateStatus(jobDetail, BatchJobService.SCHEDULED_JOB_STATUS_CODE);
getScheduler().scheduleJob(jobDetail, trigger);
}
}
代码示例来源:origin: pentaho/pentaho-platform
Scheduler scheduler = getQuartzScheduler();
for ( String groupName : scheduler.getJobGroupNames() ) {
for ( String jobId : scheduler.getJobNames( groupName ) ) {
for ( Trigger trigger : scheduler.getTriggersOfJob( jobId, groupName ) ) {
if ( "MANUAL_TRIGGER".equals( trigger.getGroup() ) ) {
内容来源于网络,如有侵权,请联系作者删除!