Skip to content

Commit

Permalink
Async security context (#306)
Browse files Browse the repository at this point in the history
* adding security context delegation to threaded executor

* adding dstu3 executor delegate access

* adding spring context dependency

* adding executor as a property to be injected

* remove unused imports

* remove spring dependency

---------

Co-authored-by: justin.mckelvy <justin.mckelvy@smilecdr.com>
Co-authored-by: JP <jonathan.i.percival@gmail.com>
  • Loading branch information
3 people authored May 16, 2023
1 parent 97d815a commit 938ed77
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;


import org.opencds.cqf.cql.evaluator.fhir.util.ValidationProfile;

Expand All @@ -11,11 +13,20 @@ public static MeasureEvaluationOptions defaultOptions() {
}

private boolean isThreadedEnabled = false;

private Executor measureExecutor;
private Integer threadedBatchSize = 200;
private Integer numThreads = null;
private boolean isValidationEnabled = false;
private Map<String, ValidationProfile> validationProfiles = new HashMap<>();

public Executor getMeasureExecutor(){
return this.measureExecutor;
}

public void setMeasureExecutor(Executor cqlExecutor){
this.measureExecutor = cqlExecutor;
}
public boolean isThreadedEnabled() {
return this.isThreadedEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

import javax.inject.Inject;
Expand Down Expand Up @@ -255,12 +253,11 @@ protected CompletableFuture<MeasureReport> runEvaluate(Measure measure, String p
Bundle additionalData) {

if (measureEvaluationOptions.isThreadedEnabled()) {
ExecutorService executor =
Executors.newFixedThreadPool(this.measureEvaluationOptions.getNumThreads());
var myMeasureExecutor = this.measureEvaluationOptions.getMeasureExecutor();
return CompletableFuture.supplyAsync(
() -> this.innerEvaluateMeasure(measure, periodStart, periodEnd, reportType, subjectIds,
fhirDal, contentEndpoint, terminologyEndpoint, dataEndpoint, additionalData),
executor);
myMeasureExecutor);
} else {
return CompletableFuture.completedFuture(
this.innerEvaluateMeasure(measure, periodStart, periodEnd, reportType, subjectIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

import javax.inject.Inject;
Expand Down Expand Up @@ -304,18 +302,20 @@ public MeasureReport evaluateMeasure(Measure measure, String periodStart, String
}
}


protected CompletableFuture<MeasureReport> runEvaluate(Measure measure, String periodStart,
String periodEnd, String reportType, List<String> subjectIds, FhirDal fhirDal,
Endpoint contentEndpoint, Endpoint terminologyEndpoint, Endpoint dataEndpoint,
Bundle additionalData) {

if (measureEvaluationOptions.isThreadedEnabled()) {
ExecutorService executor =
Executors.newFixedThreadPool(this.measureEvaluationOptions.getNumThreads());

var myMeasureExecutor = this.measureEvaluationOptions.getMeasureExecutor();

return CompletableFuture.supplyAsync(
() -> this.innerEvaluateMeasure(measure, periodStart, periodEnd, reportType, subjectIds,
fhirDal, contentEndpoint, terminologyEndpoint, dataEndpoint, additionalData),
executor);
myMeasureExecutor);
} else {
return CompletableFuture.completedFuture(
this.innerEvaluateMeasure(measure, periodStart, periodEnd, reportType, subjectIds,
Expand Down

0 comments on commit 938ed77

Please sign in to comment.