本文整理汇总了Java中org.quartz.SchedulerException类的典型用法代码示例。如果您正苦于以下问题:Java SchedulerException类的具体用法?Java SchedulerException怎么用?Java SchedulerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SchedulerException类属于org.quartz包,在下文中一共展示了SchedulerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.quartz.SchedulerException; //导入依赖的package包/类
@Transactional(rollbackFor = Exception.class)
public void delete(Long jobId) throws SchedulerException {
Job job = getJob(jobId);
if (job != null) {
//单一任务,直接执行删除
String sql = "UPDATE T_JOB SET deleted=1 WHERE ";
if (job.getJobType().equals(JobType.SINGLETON.getCode())) {
sql += " jobId=" + jobId;
}
if (job.getJobType().equals(JobType.FLOW.getCode())) {
if (job.getFlowNum() == 0) {
//顶层流程任务,则删除一组
sql += " flowId=" + job.getFlowId();
} else {
//其中一个子流程任务,则删除单个
sql += " jobId=" + jobId;
}
}
queryDao.createSQLQuery(sql).executeUpdate();
schedulerService.syncJobTigger(jobId, null);
flushJob();
}
}
示例2: resumeJob
import org.quartz.SchedulerException; //导入依赖的package包/类
/**
* Resume paused job
*/
@Override
public boolean resumeJob(String jobName) {
System.out.println("Request received for resuming job.");
String jobKey = jobName;
String groupKey = "SampleGroup";
JobKey jKey = new JobKey(jobKey, groupKey);
System.out.println("Parameters received for resuming job : jobKey :"+jobKey);
try {
schedulerFactoryBean.getScheduler().resumeJob(jKey);
System.out.println("Job with jobKey :"+jobKey+ " resumed succesfully.");
return true;
} catch (SchedulerException e) {
System.out.println("SchedulerException while resuming job with key :"+jobKey+ " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例3: unScheduleJob
import org.quartz.SchedulerException; //导入依赖的package包/类
/**
* Remove the indicated Trigger from the scheduler.
* If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.
*/
@Override
public boolean unScheduleJob(String jobName) {
System.out.println("Request received for Unscheduleding job.");
String jobKey = jobName;
TriggerKey tkey = new TriggerKey(jobKey);
System.out.println("Parameters received for unscheduling job : tkey :"+jobKey);
try {
boolean status = schedulerFactoryBean.getScheduler().unscheduleJob(tkey);
System.out.println("Trigger associated with jobKey :"+jobKey+ " unscheduled with status :"+status);
return status;
} catch (SchedulerException e) {
System.out.println("SchedulerException while unscheduling job with key :"+jobKey + " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例4: notifyTriggerListenersComplete
import org.quartz.SchedulerException; //导入依赖的package包/类
private boolean notifyTriggerListenersComplete(JobExecutionContext jobExCtxt, CompletedExecutionInstruction instCode) {
try {
qs.notifyTriggerListenersComplete(jobExCtxt, instCode);
} catch (SchedulerException se) {
qs.notifySchedulerListenersError(
"Unable to notify TriggerListener(s) of Job that was executed: "
+ "(error will be ignored). trigger= "
+ jobExCtxt.getTrigger().getKey() + " job= "
+ jobExCtxt.getJobDetail().getKey(), se);
return false;
}
if (jobExCtxt.getTrigger().getNextFireTime() == null) {
qs.notifySchedulerListenersFinalized(jobExCtxt.getTrigger());
}
return true;
}
示例5: assertExecute
import org.quartz.SchedulerException; //导入依赖的package包/类
@Test
public void assertExecute() throws SchedulerException {
Optional<JobRunningStatistics> latestJobRunningStatistics = Optional.of(new JobRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3)));
Optional<TaskRunningStatistics> latestTaskRunningStatistics = Optional.of(new TaskRunningStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.MINUTE, -3)));
when(repository.findLatestJobRunningStatistics()).thenReturn(latestJobRunningStatistics);
when(repository.findLatestTaskRunningStatistics()).thenReturn(latestTaskRunningStatistics);
when(repository.add(any(JobRunningStatistics.class))).thenReturn(true);
when(repository.add(any(TaskRunningStatistics.class))).thenReturn(true);
Map<String, Set<TaskContext>> jobMap = new HashMap<>(1);
Set<TaskContext> jobSet = new HashSet<>(1);
jobSet.add(TaskContext.from(TaskNode.builder().jobName("test_job").build().getTaskNodeValue()));
jobMap.put("test_job", jobSet);
when(runningService.getAllRunningTasks()).thenReturn(jobMap);
jobRunningStatisticJob.execute(null);
verify(repository).findLatestJobRunningStatistics();
verify(repository).findLatestTaskRunningStatistics();
verify(repository, times(3)).add(any(JobRunningStatistics.class));
verify(repository, times(3)).add(any(TaskRunningStatistics.class));
verify(runningService).getAllRunningTasks();
}
示例6: stopNow
import org.quartz.SchedulerException; //导入依赖的package包/类
@Transactional(rollbackFor = Exception.class)
public void stopNow(Integer id) {
JobDetailDO jobDetailDO = daoSupport.get(id, JobDetailDO.class);
if (Objects.isNull(jobDetailDO) || jobDetailDO.getState().intValue() != 1) {
throw new BusinessException(ExceptionEnum.FAIL);
}
//先保留原状态,原表达式。
Integer origState = jobDetailDO.getState();
String origCron = jobDetailDO.getCron();
//调用任务处理service,删除job。
jobDetailDO.setState(2);
try {
initJobService.deleteJob(jobDetailDO);
} catch (SchedulerException e) {
e.printStackTrace();
throw new BusinessException(ExceptionEnum.FAIL);
}
//增加操作记录
JobDetailEditAO jobDetailEditAO = buildJobDetailEditAO(origState, origCron, JobDetailEditTypeEnum.DELETE.getCode(), jobDetailDO);
jobDetailEditNotesService.addEditNote(jobDetailEditAO);
}
示例7: getAllJobList
import org.quartz.SchedulerException; //导入依赖的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;
}
示例8: notifyJobListenersComplete
import org.quartz.SchedulerException; //导入依赖的package包/类
private boolean notifyJobListenersComplete(JobExecutionContext jec,
JobExecutionException jobExEx) {
try {
qs.notifyJobListenersWasExecuted(jec, jobExEx);
} catch (SchedulerException se) {
qs.notifySchedulerListenersError(
"Unable to notify JobListener(s) of Job that was executed: "
+ "(error will be ignored). trigger= "
+ jec.getTrigger().getFullName() + " job= "
+ jec.getJobDetail().getFullName(), se);
return false;
}
return true;
}
示例9: deleteJobs
import org.quartz.SchedulerException; //导入依赖的package包/类
public boolean deleteJobs(List<JobKey> jobKeys) throws SchedulerException {
validateState();
boolean result = false;
result = resources.getJobStore().removeJobs(jobKeys);
notifySchedulerThread(0L);
for(JobKey key: jobKeys)
notifySchedulerListenersJobDeleted(key);
return result;
}
示例10: shutdown
import org.quartz.SchedulerException; //导入依赖的package包/类
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void shutdown() throws SchedulerException {
try {
String schedulerName = getSchedulerName();
getRemoteScheduler().shutdown();
SchedulerRepository.getInstance().remove(schedulerName);
} catch (RemoteException re) {
throw invalidateHandleCreateException(
"Error communicating with remote scheduler.", re);
}
}
示例11: assertExecute
import org.quartz.SchedulerException; //导入依赖的package包/类
@Test
public void assertExecute() throws SchedulerException {
Optional<JobRegisterStatistics> latestOne = Optional.of(new JobRegisterStatistics(0, StatisticTimeUtils.getStatisticTime(StatisticInterval.DAY, -3)));
when(repository.findLatestJobRegisterStatistics()).thenReturn(latestOne);
when(repository.add(any(JobRegisterStatistics.class))).thenReturn(true);
when(configurationService.loadAll()).thenReturn(Lists.newArrayList(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
registeredJobStatisticJob.execute(null);
verify(repository).findLatestJobRegisterStatistics();
verify(repository, times(3)).add(any(JobRegisterStatistics.class));
verify(configurationService).loadAll();
}
示例12: resumeTrigger
import org.quartz.SchedulerException; //导入依赖的package包/类
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void resumeTrigger(TriggerKey triggerKey)
throws SchedulerException {
try {
getRemoteScheduler().resumeTrigger(triggerKey);
} catch (RemoteException re) {
throw invalidateHandleCreateException(
"Error communicating with remote scheduler.", re);
}
}
示例13: destroy
import org.quartz.SchedulerException; //导入依赖的package包/类
public void destroy() {
if (schedulerOn) {
try {
sched.shutdown();
} catch (SchedulerException e) {
Engine.logEngine.error("Unexpected exception", e);
} finally {
schedulerOn = false;
}
}
}
示例14: pauseJobs
import org.quartz.SchedulerException; //导入依赖的package包/类
private void pauseJobs() throws SchedulerException {
for (final Iterator i = triggerKeyList.iterator(); i.hasNext();) {
final TriggerKey key = (TriggerKey) i.next();
//if (log.isDebugEnabled()) log.debug("pausing: " + key.toString());
scheduler.pauseTrigger(key.getName(), key.getGroup());
}
}
示例15: start
import org.quartz.SchedulerException; //导入依赖的package包/类
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void start() throws SchedulerException {
try {
getRemoteScheduler().start();
} catch (RemoteException re) {
throw invalidateHandleCreateException(
"Error communicating with remote scheduler.", re);
}
}