add executorService config

This commit is contained in:
justin.mckelvy 2023-05-15 21:46:49 -06:00
parent 05defb58c5
commit b41c96f259
2 changed files with 16 additions and 0 deletions

View File

@ -74,12 +74,15 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor; import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool;
@ -303,6 +306,13 @@ public abstract class BaseClinicalReasoningConfig {
SecurityContextHolder.getContext()); SecurityContextHolder.getContext());
} }
@Bean
public ExecutorService measureExecutor() {
ExecutorService executor = Executors.newFixedThreadPool(CrProperties.MeasureProperties.DEFAULT_THREADS_BATCH_SIZE);
executor = new DelegatingSecurityContextExecutorService(executor);
return executor;
}
@Bean @Bean
public PreExpandedValidationSupportLoader preExpandedValidationSupportLoader(ValidationSupportChain theSupportChain, public PreExpandedValidationSupportLoader preExpandedValidationSupportLoader(ValidationSupportChain theSupportChain,
FhirContext theFhirContext) { FhirContext theFhirContext) {

View File

@ -63,6 +63,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService;
import static ca.uhn.fhir.cr.constant.MeasureReportConstants.COUNTRY_CODING_SYSTEM_CODE; import static ca.uhn.fhir.cr.constant.MeasureReportConstants.COUNTRY_CODING_SYSTEM_CODE;
import static ca.uhn.fhir.cr.constant.MeasureReportConstants.MEASUREREPORT_MEASURE_SUPPLEMENTALDATA_EXTENSION; import static ca.uhn.fhir.cr.constant.MeasureReportConstants.MEASUREREPORT_MEASURE_SUPPLEMENTALDATA_EXTENSION;
@ -141,6 +142,9 @@ public class MeasureService implements IDaoRegistryUser {
@Autowired @Autowired
protected DaoRegistry myDaoRegistry; protected DaoRegistry myDaoRegistry;
@Autowired
private ExecutorService myMeasureExecutor;
protected RequestDetails myRequestDetails; protected RequestDetails myRequestDetails;
public RequestDetails getRequestDetails() { public RequestDetails getRequestDetails() {
@ -194,6 +198,8 @@ public class MeasureService implements IDaoRegistryUser {
TerminologyProvider terminologyProvider; TerminologyProvider terminologyProvider;
myMeasureEvaluationOptions.setMeasureExecutor(myMeasureExecutor);
if (theTerminologyEndpoint != null) { if (theTerminologyEndpoint != null) {
IGenericClient client = Clients.forEndpoint(getFhirContext(), theTerminologyEndpoint); IGenericClient client = Clients.forEndpoint(getFhirContext(), theTerminologyEndpoint);
terminologyProvider = new R4FhirTerminologyProvider(client); terminologyProvider = new R4FhirTerminologyProvider(client);