From 4c7c574eefcf21acc91b972369f99f858c609e25 Mon Sep 17 00:00:00 2001 From: Ken Stevens Date: Mon, 25 Nov 2019 20:12:45 -0500 Subject: [PATCH] first pass scheduler working --- .../java/ca/uhn/fhir/jpa/config/BaseConfig.java | 7 ++++++- .../ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java | 15 +++++++-------- .../fhir/jpa/sched/ClusteredHapiScheduler.java | 10 ---------- .../ca/uhn/fhir/jpa/sched/LocalHapiScheduler.java | 10 ---------- .../java/ca/uhn/fhir/jpa/sched/NullScheduler.java | 8 -------- .../ca/uhn/fhir/jpa/sched/QuartzTableSeeder.java | 2 +- .../uhn/fhir/jpa/sched/SchedulerServiceImpl.java | 2 ++ 7 files changed, 16 insertions(+), 38 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java index baec583a33e..1c7da21d963 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java @@ -36,6 +36,7 @@ import ca.uhn.fhir.jpa.subscription.module.channel.ISubscribableChannelFactory; import ca.uhn.fhir.jpa.subscription.module.matcher.ISubscriptionMatcher; import ca.uhn.fhir.jpa.subscription.module.matcher.InMemorySubscriptionMatcher; import ca.uhn.fhir.rest.server.interceptor.consent.IConsentContextServices; +import ca.uhn.fhir.rest.server.sched.ISchedulerFactory; import ca.uhn.fhir.rest.server.sched.ISchedulerService; import org.hibernate.jpa.HibernatePersistenceProvider; import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; @@ -250,7 +251,11 @@ public abstract class BaseConfig { @Bean public ISchedulerService schedulerService() { - return new SchedulerServiceImpl(new HapiSchedulerFactory()); + return new SchedulerServiceImpl(hapiSchedulerFactory()); + } + @Bean + public ISchedulerFactory hapiSchedulerFactory() { + return new HapiSchedulerFactory(); } @Bean diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java index 775d67f366b..aa52534d0d7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/BaseHapiScheduler.java @@ -56,10 +56,13 @@ public abstract class BaseHapiScheduler implements IHapiScheduler { myScheduler.standby(); } - private void setProperties() { - myProperties.put("org.quartz.threadPool.threadCount", "4"); - myProperties.put("org.quartz.threadPool.threadNamePrefix", myThreadNamePrefix + "-" + myProperties.get(PROP_SCHED_INSTANCE_NAME)); - addProperties(myProperties); + protected void setProperties() { + addProperty("org.quartz.threadPool.threadCount", "4"); + addProperty("org.quartz.threadPool.threadNamePrefix", myThreadNamePrefix + "-" + myProperties.get(PROP_SCHED_INSTANCE_NAME)); + } + + protected void addProperty(String key, String value) { + myProperties.put(key, value); } @Override @@ -155,8 +158,4 @@ public abstract class BaseHapiScheduler implements IHapiScheduler { return true; } } - - abstract void addProperties(Properties theProperties); -// FIXME KHS -// quartzPropertiesClustered(clusteredProperties); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/ClusteredHapiScheduler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/ClusteredHapiScheduler.java index 4e02813c2bc..d09e7617ca3 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/ClusteredHapiScheduler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/ClusteredHapiScheduler.java @@ -1,18 +1,8 @@ package ca.uhn.fhir.jpa.sched; -import java.util.Properties; - public class ClusteredHapiScheduler extends BaseHapiScheduler { public ClusteredHapiScheduler(String theThreadNamePrefix, AutowiringSpringBeanJobFactory theSpringBeanJobFactory) { super(theThreadNamePrefix, theSpringBeanJobFactory); setInstanceName("clustered"); } - - /** - * Properties for the cluster scheduler (see the class docs to learn what this means) - */ - @Override - void addProperties(Properties theProperties) { -// theProperties.put("org.quartz.jobStore.tablePrefix", "QRTZHFJC_"); - } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/LocalHapiScheduler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/LocalHapiScheduler.java index 84b25de2282..7c7067cf509 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/LocalHapiScheduler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/LocalHapiScheduler.java @@ -1,18 +1,8 @@ package ca.uhn.fhir.jpa.sched; -import java.util.Properties; - public class LocalHapiScheduler extends BaseHapiScheduler { public LocalHapiScheduler(String theThreadNamePrefix, AutowiringSpringBeanJobFactory theSpringBeanJobFactory) { super(theThreadNamePrefix, theSpringBeanJobFactory); setInstanceName("local"); } - - /** - * Properties for the local scheduler (see the class docs to learn what this means) - */ - @Override - void addProperties(Properties theProperties) { - // nothing - } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/NullScheduler.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/NullScheduler.java index 5c059e846c1..b83d74f2052 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/NullScheduler.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/NullScheduler.java @@ -1,15 +1,7 @@ package ca.uhn.fhir.jpa.sched; -import java.util.Properties; - class NullScheduler extends BaseHapiScheduler { - public NullScheduler(String theThreadNamePrefix, AutowiringSpringBeanJobFactory theSpringBeanJobFactory) { super(theThreadNamePrefix, theSpringBeanJobFactory); } - - @Override - void addProperties(Properties theProperties) { - //nothing - } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/QuartzTableSeeder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/QuartzTableSeeder.java index 49ee1dec51f..b780bccd88e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/QuartzTableSeeder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/QuartzTableSeeder.java @@ -32,7 +32,7 @@ public class QuartzTableSeeder { @PostConstruct public void start() { - +// FIXME KHS what is this? } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/SchedulerServiceImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/SchedulerServiceImpl.java index 0b13675c0ef..e1c4b006b50 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/SchedulerServiceImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/sched/SchedulerServiceImpl.java @@ -115,8 +115,10 @@ public class SchedulerServiceImpl implements ISchedulerService, SmartLifecycle { } IHapiScheduler retval; if (theClustered) { + ourLog.info("Creating Clustered Scheduler"); retval = mySchedulerFactory.newClusteredHapiScheduler(); } else { + ourLog.info("Creating Local Scheduler"); retval = mySchedulerFactory.newLocalHapiScheduler(); } retval.init();