Only stop the scheduler once it is set.
Original commit: elastic/x-pack-elasticsearch@4238a62673
This commit is contained in:
parent
306fefd847
commit
e3694655af
|
@ -27,8 +27,8 @@ public class AlertScheduler extends AbstractComponent {
|
|||
// Not happy about it, but otherwise we're stuck with Quartz's SimpleThreadPool
|
||||
private volatile static ThreadPool threadPool;
|
||||
|
||||
private volatile Scheduler scheduler;
|
||||
private AlertManager alertManager;
|
||||
private volatile Scheduler scheduler;
|
||||
|
||||
@Inject
|
||||
public AlertScheduler(Settings settings, ThreadPool threadPool) {
|
||||
|
@ -56,9 +56,10 @@ public class AlertScheduler extends AbstractComponent {
|
|||
properties.setProperty(StdSchedulerFactory.PROP_SCHED_INTERRUPT_JOBS_ON_SHUTDOWN, "true");
|
||||
properties.setProperty(StdSchedulerFactory.PROP_SCHED_INTERRUPT_JOBS_ON_SHUTDOWN_WITH_WAIT, "true");
|
||||
SchedulerFactory schFactory = new StdSchedulerFactory(properties);
|
||||
scheduler = schFactory.getScheduler();
|
||||
Scheduler scheduler = schFactory.getScheduler();
|
||||
scheduler.setJobFactory(new SimpleJobFactory());
|
||||
scheduler.start();
|
||||
this.scheduler = scheduler;
|
||||
for (Map.Entry<String, Alert> entry : alerts.entrySet()) {
|
||||
add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -72,9 +73,13 @@ public class AlertScheduler extends AbstractComponent {
|
|||
*/
|
||||
public synchronized void stop() {
|
||||
try {
|
||||
scheduler.clear();
|
||||
scheduler.shutdown(true);
|
||||
logger.info("Stopped scheduler");
|
||||
if (scheduler != null) {
|
||||
logger.info("Stopping scheduler...");
|
||||
scheduler.clear();
|
||||
scheduler.shutdown(true);
|
||||
scheduler = null;
|
||||
logger.info("Stopped scheduler");
|
||||
}
|
||||
} catch (SchedulerException se){
|
||||
logger.error("Failed to stop quartz scheduler", se);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue