當前位置: 首頁>>代碼示例>>Java>>正文


Java Scheduler.isStarted方法代碼示例

本文整理匯總了Java中org.quartz.Scheduler.isStarted方法的典型用法代碼示例。如果您正苦於以下問題:Java Scheduler.isStarted方法的具體用法?Java Scheduler.isStarted怎麽用?Java Scheduler.isStarted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.Scheduler的用法示例。


在下文中一共展示了Scheduler.isStarted方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: schedulerStart

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 啟動
 * @param schedulerName
 * @throws SchedulerException
 */
public void schedulerStart(String schedulerName) throws SchedulerException {
    Scheduler scheduler = this.getAssertScheduler(schedulerName);
    if (!scheduler.isStarted()) {
        scheduler.start();
    }
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:12,代碼來源:QuartzManager.java

示例2: doHandleRequest

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Override
protected ModelAndView doHandleRequest(HttpServletRequest req,HttpServletResponse res) throws Exception {
	SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Scheduler scheduler=instanceDetection.getScheduler();
	StringBuffer sb=new StringBuffer();
	sb.append("<strong>Status</strong>:");
	if(scheduler.isInStandbyMode()){
		sb.append("Standby");
	}
	if(scheduler.isShutdown()){
		sb.append("Shutdown");
	}
	if(scheduler.isStarted()){
		sb.append("Started");
	}
	sb.append("<br>");
	for (String groupName : scheduler.getJobGroupNames()) {
	     for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
	    	 JobDetail jobDetail=scheduler.getJobDetail(jobKey);
	    	 sb.append("<strong>JobClass:</strong>");
	    	 sb.append(jobDetail.getJobClass().getName());
	    	 
	    	 Trigger trigger=scheduler.getTriggersOfJob(jobDetail.getKey()).get(0);
	    	 sb.append("<br><strong>PreviousFireDate:</strong>");
	    	 if(trigger.getPreviousFireTime()!=null){
	    		 sb.append(sd.format(trigger.getPreviousFireTime()));		    		 
	    	 }
	    	 sb.append("<br><strong>NextFireDate:</strong>");
	    	 if(sd.format(trigger.getNextFireTime())!=null){
	    		 sb.append(sd.format(trigger.getNextFireTime()));		    		 
	    	 }
	    	 if(trigger instanceof CronTriggerImpl){
	    		 CronTriggerImpl cron=(CronTriggerImpl)trigger;
	    		 sb.append("<br><strong>CronExpression:</strong>");
	    		 sb.append(cron.getCronExpression());
	    	 }
	    	 
	     }
	}
	res.setContentType("text/html; charset=utf-8");
	PrintWriter pw=res.getWriter();
	pw.write(sb.toString());
	pw.flush();
	pw.close();
	return null;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:47,代碼來源:DaemonStatusController.java

示例3: runBusinessJobInCurrentInstance

import org.quartz.Scheduler; //導入方法依賴的package包/類
private void runBusinessJobInCurrentInstance() throws Exception{
	if(!isRunBusinessJob()){
		return;
	}
	Scheduler scheduler=schedulerService.getCurrentScheduler();
	if(scheduler!=null && scheduler.isStarted()){
		return;
	}
	String currentInstanceName=schedulerService.getJobInstanceName();
	String clusterJobInstanceNames[]=getClusterJobInstanceNames();
	Session session=this.getSessionFactory().openSession();
	boolean runScheduler=true;
	try{
		Query query=session.createQuery("from "+Heartbeat.class.getName()+" b where b.applicationName=:applicationName order by b.date desc");
		@SuppressWarnings("unchecked")
		List<Heartbeat> heartbeats=query.setString("applicationName",schedulerService.getJobApplicationName()).setMaxResults(1).list();
		int currentPos=this.getPosition(clusterJobInstanceNames, currentInstanceName)+1;
		int secondUnit=40;
		if(heartbeats.size()>0){
			Date now=new Date();
			Heartbeat heartbeat=heartbeats.get(0);
			Date beatDate=heartbeat.getDate();
			Calendar beatCalendar=Calendar.getInstance();
			beatCalendar.setTime(beatDate);
			String beatInstanceName=heartbeat.getInstanceName();
			if(!currentInstanceName.equals(beatInstanceName)){
				int currentSecond=currentPos*secondUnit;
				int beatPos=this.getPosition(clusterJobInstanceNames, beatInstanceName)+1;
				if(currentPos>beatPos){
					beatCalendar.add(Calendar.SECOND,currentSecond);
				}else if(currentPos<beatPos){
					currentSecond=(currentPos+(clusterJobInstanceNames.length-beatPos))*secondUnit;
					beatCalendar.add(Calendar.SECOND,currentSecond);
				}
			}else{
				beatCalendar.add(Calendar.SECOND,secondUnit*clusterJobInstanceNames.length);				
			}
			if(now.compareTo(beatCalendar.getTime())<0){
				//當前時間小於心跳時間+currentSecond,說明當前運行JOB的實例運行中
				runScheduler=false;
			}
		}else{
			if(currentPos>1){
				//如果當前實例不處於運動集群JOB的第一位,那麽就不運行JOB
				runScheduler=false;					
			}
		}
	}finally{
		session.close();
	}
	if(runScheduler){
		schedulerService.resetScheduer();				
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:55,代碼來源:InstanceDetection.java

示例4: loadScheduerInfo

import org.quartz.Scheduler; //導入方法依賴的package包/類
@DataProvider
public SchedulerInfo loadScheduerInfo() throws Exception{
	SchedulerInfo info=new SchedulerInfo();
	info.setRunJob(schedulerService.isRunJobInCurrentInstance());
	Scheduler scheduler=schedulerService.getCurrentScheduler();
	if(scheduler!=null){
		if(scheduler.isStarted()){
			info.setState(SchedulerState.started);
		}else if(scheduler.isShutdown()){
			info.setState(SchedulerState.shutdown);
		}else if(scheduler.isInStandbyMode()){
			info.setState(SchedulerState.standby);
		}
		info.setJobInstanceName(schedulerService.getJobInstanceName());
		List<JobInfo> jobs=new ArrayList<JobInfo>();
		for (String groupName : scheduler.getJobGroupNames()) {
			for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
				JobInfo jobInfo=new JobInfo();
				JobDetail jobDetail=scheduler.getJobDetail(jobKey);
				if(jobDetail instanceof SpringBeanJobExecutorDetail){
					SpringBeanJobExecutorDetail springBeanDetail=(SpringBeanJobExecutorDetail)jobDetail;
					jobInfo.setTargetJobInfo("SpringBean:"+springBeanDetail.getTargetJobBeanId());
					jobInfo.setType(JobType.definition);
					
				}else if(jobDetail instanceof ScanJobExecutorDetail){
					jobInfo.setType(JobType.scan);
					jobInfo.setTargetJobInfo(jobDetail.getJobClass().getName());
				}
				Trigger trigger=scheduler.getTriggersOfJob(jobKey).get(0);
				jobInfo.setName(jobDetail.getKey().getName());
				jobInfo.setGroup(jobDetail.getKey().getGroup());
				jobInfo.setNextFireDate(trigger.getNextFireTime());
				jobInfo.setPreviousFireDate(trigger.getPreviousFireTime());
				if(trigger instanceof CronTriggerImpl){
					CronTriggerImpl cron=(CronTriggerImpl)trigger;
					jobInfo.setTriggerInfo("Cron表達式類型觸發器["+cron.getCronExpression()+"]");
				}else{
					jobInfo.setTriggerInfo("觸發器類型:"+trigger.getClass());
				}
				jobs.add(jobInfo);
				
			}
			info.setJobs(jobs);
		}
	}
	return info;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:48,代碼來源:SchedulerAnalysis.java


注:本文中的org.quartz.Scheduler.isStarted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。