Force the caller to run the bundle task if we are operating with <= 1 pool size

This commit is contained in:
Tadgh 2021-08-27 12:01:10 -04:00
parent 3a7d778591
commit c2c6e0b440
2 changed files with 13 additions and 4 deletions

View File

@ -349,8 +349,13 @@ public abstract class BaseTransactionProcessor {
for (int i=0; i<requestEntriesSize; i++ ) { for (int i=0; i<requestEntriesSize; i++ ) {
nextRequestEntry = requestEntries.get(i); nextRequestEntry = requestEntries.get(i);
BundleTask bundleTask = new BundleTask(completionLatch, theRequestDetails, responseMap, i, nextRequestEntry, theNestedMode); BundleTask bundleTask = new BundleTask(completionLatch, theRequestDetails, responseMap, i, nextRequestEntry, theNestedMode);
//Don't spin up a new thread for nothing if batch size is <=1
if (myDaoConfig.getBundleBatchPoolSize() <= 1) {
bundleTask.call();
} else {
myExecutor.submit(bundleTask); myExecutor.submit(bundleTask);
} }
}
// waiting for all tasks to be completed // waiting for all tasks to be completed
AsyncUtil.awaitLatchAndIgnoreInterrupt(completionLatch, 300L, TimeUnit.SECONDS); AsyncUtil.awaitLatchAndIgnoreInterrupt(completionLatch, 300L, TimeUnit.SECONDS);
@ -1557,7 +1562,7 @@ public abstract class BaseTransactionProcessor {
public class BundleTask implements Callable<Void> { public class BundleTask implements Callable<Void> {
private CountDownLatch myCompletedLatch; private CountDownLatch myCompletedLatch;
private ServletRequestDetails myRequestDetails; private RequestDetails myRequestDetails;
private IBase myNextReqEntry; private IBase myNextReqEntry;
private Map<Integer, Object> myResponseMap; private Map<Integer, Object> myResponseMap;
private int myResponseOrder; private int myResponseOrder;
@ -1565,7 +1570,7 @@ public abstract class BaseTransactionProcessor {
protected BundleTask(CountDownLatch theCompletedLatch, RequestDetails theRequestDetails, Map<Integer, Object> theResponseMap, int theResponseOrder, IBase theNextReqEntry, boolean theNestedMode) { protected BundleTask(CountDownLatch theCompletedLatch, RequestDetails theRequestDetails, Map<Integer, Object> theResponseMap, int theResponseOrder, IBase theNextReqEntry, boolean theNestedMode) {
this.myCompletedLatch = theCompletedLatch; this.myCompletedLatch = theCompletedLatch;
this.myRequestDetails = (ServletRequestDetails)theRequestDetails; this.myRequestDetails = theRequestDetails;
this.myNextReqEntry = theNextReqEntry; this.myNextReqEntry = theNextReqEntry;
this.myResponseMap = theResponseMap; this.myResponseMap = theResponseMap;
this.myResponseOrder = theResponseOrder; this.myResponseOrder = theResponseOrder;

View File

@ -117,12 +117,16 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
myDaoConfig.setAllowInlineMatchUrlReferences(false); myDaoConfig.setAllowInlineMatchUrlReferences(false);
myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete()); myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete());
myModelConfig.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED); myModelConfig.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED);
myDaoConfig.setBundleBatchPoolSize(new DaoConfig().getBundleBatchPoolSize());
myDaoConfig.setBundleBatchMaxPoolSize(new DaoConfig().getBundleBatchMaxPoolSize());
} }
@BeforeEach @BeforeEach
public void beforeDisableResultReuse() { public void beforeDisableResultReuse() {
myInterceptorRegistry.registerInterceptor(myInterceptor); myInterceptorRegistry.registerInterceptor(myInterceptor);
myDaoConfig.setReuseCachedSearchResultsForMillis(null); myDaoConfig.setReuseCachedSearchResultsForMillis(null);
myDaoConfig.setBundleBatchPoolSize(1);
myDaoConfig.setBundleBatchMaxPoolSize(1);
} }
private Bundle createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb theVerb) { private Bundle createInputTransactionWithPlaceholderIdInMatchUrl(HTTPVerb theVerb) {