ensure only one @PostConstruct method to make order explicit
This commit is contained in:
parent
37eef4e3e4
commit
f92c2bb5f9
|
@ -78,7 +78,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
public class BulkDataExportSvcImpl implements IBulkDataExportSvc {
|
||||
|
||||
private static final long JOB_INTERVAL_MILLIS = 10 * DateUtils.MILLIS_PER_SECOND;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(BulkDataExportSvcImpl.class);
|
||||
private int myReuseBulkExportForMillis = (int) (60 * DateUtils.MILLIS_PER_MINUTE);
|
||||
|
||||
|
@ -311,13 +310,12 @@ public class BulkDataExportSvcImpl implements IBulkDataExportSvc {
|
|||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
ourLog.info("Bulk export service starting with refresh interval {}", StopWatch.formatMillis(JOB_INTERVAL_MILLIS));
|
||||
myTxTemplate = new TransactionTemplate(myTxManager);
|
||||
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(this.getClass().getName());
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleClusteredJob(JOB_INTERVAL_MILLIS, jobDetail);
|
||||
mySchedulerService.scheduleClusteredJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -113,7 +113,7 @@ public abstract class BaseHapiScheduler implements IHapiScheduler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void scheduleFixedDelay(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
public void scheduleJob(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
Validate.isTrue(theIntervalMillis >= 100);
|
||||
|
||||
Validate.notNull(theJobDefinition);
|
||||
|
|
|
@ -25,6 +25,7 @@ import ca.uhn.fhir.model.api.ISmartLifecyclePhase;
|
|||
import ca.uhn.fhir.rest.server.sched.IHapiScheduler;
|
||||
import ca.uhn.fhir.rest.server.sched.ISchedulerService;
|
||||
import ca.uhn.fhir.rest.server.sched.ScheduledJobDefinition;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -173,12 +174,14 @@ public abstract class BaseSchedulerServiceImpl implements ISchedulerService, Sma
|
|||
|
||||
@Override
|
||||
public void scheduleLocalJob(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
myLocalScheduler.scheduleFixedDelay(theIntervalMillis, theJobDefinition);
|
||||
ourLog.info("Scheduling local job {} with interval {}", theJobDefinition.getId(), StopWatch.formatMillis(theIntervalMillis));
|
||||
myLocalScheduler.scheduleJob(theIntervalMillis, theJobDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleClusteredJob(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
myClusteredScheduler.scheduleFixedDelay(theIntervalMillis, theJobDefinition);
|
||||
ourLog.info("Scheduling clustered job {} with interval {}", theJobDefinition.getId(), StopWatch.formatMillis(theIntervalMillis));
|
||||
myClusteredScheduler.scheduleJob(theIntervalMillis, theJobDefinition);
|
||||
}
|
||||
|
||||
private boolean isSchedulingDisabledForUnitTests() {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class HapiNullScheduler implements IHapiScheduler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void scheduleFixedDelay(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
public void scheduleJob(long theIntervalMillis, ScheduledJobDefinition theJobDefinition) {
|
||||
ourLog.debug("Skipping scheduling job {} since scheduling is disabled", theJobDefinition.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ package ca.uhn.fhir.jpa.search;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc;
|
||||
import ca.uhn.fhir.rest.server.sched.ISchedulerService;
|
||||
import ca.uhn.fhir.rest.server.sched.ScheduledJobDefinition;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -58,13 +58,23 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
|
|||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(StaleSearchDeletingSvcImpl.class.getName());
|
||||
jobDetail.setJobClass(StaleSearchDeletingSvcImpl.SubmitJob.class);
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleClusteredJob(DEFAULT_CUTOFF_SLACK, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private IStaleSearchDeletingSvc myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.schedulePollForStaleSearches();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
@Override
|
||||
public synchronized void schedulePollForStaleSearches() {
|
||||
|
@ -72,14 +82,4 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
|
|||
pollForStaleSearchesAndDeleteThem();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
@Autowired
|
||||
private IStaleSearchDeletingSvc myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.schedulePollForStaleSearches();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ package ca.uhn.fhir.jpa.search.cache;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.rest.server.sched.ISchedulerService;
|
||||
import ca.uhn.fhir.rest.server.sched.ScheduledJobDefinition;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
@ -51,10 +51,10 @@ public abstract class BaseSearchCacheSvcImpl implements ISearchCacheSvc {
|
|||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(BaseSearchCacheSvcImpl.class.getName());
|
||||
jobDetail.setJobClass(BaseSearchCacheSvcImpl.SubmitJob.class);
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public abstract class BaseSearchCacheSvcImpl implements ISearchCacheSvc {
|
|||
|
||||
protected abstract void flushLastUpdated(Long theSearchId, Date theLastUpdated);
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private ISearchCacheSvc myTarget;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceReindexJobEntity;
|
||||
import ca.uhn.fhir.jpa.model.entity.ForcedId;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
|
@ -46,7 +47,6 @@ import org.apache.commons.lang3.time.DateUtils;
|
|||
import org.hibernate.search.util.impl.Executors;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -146,6 +146,7 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
public void start() {
|
||||
myTxTemplate = new TransactionTemplate(myTxManager);
|
||||
initExecutor();
|
||||
scheduleJob();
|
||||
}
|
||||
|
||||
public void initExecutor() {
|
||||
|
@ -160,6 +161,13 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
);
|
||||
}
|
||||
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleClusteredJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Long markAllResourcesForReindexing() {
|
||||
|
@ -187,12 +195,14 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
return job.getId();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(ResourceReindexingSvcImpl.class.getName());
|
||||
jobDetail.setJobClass(ResourceReindexingSvcImpl.SubmitJob.class);
|
||||
mySchedulerService.scheduleClusteredJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private IResourceReindexingSvc myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.runReindexingPass();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -545,14 +555,4 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
return myUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
@Autowired
|
||||
private IResourceReindexingSvc myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.runReindexingPass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.*;
|
|||
@Component
|
||||
public class CacheWarmingSvcImpl implements ICacheWarmingSvc {
|
||||
|
||||
public static final long JOB_INTERVAL_MILLIS = 10 * DateUtils.MILLIS_PER_SECOND;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(CacheWarmingSvcImpl.class);
|
||||
@Autowired
|
||||
private DaoConfig myDaoConfig;
|
||||
|
@ -108,9 +107,9 @@ public class CacheWarmingSvcImpl implements ICacheWarmingSvc {
|
|||
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(this.getClass().getName());
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleClusteredJob(JOB_INTERVAL_MILLIS, jobDetail);
|
||||
mySchedulerService.scheduleClusteredJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -75,7 +75,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
@Service
|
||||
public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc {
|
||||
public static final long JOB_INTERVAL_MILLIS = DateUtils.MILLIS_PER_SECOND;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionTriggeringProvider.class);
|
||||
private static final int DEFAULT_MAX_SUBMIT = 10000;
|
||||
private final List<SubscriptionTriggeringJobDetails> myActiveJobs = new ArrayList<>();
|
||||
|
@ -385,9 +384,9 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
|
|||
|
||||
private void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(this.getClass().getName());
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(JOB_INTERVAL_MILLIS, jobDetail);
|
||||
mySchedulerService.scheduleLocalJob(DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -30,6 +30,7 @@ import ca.uhn.fhir.jpa.entity.*;
|
|||
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum;
|
||||
import ca.uhn.fhir.jpa.model.cross.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
|
||||
|
@ -69,7 +70,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.codesystems.ConceptSubsumptionOutcome;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -206,23 +206,6 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc, ApplicationCo
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void buildTranslationCaches() {
|
||||
Long timeout = myDaoConfig.getTranslationCachesExpireAfterWriteInMinutes();
|
||||
|
||||
myTranslationCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(timeout, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
myTranslationWithReverseCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(timeout, TimeUnit.MINUTES)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is present only for unit tests, do not call from client code
|
||||
*/
|
||||
|
@ -1300,18 +1283,46 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc, ApplicationCo
|
|||
RuleBasedTransactionAttribute rules = new RuleBasedTransactionAttribute();
|
||||
rules.getRollbackRules().add(new NoRollbackRuleAttribute(ExpansionTooCostlyException.class));
|
||||
myTxTemplate = new TransactionTemplate(myTransactionManager, rules);
|
||||
buildTranslationCaches();
|
||||
scheduleJob();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
private void buildTranslationCaches() {
|
||||
Long timeout = myDaoConfig.getTranslationCachesExpireAfterWriteInMinutes();
|
||||
|
||||
myTranslationCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(timeout, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
myTranslationWithReverseCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.expireAfterWrite(timeout, TimeUnit.MINUTES)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void scheduleJob() {
|
||||
// FIXME KHS what does this mean?
|
||||
// Register scheduled job to pre-expand ValueSets
|
||||
// In the future it would be great to make this a cluster-aware task somehow
|
||||
ScheduledJobDefinition vsJobDefinition = new ScheduledJobDefinition();
|
||||
vsJobDefinition.setId(BaseTermReadSvcImpl.class.getName() + "_preExpandValueSets");
|
||||
vsJobDefinition.setJobClass(PreExpandValueSetsJob.class);
|
||||
vsJobDefinition.setId(getClass().getName());
|
||||
vsJobDefinition.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleClusteredJob(10 * DateUtils.MILLIS_PER_MINUTE, vsJobDefinition);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private ITermReadSvc myTerminologySvc;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTerminologySvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void storeTermConceptMapAndChildren(ResourceTable theResourceTable, ConceptMap theConceptMap) {
|
||||
|
@ -1865,17 +1876,6 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc, ApplicationCo
|
|||
.findFirst();
|
||||
}
|
||||
|
||||
public static class PreExpandValueSetsJob implements Job {
|
||||
|
||||
@Autowired
|
||||
private ITermReadSvc myTerminologySvc;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTerminologySvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
}
|
||||
}
|
||||
|
||||
static List<TermConcept> toPersistedConcepts(List<CodeSystem.ConceptDefinitionComponent> theConcept, TermCodeSystemVersion theCodeSystemVersion) {
|
||||
ArrayList<TermConcept> retVal = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ import java.util.List;
|
|||
|
||||
public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
||||
|
||||
private static final int JOB_INTERVAL_MILLIS = 5000;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(TermDeferredStorageSvcImpl.class);
|
||||
@Autowired
|
||||
protected ITermConceptDao myConceptDao;
|
||||
|
@ -267,7 +266,7 @@ public class TermDeferredStorageSvcImpl implements ITermDeferredStorageSvc {
|
|||
ScheduledJobDefinition jobDefinition = new ScheduledJobDefinition();
|
||||
jobDefinition.setId(this.getClass().getName());
|
||||
jobDefinition.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(JOB_INTERVAL_MILLIS, jobDefinition);
|
||||
mySchedulerService.scheduleLocalJob(5000, jobDefinition);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -54,7 +54,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
|
||||
public class TermReindexingSvcImpl implements ITermReindexingSvc {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(TermReindexingSvcImpl.class);
|
||||
private static final long JOB_INTERVAL_MILLIS = DateUtils.MILLIS_PER_MINUTE;
|
||||
private static boolean ourForceSaveDeferredAlwaysForUnitTest;
|
||||
@Autowired
|
||||
protected ITermConceptDao myConceptDao;
|
||||
|
@ -157,7 +156,7 @@ public class TermReindexingSvcImpl implements ITermReindexingSvc {
|
|||
ScheduledJobDefinition jobDefinition = new ScheduledJobDefinition();
|
||||
jobDefinition.setId(this.getClass().getName());
|
||||
jobDefinition.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(JOB_INTERVAL_MILLIS, jobDefinition);
|
||||
mySchedulerService.scheduleLocalJob(DateUtils.MILLIS_PER_MINUTE, jobDefinition);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -20,12 +20,12 @@ package ca.uhn.fhir.jpa.util;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.sched.ISchedulerService;
|
||||
import ca.uhn.fhir.rest.server.sched.ScheduledJobDefinition;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -92,14 +92,14 @@ public class ResourceCountCache {
|
|||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(ResourceCountCache.class.getName());
|
||||
jobDetail.setJobClass(ResourceCountCache.SubmitJob.class);
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(10 * DateUtils.MILLIS_PER_MINUTE, jobDetail);
|
||||
}
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private ResourceCountCache myTarget;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.interceptor.api.HookParams;
|
|||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
|
||||
import ca.uhn.fhir.jpa.searchparam.JpaRuntimeSearchParam;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParamConstants;
|
||||
|
@ -49,7 +50,6 @@ import org.hl7.fhir.dstu3.model.Extension;
|
|||
import org.hl7.fhir.dstu3.model.SearchParameter;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -724,13 +724,23 @@ public class SearchParamRegistryImpl implements ISearchParamRegistry {
|
|||
}
|
||||
|
||||
@PostConstruct
|
||||
public void registerScheduledJob() {
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(SearchParamRegistryImpl.class.getName());
|
||||
jobDetail.setJobClass(SubmitJob.class);
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(10 * DateUtils.MILLIS_PER_SECOND, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private ISearchParamRegistry myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.refreshCacheIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean refreshCacheIfNecessary() {
|
||||
if (myActiveSearchParams == null || System.currentTimeMillis() - REFRESH_INTERVAL > myLastRefresh) {
|
||||
|
@ -767,17 +777,6 @@ public class SearchParamRegistryImpl implements ISearchParamRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
@Autowired
|
||||
private ISearchParamRegistry myTarget;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext theContext) {
|
||||
myTarget.refreshCacheIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Map<String, RuntimeSearchParam>> createBuiltInSearchParamMap(FhirContext theFhirContext) {
|
||||
Map<String, Map<String, RuntimeSearchParam>> resourceNameToSearchParams = new HashMap<>();
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ import java.util.concurrent.Semaphore;
|
|||
@Service
|
||||
@Lazy
|
||||
public class SubscriptionLoader {
|
||||
public static final long JOB_INTERVAL_MILLIS = DateUtils.MILLIS_PER_MINUTE;
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(SubscriptionLoader.class);
|
||||
private static final int MAX_RETRIES = 60; // 60 * 5 seconds = 5 minutes
|
||||
private final Object mySyncSubscriptionsLock = new Object();
|
||||
|
@ -90,9 +89,9 @@ public class SubscriptionLoader {
|
|||
@PostConstruct
|
||||
public void scheduleJob() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(this.getClass().getName());
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(JOB_INTERVAL_MILLIS, jobDetail);
|
||||
mySchedulerService.scheduleLocalJob(DateUtils.MILLIS_PER_MINUTE, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhirtest.interceptor;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
|
@ -13,7 +14,6 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
@ -55,7 +55,15 @@ public class AnalyticsInterceptor extends InterceptorAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public static class SubmitJob implements Job {
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(Job.class);
|
||||
mySchedulerService.scheduleLocalJob(5000, jobDetail);
|
||||
}
|
||||
|
||||
public static class Job implements HapiJob {
|
||||
@Autowired
|
||||
private AnalyticsInterceptor myAnalyticsInterceptor;
|
||||
|
||||
|
@ -65,14 +73,6 @@ public class AnalyticsInterceptor extends InterceptorAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
ScheduledJobDefinition jobDetail = new ScheduledJobDefinition();
|
||||
jobDetail.setId(getClass().getName());
|
||||
jobDetail.setJobClass(SubmitJob.class);
|
||||
mySchedulerService.scheduleLocalJob(5000, jobDetail);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void stop() throws IOException {
|
||||
if (myHttpClient instanceof CloseableHttpClient) {
|
||||
|
|
|
@ -15,5 +15,5 @@ public interface IHapiScheduler {
|
|||
|
||||
void logStatusForUnitTest();
|
||||
|
||||
void scheduleFixedDelay(long theIntervalMillis, ScheduledJobDefinition theJobDefinition);
|
||||
void scheduleJob(long theIntervalMillis, ScheduledJobDefinition theJobDefinition);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue