org.quartz.Scheduler#pauseJob ( )源码实例Demo

下面列出了org.quartz.Scheduler#pauseJob ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: supplierShop   文件: ScheduleUtils.java
/**
 * 创建定时任务
 */
public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
{
    Class<? extends Job> jobClass = getQuartzJobClass(job);
    // 构建job信息
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();

    // 表达式调度构建器
    CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
    cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);

    // 按新的cronExpression表达式构建一个新的trigger
    CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup))
            .withSchedule(cronScheduleBuilder).build();

    // 放入参数,运行时的方法可以获取
    jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);

    // 判断是否存在
    if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
    {
        // 防止创建时存在数据问题 先移除,然后在执行创建操作
        scheduler.deleteJob(getJobKey(jobId, jobGroup));
    }

    scheduler.scheduleJob(jobDetail, trigger);

    // 暂停任务
    if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
    {
        scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
    }
}
 
源代码2 项目: RuoYi-Vue   文件: ScheduleUtils.java
/**
 * 创建定时任务
 */
public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
{
    Class<? extends Job> jobClass = getQuartzJobClass(job);
    // 构建job信息
    Long jobId = job.getJobId();
    String jobGroup = job.getJobGroup();
    JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();

    // 表达式调度构建器
    CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
    cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);

    // 按新的cronExpression表达式构建一个新的trigger
    CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup))
            .withSchedule(cronScheduleBuilder).build();

    // 放入参数,运行时的方法可以获取
    jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);

    // 判断是否存在
    if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
    {
        // 防止创建时存在数据问题 先移除,然后在执行创建操作
        scheduler.deleteJob(getJobKey(jobId, jobGroup));
    }

    scheduler.scheduleJob(jobDetail, trigger);

    // 暂停任务
    if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
    {
        scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
    }
}
 
源代码3 项目: ruoyiplus   文件: ScheduleUtils.java
/**
 * 暂停任务
 */
public static void pauseJob(Scheduler scheduler, Long jobId)
{
    try
    {
        scheduler.pauseJob(getJobKey(jobId));
    }
    catch (SchedulerException e)
    {
        log.error("pauseJob 异常:", e);
    }
}
 
源代码4 项目: LuckyFrameWeb   文件: ScheduleUtils.java
/**
 * 暂停任务
 */
public static void pauseJob(Scheduler scheduler, Long jobId)
{
    try
    {
        scheduler.pauseJob(getJobKey(jobId));
    }
    catch (SchedulerException e)
    {
        log.error("pauseJob 异常:", e);
    }
}
 
源代码5 项目: griffin   文件: BatchJobOperatorImpl.java
private void pauseJob(String group, String name) throws SchedulerException {
    if (StringUtils.isEmpty(group) || StringUtils.isEmpty(name)) {
        return;
    }
    Scheduler scheduler = factory.getScheduler();
    JobKey jobKey = new JobKey(name, group);
    if (!scheduler.checkExists(jobKey)) {
        LOGGER.warn("Job({},{}) does not exist.", jobKey.getGroup(), jobKey
            .getName());
        throw new GriffinException.NotFoundException
            (JOB_KEY_DOES_NOT_EXIST);
    }
    scheduler.pauseJob(jobKey);
}
 
源代码6 项目: fixflow   文件: ScheduleServiceImpl.java
public void suspendJob(String name, String group) {
	if(!getIsEnabled()){
		throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE);
	}
	Scheduler scheduler = getScheduler();
	try {
		scheduler.pauseJob(new JobKey(name,group));
	} catch (SchedulerException e) {
		throw new FixFlowException(e.getMessage(),e);
	}
}
 
源代码7 项目: quartz-web   文件: QuartzUtils.java
public static void pauseJob(String jobName, String jobGroup, Scheduler scheduler) throws SchedulerException {
    scheduler.pauseJob(getJobKey(jobName, jobGroup));
}
 
源代码8 项目: alfresco-remote-api   文件: RepoService.java
@SuppressWarnings("unchecked")
public RepoService(ApplicationContext applicationContext) throws Exception
   {
   	this.applicationContext = applicationContext;
   	this.publicApiContext = new PublicApiTestContext(applicationContext);
   	this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
   	this.siteService = (SiteService)applicationContext.getBean("SiteService");
   	this.activityService = (ActivityService)applicationContext.getBean("activityService");
   	this.fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService");
   	this.contentService = (ContentService)applicationContext.getBean("ContentService");
   	this.commentService = (CommentService)applicationContext.getBean("CommentService");
   	this.nodeService = (NodeService)applicationContext.getBean("NodeService");
   	this.preferenceService = (PreferenceService)applicationContext.getBean("PreferenceService");
   	this.taggingService = (TaggingService)applicationContext.getBean("TaggingService");
   	this.ratingService = (RatingService)applicationContext.getBean("RatingService");
   	this.tenantService = (TenantService)applicationContext.getBean("tenantService");
   	this.tenantAdminService = (TenantAdminService)applicationContext.getBean("tenantAdminService");
   	this.personService = (PersonService)applicationContext.getBean("PersonService");
   	this.contentStoreCleaner = (ContentStoreCleaner)applicationContext.getBean("contentStoreCleaner");
   	this.postDAO = (ActivityPostDAO)applicationContext.getBean("postDAO");
   	this.nodeRatingSchemeRegistry = (NamedObjectRegistry<RatingScheme>)applicationContext.getBean("nodeRatingSchemeRegistry");
   	this.cociService = (CheckOutCheckInService)applicationContext.getBean("CheckoutCheckinService");
   	this.favouritesService = (FavouritesService)applicationContext.getBean("FavouritesService");
   	this.dictionaryService =  (DictionaryService)applicationContext.getBean("dictionaryService");
   	this.invitationService = (InvitationService)applicationContext.getBean("InvitationService");
   	this.lockService = (LockService)applicationContext.getBean("LockService");
   	this.cmisConnector = (CMISConnector)applicationContext.getBean("CMISConnector");
   	this.activities = (Activities)applicationContext.getBean("activities");
   	this.hiddenAspect = (HiddenAspect)applicationContext.getBean("hiddenAspect");
   	this.networksService = (NetworksService)applicationContext.getBean("networksService");
   	this.namespaceService = (NamespaceService)applicationContext.getBean("namespaceService"); 
   	this.transactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper");

       Scheduler scheduler = (Scheduler)applicationContext.getBean("schedulerFactory");

       CronTrigger contentStoreCleanerTrigger = (CronTrigger)applicationContext.getBean("contentStoreCleanerTrigger");
       scheduler.pauseJob(contentStoreCleanerTrigger.getJobKey());

       ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)applicationContext.getBean("ActivitiesFeed");
       ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
       this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
       this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
       this.feedGeneratorJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedGeneratorJobDetail");
       this.postLookupJobDetail = (JobDetail)activitiesFeedCtx.getBean("postLookupJobDetail");
       this.feedCleanerJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedCleanerJobDetail");
       this.postCleanerJobDetail = (JobDetail)activitiesFeedCtx.getBean("postCleanerJobDetail");
       this.feedNotifierJobDetail = (JobDetail)activitiesFeedCtx.getBean("feedNotifierJobDetail");
   	this.feedCleaner = (FeedCleaner)activitiesFeedCtx.getBean("feedCleaner");

       // Pause activities jobs so that we aren't competing with their scheduled versions
       scheduler.pauseJob(feedGeneratorJobDetail.getKey());
       scheduler.pauseJob(postLookupJobDetail.getKey());
       scheduler.pauseJob(feedCleanerJobDetail.getKey());
       scheduler.pauseJob(postCleanerJobDetail.getKey());
       scheduler.pauseJob(feedNotifierJobDetail.getKey());

       this.systemNetwork = new TestNetwork(TenantService.DEFAULT_DOMAIN, true);
}
 
源代码9 项目: javamelody   文件: QuartzAdapter.java
void pauseJob(JobDetail jobDetail, Scheduler scheduler) throws SchedulerException {
	scheduler.pauseJob(jobDetail.getName(), jobDetail.getGroup());
}
 
源代码10 项目: javamelody   文件: Quartz2Adapter.java
@Override
void pauseJob(JobDetail jobDetail, Scheduler scheduler) throws SchedulerException {
	scheduler.pauseJob(jobDetail.getKey());
}
 
源代码11 项目: iaf   文件: ShowScheduler.java
@PUT
@RolesAllowed({"IbisDataAdmin", "IbisAdmin", "IbisTester"})
@Path("/schedules/{groupName}/job/{jobName}")
@Relation("schedules")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response trigger(@PathParam("jobName") String jobName, @PathParam("groupName") String groupName, LinkedHashMap<String, Object> json) throws ApiException {
	Scheduler scheduler = getScheduler();

	String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
	commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
	commandIssuedBy += servletConfig.getInitParameter("remoteUser");

	if(log.isInfoEnabled()) log.info("trigger job jobName [" + jobName + "] groupName [" + groupName + "] " + commandIssuedBy);
	JobKey jobKey = JobKey.jobKey(jobName, groupName);

	String action = ""; //PAUSE,RESUME,TRIGGER

	for (Entry<String, Object> entry : json.entrySet()) {
		String key = entry.getKey();
		if(key.equalsIgnoreCase("action")) {//Start or stop an adapter!
			action = (String) entry.getValue();
		}
	}

	try {
		if("pause".equals(action)) {
			scheduler.pauseJob(jobKey);
		}
		else if("resume".equals(action)) {
			scheduler.resumeJob(jobKey);
		}
		else if("trigger".equals(action)) {
			scheduler.triggerJob(jobKey);
		}
		else {
			throw new ApiException("no (valid) action provided! Expected one of PAUSE,RESUME,TRIGGER");
		}
	} catch (SchedulerException e) {
		throw new ApiException("Failed to "+action+" job", e); 
	}

	return Response.status(Response.Status.OK).build();
}
 
源代码12 项目: spring-cloud-shop   文件: JobTrigger.java
/**
 * 暂停任务
 *
 * @param scheduler scheduler
 * @param jobName   jobName
 * @param jobGroup  jobGroup
 */
public static void pauseJob(Scheduler scheduler, String jobName, String jobGroup) throws SchedulerException {

    log.info("暂定定时任务 jobName = {}, jobGroup = {}", jobName, jobGroup);
    JobKey jobKey = JobKey.jobKey(jobName, jobGroup);
    scheduler.pauseJob(jobKey);
}
 
源代码13 项目: quartz-web   文件: QuartzUtils.java
/**
 * 暂停Job
 * @param jobDetail
 * @param scheduler
 * @throws SchedulerException
 */
public static void pauseJob(JobDetail jobDetail, Scheduler scheduler) throws SchedulerException {
    scheduler.pauseJob(jobDetail.getKey());
}