Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
jamesagnew 2020-06-10 09:57:24 -04:00
commit 7d6f8fe612
3 changed files with 27 additions and 21 deletions

View File

@ -180,18 +180,21 @@ public class CircularQueueCaptureQueriesListener extends BaseCaptureQueriesListe
/**
* Log all captured UPDATE queries
*/
public void logUpdateQueriesForCurrentThread() {
public String logUpdateQueriesForCurrentThread() {
List<String> queries = getUpdateQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.collect(Collectors.toList());
ourLog.info("Update Queries:\n{}", String.join("\n", queries));
String joined = String.join("\n", queries);
ourLog.info("Update Queries:\n{}", joined);
return joined;
}
/**
* Log all captured SELECT queries
* @return
*/
public void logSelectQueriesForCurrentThread(int... theIndexes) {
public String logSelectQueriesForCurrentThread(int... theIndexes) {
List<String> queries = getSelectQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
@ -205,7 +208,9 @@ public class CircularQueueCaptureQueriesListener extends BaseCaptureQueriesListe
queries = newList;
}
ourLog.info("Select Queries:\n{}", String.join("\n", queries));
String queriesAsString = String.join("\n", queries);
ourLog.info("Select Queries:\n{}", queriesAsString);
return queriesAsString;
}
/**
@ -234,12 +239,14 @@ public class CircularQueueCaptureQueriesListener extends BaseCaptureQueriesListe
/**
* Log all captured INSERT queries
*/
public void logInsertQueriesForCurrentThread() {
public String logInsertQueriesForCurrentThread() {
List<String> queries = getInsertQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.collect(Collectors.toList());
ourLog.info("Insert Queries:\n{}", String.join("\n", queries));
String queriesAsString = String.join("\n", queries);
ourLog.info("Insert Queries:\n{}", queriesAsString);
return queriesAsString;
}
/**
@ -278,14 +285,17 @@ public class CircularQueueCaptureQueriesListener extends BaseCaptureQueriesListe
/**
* Log all captured DELETE queries
*/
public void logDeleteQueriesForCurrentThread() {
public String logDeleteQueriesForCurrentThread() {
List<String> queries = getDeleteQueriesForCurrentThread()
.stream()
.map(CircularQueueCaptureQueriesListener::formatQueryAsSql)
.collect(Collectors.toList());
ourLog.info("Delete Queries:\n{}", String.join("\n", queries));
String joined = String.join("\n", queries);
ourLog.info("Delete Queries:\n{}", joined);
return joined;
}
/**
* Log all captured DELETE queries
*/

View File

@ -145,14 +145,10 @@ public class FhirResourceDaoR4QueryCountTest extends BaseJpaR4Test {
// Validate once
myCaptureQueriesListener.clear();
myObservationDao.validate(obs, null, null, null, null, null, null);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertEquals(8, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size());
myCaptureQueriesListener.logUpdateQueriesForCurrentThread();
assertEquals(0, myCaptureQueriesListener.getUpdateQueriesForCurrentThread().size());
myCaptureQueriesListener.logInsertQueriesForCurrentThread();
assertEquals(0, myCaptureQueriesListener.getInsertQueriesForCurrentThread().size());
myCaptureQueriesListener.logDeleteQueriesForCurrentThread();
assertEquals(0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size());
assertEquals(myCaptureQueriesListener.logSelectQueriesForCurrentThread(), 10, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size());
assertEquals(myCaptureQueriesListener.logUpdateQueriesForCurrentThread(), 0, myCaptureQueriesListener.getUpdateQueriesForCurrentThread().size());
assertEquals(myCaptureQueriesListener.logInsertQueriesForCurrentThread(), 0, myCaptureQueriesListener.getInsertQueriesForCurrentThread().size());
assertEquals(myCaptureQueriesListener.logDeleteQueriesForCurrentThread(), 0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size());
// Validate again (should rely only on caches)
myCaptureQueriesListener.clear();
@ -1131,8 +1127,8 @@ public class FhirResourceDaoR4QueryCountTest extends BaseJpaR4Test {
myCaptureQueriesListener.clear();
mySystemDao.transaction(mySrd, input);
myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertEquals(3, myCaptureQueriesListener.countSelectQueriesForCurrentThread());
assertEquals(8, myCaptureQueriesListener.countInsertQueriesForCurrentThread());
assertEquals(myCaptureQueriesListener.logSelectQueriesForCurrentThread(), 3, myCaptureQueriesListener.countSelectQueriesForCurrentThread());
assertEquals(myCaptureQueriesListener.logInsertQueriesForCurrentThread(), 8, myCaptureQueriesListener.countInsertQueriesForCurrentThread());
myCaptureQueriesListener.logUpdateQueriesForCurrentThread();
assertEquals(1, myCaptureQueriesListener.countUpdateQueriesForCurrentThread());
assertEquals(0, myCaptureQueriesListener.countDeleteQueriesForCurrentThread());

View File

@ -36,17 +36,17 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple
super(theWrap.getFhirContext(), theWrap);
myValidateCodeCache = Caffeine
.newBuilder()
.expireAfterWrite(60, TimeUnit.SECONDS)
.expireAfterWrite(10, TimeUnit.MINUTES)
.maximumSize(5000)
.build();
myLookupCodeCache = Caffeine
.newBuilder()
.expireAfterWrite(60, TimeUnit.SECONDS)
.expireAfterWrite(10, TimeUnit.MINUTES)
.maximumSize(5000)
.build();
myCache = Caffeine
.newBuilder()
.expireAfterWrite(60, TimeUnit.SECONDS)
.expireAfterWrite(10, TimeUnit.MINUTES)
.maximumSize(5000)
.build();
}