本文整理匯總了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);
}
}