Java Code Examples for org.quartz.Scheduler#isShutdown()
The following examples show how to use
org.quartz.Scheduler#isShutdown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuartzManagerUtils.java From kafka-eagle with Apache License 2.0 | 6 votes |
/** Add new job. */ public static void addJob(BaseJobContext jobContext, String jobName, Class<? extends Job> jobClass, String cron) { try { Scheduler sched = schedulerFactory.getScheduler(); JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName, KE_JOB_GROUP_NAME).build(); jobDetail.getJobDataMap().put(AlarmQueue.JOB_PARAMS, jobContext); TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger(); triggerBuilder.withIdentity("ke_trigger_name_" + new Date().getTime(), "ke_trigger_group_" + new Date().getTime()); triggerBuilder.startNow(); triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron)); CronTrigger trigger = (CronTrigger) triggerBuilder.build(); sched.scheduleJob(jobDetail, trigger); if (!sched.isShutdown()) { sched.start(); } } catch (Exception e) { throw new RuntimeException(e); } }
Example 2
Source File: StdSchedulerFactory.java From AsuraFramework with Apache License 2.0 | 6 votes |
/** * <p> * Returns a handle to the Scheduler produced by this factory. * </p> * * <p> * If one of the <code>initialize</code> methods has not be previously * called, then the default (no-arg) <code>initialize()</code> method * will be called by this method. * </p> */ public Scheduler getScheduler() throws SchedulerException { if (cfg == null) { initialize(); } SchedulerRepository schedRep = SchedulerRepository.getInstance(); Scheduler sched = schedRep.lookup(getSchedulerName()); if (sched != null) { if (sched.isShutdown()) { schedRep.remove(getSchedulerName()); } else { return sched; } } sched = instantiate(); return sched; }
Example 3
Source File: QuartzManager.java From quartz-web with Apache License 2.0 | 5 votes |
public void schedulerShutdown(String schedulerName, boolean waitForJobsToComplete) throws SchedulerException { Scheduler scheduler = this.getAssertScheduler(schedulerName); if (!scheduler.isShutdown()) { List<JobDetail> allJobsOfScheduler = QuartzUtils.getAllJobsOfScheduler(scheduler); for (JobDetail jobDetail : allJobsOfScheduler) { QuartzUtils.pauseJob(jobDetail, scheduler); } if (waitForJobsToComplete) { scheduler.shutdown(waitForJobsToComplete); } else { scheduler.shutdown(); } } }
Example 4
Source File: QuartzManagerUtils.java From kafka-eagle with Apache License 2.0 | 5 votes |
/** Shutdown all jobs. */ public static void shutdownJobs() { try { Scheduler sched = schedulerFactory.getScheduler(); if (!sched.isShutdown()) { sched.shutdown(); } } catch (Exception e) { throw new RuntimeException(e); } }
Example 5
Source File: QuartzManager.java From quartz-web with Apache License 2.0 | 4 votes |
public void schedulerShutdown(String schedulerName) throws SchedulerException { Scheduler scheduler = this.getAssertScheduler(schedulerName); if (!scheduler.isShutdown()) { scheduler.shutdown(); } }
Example 6
Source File: ShowScheduler.java From iaf with Apache License 2.0 | 4 votes |
@PUT @RolesAllowed({"IbisDataAdmin", "IbisAdmin", "IbisTester"}) @Path("/schedules/") @Relation("schedules") @Produces(MediaType.APPLICATION_JSON) public Response updateScheduler(LinkedHashMap<String, Object> json) throws ApiException { Scheduler scheduler = getScheduler(); String action = null; for (Entry<String, Object> entry : json.entrySet()) { String key = entry.getKey(); if(key.equalsIgnoreCase("action")) { action = entry.getValue().toString(); } } try { String commandIssuedBy = servletConfig.getInitParameter("remoteHost"); commandIssuedBy += servletConfig.getInitParameter("remoteAddress"); commandIssuedBy += servletConfig.getInitParameter("remoteUser"); if (action.equalsIgnoreCase("start")) { if(scheduler.isInStandbyMode() || scheduler.isShutdown()) { scheduler.start(); log.info("start scheduler:" + new Date() + commandIssuedBy); } else { throw new ApiException("Failed to start scheduler"); } } else if (action.equalsIgnoreCase("pause")) { if(scheduler.isStarted()) { scheduler.standby(); log.info("pause scheduler:" + new Date() + commandIssuedBy); } else { throw new ApiException("Failed to pause scheduler"); } } else if (action.equalsIgnoreCase("stop")) { if(scheduler.isStarted() || scheduler.isInStandbyMode()) { scheduler.shutdown(); log.info("shutdown scheduler:" + new Date() + commandIssuedBy); } else { throw new ApiException("Failed to stop scheduler"); } } else { return Response.status(Response.Status.BAD_REQUEST).build(); } } catch (Exception e) { log.error("unable to run action ["+action+"]",e); } return Response.status(Response.Status.OK).build(); }