Use a direct subclass for the resource cache
This commit is contained in:
parent
994f2992d1
commit
87666a1622
|
@ -4,7 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.jpa.dao.*;
|
import ca.uhn.fhir.jpa.dao.*;
|
||||||
import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu2;
|
import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu2;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
import ca.uhn.fhir.validation.IValidatorModule;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
@ -19,8 +19,6 @@ import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR JPA Server
|
* HAPI FHIR JPA Server
|
||||||
|
@ -118,8 +116,8 @@ public class BaseDstu2Config extends BaseConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "myResourceCountsCache")
|
@Bean(name = "myResourceCountsCache")
|
||||||
public SingleItemLoadingCache<Map<String, Long>> resourceCountsCache() {
|
public ResourceCountCache resourceCountsCache() {
|
||||||
SingleItemLoadingCache<Map<String, Long>> retVal = new SingleItemLoadingCache<>(() -> systemDaoDstu2().getResourceCounts());
|
ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoDstu2().getResourceCounts());
|
||||||
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu3;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvcDstu3;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvcDstu3;
|
||||||
import ca.uhn.fhir.jpa.term.TerminologyLoaderSvcImpl;
|
import ca.uhn.fhir.jpa.term.TerminologyLoaderSvcImpl;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
import ca.uhn.fhir.validation.IValidatorModule;
|
||||||
|
@ -83,8 +84,8 @@ public class BaseDstu3Config extends BaseConfig {
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "myResourceCountsCache")
|
@Bean(name = "myResourceCountsCache")
|
||||||
public SingleItemLoadingCache<Map<String, Long>> resourceCountsCache() {
|
public ResourceCountCache resourceCountsCache() {
|
||||||
SingleItemLoadingCache<Map<String, Long>> retVal = new SingleItemLoadingCache<>(() -> systemDaoDstu3().getResourceCounts());
|
ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoDstu3().getResourceCounts());
|
||||||
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import ca.uhn.fhir.jpa.term.HapiTerminologySvcR4;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvcR4;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvcR4;
|
||||||
import ca.uhn.fhir.jpa.term.TerminologyLoaderSvcImpl;
|
import ca.uhn.fhir.jpa.term.TerminologyLoaderSvcImpl;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
import ca.uhn.fhir.validation.IValidatorModule;
|
||||||
|
@ -97,8 +98,8 @@ public class BaseR4Config extends BaseConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "myResourceCountsCache")
|
@Bean(name = "myResourceCountsCache")
|
||||||
public SingleItemLoadingCache<Map<String, Long>> resourceCountsCache() {
|
public ResourceCountCache resourceCountsCache() {
|
||||||
SingleItemLoadingCache<Map<String, Long>> retVal = new SingleItemLoadingCache<>(() -> systemDaoR4().getResourceCounts());
|
ResourceCountCache retVal = new ResourceCountCache(() -> systemDaoR4().getResourceCounts());
|
||||||
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
retVal.setCacheMillis(60 * DateUtils.MILLIS_PER_SECOND);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,7 @@ import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||||
import ca.uhn.fhir.jpa.dao.data.ITermConceptDao;
|
import ca.uhn.fhir.jpa.dao.data.ITermConceptDao;
|
||||||
import ca.uhn.fhir.jpa.entity.ForcedId;
|
import ca.uhn.fhir.jpa.entity.ForcedId;
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.util.ExpungeOptions;
|
import ca.uhn.fhir.jpa.util.*;
|
||||||
import ca.uhn.fhir.jpa.util.ExpungeOutcome;
|
|
||||||
import ca.uhn.fhir.jpa.util.ReindexFailureException;
|
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
|
||||||
import ca.uhn.fhir.util.StopWatch;
|
import ca.uhn.fhir.util.StopWatch;
|
||||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
|
@ -72,7 +69,7 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
|
||||||
private IResourceTableDao myResourceTableDao;
|
private IResourceTableDao myResourceTableDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("myResourceCountsCache")
|
@Qualifier("myResourceCountsCache")
|
||||||
public SingleItemLoadingCache<Map<String, Long>> myResourceCountsCache;
|
public ResourceCountCache myResourceCountsCache;
|
||||||
|
|
||||||
|
|
||||||
private int doPerformReindexingPass(final Integer theCount) {
|
private int doPerformReindexingPass(final Integer theCount) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||||
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
|
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||||
|
@ -55,7 +56,7 @@ public class JpaConformanceProviderDstu2 extends ServerConformanceProvider {
|
||||||
private boolean myIncludeResourceCounts;
|
private boolean myIncludeResourceCounts;
|
||||||
private RestfulServer myRestfulServer;
|
private RestfulServer myRestfulServer;
|
||||||
private IFhirSystemDao<Bundle, MetaDt> mySystemDao;
|
private IFhirSystemDao<Bundle, MetaDt> mySystemDao;
|
||||||
private SingleItemLoadingCache<Map<String, Long>> myResourceCountsCache;
|
private ResourceCountCache myResourceCountsCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.jpa.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
public class ResourceCountCache extends SingleItemLoadingCache<Map<String, Long>> {
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public ResourceCountCache(Callable<Map<String, Long>> theFetcher) {
|
||||||
|
super(theFetcher);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
|
||||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||||
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||||
|
@ -51,7 +52,7 @@ import static org.mockito.Mockito.mock;
|
||||||
public abstract class BaseJpaDstu2Test extends BaseJpaTest {
|
public abstract class BaseJpaDstu2Test extends BaseJpaTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("myResourceCountsCache")
|
@Qualifier("myResourceCountsCache")
|
||||||
protected SingleItemLoadingCache<Map<String, Long>> myResourceCountsCache;
|
protected ResourceCountCache myResourceCountsCache;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ISearchParamRegistry mySearchParamRegsitry;
|
protected ISearchParamRegistry mySearchParamRegsitry;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -13,6 +13,7 @@ import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||||
import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc;
|
import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc;
|
||||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
||||||
import ca.uhn.fhir.parser.IParser;
|
import ca.uhn.fhir.parser.IParser;
|
||||||
|
@ -59,7 +60,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("myResourceCountsCache")
|
@Qualifier("myResourceCountsCache")
|
||||||
protected SingleItemLoadingCache<Map<String, Long>> myResourceCountsCache;
|
protected ResourceCountCache myResourceCountsCache;
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("myCoverageDaoDstu3")
|
@Qualifier("myCoverageDaoDstu3")
|
||||||
protected IFhirResourceDao<Coverage> myCoverageDao;
|
protected IFhirResourceDao<Coverage> myCoverageDao;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||||
import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc;
|
import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc;
|
||||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||||
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
||||||
import ca.uhn.fhir.parser.IParser;
|
import ca.uhn.fhir.parser.IParser;
|
||||||
|
@ -59,7 +60,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("myResourceCountsCache")
|
@Qualifier("myResourceCountsCache")
|
||||||
protected SingleItemLoadingCache<Map<String, Long>> myResourceCountsCache;
|
protected ResourceCountCache myResourceCountsCache;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected IResourceLinkDao myResourceLinkDao;
|
protected IResourceLinkDao myResourceLinkDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.dao.r4.SearchParamRegistryR4;
|
||||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||||
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||||
import ca.uhn.fhir.jpa.subscription.resthook.SubscriptionRestHookInterceptor;
|
import ca.uhn.fhir.jpa.subscription.resthook.SubscriptionRestHookInterceptor;
|
||||||
|
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainR4;
|
||||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||||
|
@ -63,7 +64,7 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
|
||||||
private TerminologyUploaderProviderR4 myTerminologyUploaderProvider;
|
private TerminologyUploaderProviderR4 myTerminologyUploaderProvider;
|
||||||
private Object ourGraphQLProvider;
|
private Object ourGraphQLProvider;
|
||||||
private boolean ourRestHookSubscriptionInterceptorRequested;
|
private boolean ourRestHookSubscriptionInterceptorRequested;
|
||||||
protected SingleItemLoadingCache<Map<String, Long>> ourResourceCountsCache;
|
protected ResourceCountCache ourResourceCountsCache;
|
||||||
|
|
||||||
public BaseResourceProviderR4Test() {
|
public BaseResourceProviderR4Test() {
|
||||||
super();
|
super();
|
||||||
|
@ -102,7 +103,7 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
|
||||||
ourRestServer.setServerConformanceProvider(confProvider);
|
ourRestServer.setServerConformanceProvider(confProvider);
|
||||||
|
|
||||||
ourPagingProvider = myAppCtx.getBean(DatabaseBackedPagingProvider.class);
|
ourPagingProvider = myAppCtx.getBean(DatabaseBackedPagingProvider.class);
|
||||||
ourResourceCountsCache = (SingleItemLoadingCache<Map<String, Long>>) myAppCtx.getBean("myResourceCountsCache");
|
ourResourceCountsCache = (ResourceCountCache) myAppCtx.getBean("myResourceCountsCache");
|
||||||
|
|
||||||
Server server = new Server(ourPort);
|
Server server = new Server(ourPort);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue