mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-06 20:19:42 +00:00
Reindex Behaviour Issues (#4261)
* fixmes for ND * address FIXME comments * fix tests * increase max retries * fix resource id chunking logic * fix test * add modular patient * change log * version bump Co-authored-by: Ken Stevens <ken@smilecdr.com> Co-authored-by: nathaniel.doef <nathaniel.doef@smilecdr.com>
This commit is contained in:
parent
7f67493922
commit
1722812834
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -145,6 +145,9 @@ public class Constants {
|
||||
public static final String HEADER_SUFFIX_CT_UTF_8 = "; charset=UTF-8";
|
||||
public static final String HEADERVALUE_CORS_ALLOW_METHODS_ALL = "GET, POST, PUT, DELETE, OPTIONS";
|
||||
public static final String HEADER_REWRITE_HISTORY = "X-Rewrite-History";
|
||||
public static final String HEADER_RETRY_ON_VERSION_CONFLICT = "X-Retry-On-Version-Conflict";
|
||||
public static final String HEADER_MAX_RETRIES = "max-retries";
|
||||
public static final String HEADER_RETRY = "retry";
|
||||
public static final Map<Integer, String> HTTP_STATUS_NAMES;
|
||||
public static final String LINK_FHIR_BASE = "fhir-base";
|
||||
public static final String LINK_FIRST = "first";
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -3,14 +3,14 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-bom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>HAPI FHIR BOM</name>
|
||||
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-cli</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../hapi-deployable-pom</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
type: fix
|
||||
issue: 4267
|
||||
title: "Previously, if the `$reindex` operation failed with a `ResourceVersionConflictException` the related
|
||||
batch job would fail. This has been corrected by adding 10 retry attempts for transactions that have
|
||||
failed with a `ResourceVersionConflictException` during the `$reindex` operation. In addition, the `ResourceIdListStep`
|
||||
was submitting one more resource than expected (i.e. 1001 records processed during a `$reindex` operation if only 1000
|
||||
`Resources` were in the database). This has been corrected."
|
@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -332,8 +332,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
@Test
|
||||
public void testCreateWithClientAssignedId() {
|
||||
myInterceptorRegistry.registerInterceptor(myRetryInterceptor);
|
||||
String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10";
|
||||
when(mySrd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value));
|
||||
setupRetryBehaviour(mySrd);
|
||||
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -502,8 +501,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
@Test
|
||||
public void testDelete() {
|
||||
myInterceptorRegistry.registerInterceptor(myRetryInterceptor);
|
||||
String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=100";
|
||||
when(mySrd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value));
|
||||
setupRetryBehaviour(mySrd);
|
||||
|
||||
IIdType patientId = runInTransaction(() -> {
|
||||
Patient p = new Patient();
|
||||
@ -664,8 +662,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
@Test
|
||||
public void testPatch() {
|
||||
myInterceptorRegistry.registerInterceptor(myRetryInterceptor);
|
||||
String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10";
|
||||
when(mySrd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value));
|
||||
setupRetryBehaviour(mySrd);
|
||||
|
||||
Patient p = new Patient();
|
||||
p.addName().setFamily("FAMILY");
|
||||
@ -719,8 +716,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
myInterceptorRegistry.registerInterceptor(myRetryInterceptor);
|
||||
|
||||
ServletRequestDetails srd = mock(ServletRequestDetails.class);
|
||||
String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10";
|
||||
when(srd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value));
|
||||
setupRetryBehaviour(srd);
|
||||
when(srd.getUserData()).thenReturn(new HashMap<>());
|
||||
when(srd.getServer()).thenReturn(new RestfulServer(myFhirContext));
|
||||
when(srd.getInterceptorBroadcaster()).thenReturn(new InterceptorService());
|
||||
@ -772,8 +768,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
myDaoConfig.setDeleteEnabled(false);
|
||||
|
||||
ServletRequestDetails srd = mock(ServletRequestDetails.class);
|
||||
String value = UserRequestRetryVersionConflictsInterceptor.RETRY + "; " + UserRequestRetryVersionConflictsInterceptor.MAX_RETRIES + "=10";
|
||||
when(srd.getHeaders(eq(UserRequestRetryVersionConflictsInterceptor.HEADER_NAME))).thenReturn(Collections.singletonList(value));
|
||||
setupRetryBehaviour(srd);
|
||||
when(srd.getUserData()).thenReturn(new HashMap<>());
|
||||
when(srd.getServer()).thenReturn(new RestfulServer(myFhirContext));
|
||||
when(srd.getInterceptorBroadcaster()).thenReturn(new InterceptorService());
|
||||
@ -824,4 +819,9 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
|
||||
|
||||
}
|
||||
|
||||
private void setupRetryBehaviour(ServletRequestDetails theServletRequestDetails) {
|
||||
when(theServletRequestDetails.isRetry()).thenReturn(true);
|
||||
when(theServletRequestDetails.getMaxRetries()).thenReturn(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,14 +11,19 @@ import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
||||
import ca.uhn.fhir.jpa.test.PatientReindexTestHelper;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@ -30,10 +35,13 @@ public class ReindexJobTest extends BaseJpaR4Test {
|
||||
private IJobCoordinator myJobCoordinator;
|
||||
|
||||
private ReindexTestHelper myReindexTestHelper;
|
||||
private PatientReindexTestHelper myPatientReindexTestHelper;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
myReindexTestHelper = new ReindexTestHelper(myFhirContext, myDaoRegistry, mySearchParamRegistry);
|
||||
boolean incrementVersionAfterReindex = false;
|
||||
myPatientReindexTestHelper = new PatientReindexTestHelper(myJobCoordinator, myBatch2JobHelper, myPatientDao, incrementVersionAfterReindex);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@ -167,4 +175,26 @@ public class ReindexJobTest extends BaseJpaR4Test {
|
||||
assertEquals("java.lang.Error: foo message", outcome.getErrorMessage());
|
||||
}
|
||||
|
||||
private static Stream<Arguments> numResourcesParams(){
|
||||
return PatientReindexTestHelper.numResourcesParams();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("numResourcesParams")
|
||||
public void testReindex(int theNumResources){
|
||||
myPatientReindexTestHelper.testReindex(theNumResources);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("numResourcesParams")
|
||||
public void testSequentialReindexOperation(int theNumResources){
|
||||
myPatientReindexTestHelper.testSequentialReindexOperation(theNumResources);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("numResourcesParams")
|
||||
public void testParallelReindexOperation(int theNumResources){
|
||||
myPatientReindexTestHelper.testParallelReindexOperation(theNumResources);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -134,6 +134,11 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest</artifactId>
|
||||
|
@ -0,0 +1,165 @@
|
||||
package ca.uhn.fhir.jpa.test;
|
||||
|
||||
import ca.uhn.fhir.batch2.api.IJobCoordinator;
|
||||
import ca.uhn.fhir.batch2.jobs.reindex.ReindexAppCtx;
|
||||
import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters;
|
||||
import ca.uhn.fhir.batch2.model.JobInstance;
|
||||
import ca.uhn.fhir.batch2.model.JobInstanceStartRequest;
|
||||
import ca.uhn.fhir.batch2.model.StatusEnum;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class PatientReindexTestHelper {
|
||||
|
||||
private static final int VERSION_1 = 1;
|
||||
private static final int VERSION_2 = 2;
|
||||
private static final int VERSION_3 = 3;
|
||||
public static final int JOB_WAIT_TIME = 60;
|
||||
|
||||
private final IJobCoordinator myJobCoordinator;
|
||||
private final Batch2JobHelper myBatch2JobHelper;
|
||||
private final IFhirResourceDao<Patient> myPatientDao;
|
||||
private final boolean myIncrementVersionOnReindex;
|
||||
|
||||
public static Stream<Arguments> numResourcesParams(){
|
||||
return Stream.of(
|
||||
Arguments.of(0),
|
||||
Arguments.of(1),
|
||||
Arguments.of(499),
|
||||
Arguments.of(500),
|
||||
Arguments.of(750),
|
||||
Arguments.of(1000),
|
||||
Arguments.of(1001)
|
||||
);
|
||||
}
|
||||
|
||||
public PatientReindexTestHelper(IJobCoordinator theJobCoordinator, Batch2JobHelper theBatch2JobHelper, IFhirResourceDao<Patient> thePatientDao, boolean theIncrementVersionOnReindex) {
|
||||
myJobCoordinator = theJobCoordinator;
|
||||
myBatch2JobHelper = theBatch2JobHelper;
|
||||
myPatientDao = thePatientDao;
|
||||
myIncrementVersionOnReindex = theIncrementVersionOnReindex;
|
||||
}
|
||||
|
||||
public void testReindex(int theNumResources){
|
||||
createPatients(theNumResources);
|
||||
|
||||
validatePersistedPatients(theNumResources, VERSION_1);
|
||||
|
||||
// Reindex 1
|
||||
JobInstanceStartRequest reindexRequest1 = createPatientReindexRequest(theNumResources);
|
||||
Batch2JobStartResponse reindexResponse1 = myJobCoordinator.startInstance(reindexRequest1);
|
||||
JobInstance instance1 = myBatch2JobHelper.awaitJobHasStatus(reindexResponse1.getJobId(), JOB_WAIT_TIME, StatusEnum.COMPLETED);
|
||||
|
||||
validateReindexJob(instance1, theNumResources);
|
||||
|
||||
int expectedVersion = myIncrementVersionOnReindex ? VERSION_2 : VERSION_1;
|
||||
validatePersistedPatients(theNumResources, expectedVersion);
|
||||
}
|
||||
|
||||
public void testSequentialReindexOperation(int theNumResources){
|
||||
createPatients(theNumResources);
|
||||
|
||||
validatePersistedPatients(theNumResources, VERSION_1);
|
||||
|
||||
// Reindex 1
|
||||
JobInstanceStartRequest reindexRequest1 = createPatientReindexRequest(theNumResources);
|
||||
Batch2JobStartResponse reindexResponse1 = myJobCoordinator.startInstance(reindexRequest1);
|
||||
JobInstance instance1 = myBatch2JobHelper.awaitJobHasStatus(reindexResponse1.getJobId(), JOB_WAIT_TIME, StatusEnum.COMPLETED);
|
||||
|
||||
validateReindexJob(instance1, theNumResources);
|
||||
int expectedVersion = myIncrementVersionOnReindex ? VERSION_2 : VERSION_1;
|
||||
validatePersistedPatients(theNumResources, expectedVersion);
|
||||
|
||||
// Reindex 2
|
||||
JobInstanceStartRequest reindexRequest2 = createPatientReindexRequest(theNumResources);
|
||||
Batch2JobStartResponse reindexResponse2 = myJobCoordinator.startInstance(reindexRequest2);
|
||||
JobInstance instance2 = myBatch2JobHelper.awaitJobHasStatus(reindexResponse2.getJobId(), JOB_WAIT_TIME, StatusEnum.COMPLETED);
|
||||
|
||||
validateReindexJob(instance2, theNumResources);
|
||||
expectedVersion = myIncrementVersionOnReindex ? VERSION_3 : VERSION_1;
|
||||
validatePersistedPatients(theNumResources, expectedVersion);
|
||||
}
|
||||
|
||||
public void testParallelReindexOperation(int theNumResources){
|
||||
createPatients(theNumResources);
|
||||
|
||||
validatePersistedPatients(theNumResources, VERSION_1);
|
||||
|
||||
// Reindex 1
|
||||
JobInstanceStartRequest reindexRequest1 = createPatientReindexRequest(theNumResources);
|
||||
Batch2JobStartResponse reindexResponse1 = myJobCoordinator.startInstance(reindexRequest1);
|
||||
|
||||
// Reindex 2
|
||||
JobInstanceStartRequest reindexRequest2 = createPatientReindexRequest(theNumResources);
|
||||
Batch2JobStartResponse reindexResponse2 = myJobCoordinator.startInstance(reindexRequest2);
|
||||
|
||||
// Wait for jobs to finish
|
||||
JobInstance instance1 = myBatch2JobHelper.awaitJobHasStatus(reindexResponse1.getJobId(), JOB_WAIT_TIME, StatusEnum.COMPLETED);
|
||||
JobInstance instance2 = myBatch2JobHelper.awaitJobHasStatus(reindexResponse2.getJobId(), JOB_WAIT_TIME, StatusEnum.COMPLETED);
|
||||
|
||||
validateReindexJob(instance1, theNumResources);
|
||||
|
||||
validateReindexJob(instance2, theNumResources);
|
||||
|
||||
int expectedVersion = myIncrementVersionOnReindex ? VERSION_3 : VERSION_1;
|
||||
validatePersistedPatients(theNumResources, expectedVersion);
|
||||
}
|
||||
|
||||
|
||||
private void createPatients(int theNumPatients) {
|
||||
RequestDetails requestDetails = new SystemRequestDetails();
|
||||
for(int i = 0; i < theNumPatients; i++){
|
||||
Patient patient = new Patient();
|
||||
patient.getNameFirstRep().setFamily("Family-"+i).addGiven("Given-"+i);
|
||||
patient.getIdentifierFirstRep().setValue("Id-"+i);
|
||||
myPatientDao.create(patient, requestDetails);
|
||||
}
|
||||
TestUtil.sleepOneClick();
|
||||
}
|
||||
|
||||
private void validatePersistedPatients(int theExpectedNumPatients, long theExpectedVersion) {
|
||||
RequestDetails requestDetails = new SystemRequestDetails();
|
||||
List<IBaseResource> resources = myPatientDao.search(SearchParameterMap.newSynchronous(), requestDetails).getAllResources();
|
||||
assertEquals(theExpectedNumPatients, resources.size());
|
||||
for(IBaseResource resource : resources){
|
||||
assertEquals(Patient.class, resource.getClass());
|
||||
Patient patient = (Patient) resource;
|
||||
Long actualVersion = patient.getIdElement().getVersionIdPartAsLong();
|
||||
if(theExpectedVersion != actualVersion){
|
||||
String failureMessage = String.format("Failure for Resource [%s] with index [%s]. Expected version: %s, Actual version: %s",
|
||||
patient.getId(), resources.indexOf(resource), theExpectedVersion, actualVersion);
|
||||
fail(failureMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JobInstanceStartRequest createPatientReindexRequest(int theBatchSize) {
|
||||
JobInstanceStartRequest startRequest = new JobInstanceStartRequest();
|
||||
startRequest.setJobDefinitionId(ReindexAppCtx.JOB_REINDEX);
|
||||
|
||||
ReindexJobParameters reindexJobParameters = new ReindexJobParameters();
|
||||
reindexJobParameters.setBatchSize(theBatchSize);
|
||||
reindexJobParameters.addUrl("Patient?");
|
||||
|
||||
startRequest.setParameters(reindexJobParameters);
|
||||
return startRequest;
|
||||
}
|
||||
|
||||
private void validateReindexJob(JobInstance theJobInstance, int theRecordsProcessed) {
|
||||
assertEquals(0, theJobInstance.getErrorCount());
|
||||
assertEquals(theRecordsProcessed, theJobInstance.getCombinedRecordsProcessed());
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -77,6 +77,8 @@ public abstract class RequestDetails {
|
||||
private String myTransactionGuid;
|
||||
private String myFixedConditionalUrl;
|
||||
private boolean myRewriteHistory;
|
||||
private int myMaxRetries;
|
||||
private boolean myRetry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -542,4 +544,21 @@ public abstract class RequestDetails {
|
||||
public void setRewriteHistory(boolean theRewriteHistory) {
|
||||
myRewriteHistory = theRewriteHistory;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxRetries() {
|
||||
return myMaxRetries;
|
||||
}
|
||||
|
||||
public void setMaxRetries(int theMaxRetries) {
|
||||
myMaxRetries = theMaxRetries;
|
||||
}
|
||||
|
||||
public boolean isRetry() {
|
||||
return myRetry;
|
||||
}
|
||||
|
||||
public void setRetry(boolean theRetry) {
|
||||
myRetry = theRetry;
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.trim;
|
||||
|
||||
public class ServletRequestDetails extends RequestDetails {
|
||||
|
||||
@ -186,9 +189,36 @@ public class ServletRequestDetails extends RequestDetails {
|
||||
if ("true".equals(myServletRequest.getHeader(Constants.HEADER_REWRITE_HISTORY))) {
|
||||
setRewriteHistory(true);
|
||||
}
|
||||
setRetryFields(myServletRequest);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setRetryFields(HttpServletRequest theRequest){
|
||||
if (theRequest == null){
|
||||
return;
|
||||
}
|
||||
Enumeration<String> headers = theRequest.getHeaders(Constants.HEADER_RETRY_ON_VERSION_CONFLICT);
|
||||
if (headers != null) {
|
||||
Iterator<String> headerIterator = headers.asIterator();
|
||||
while(headerIterator.hasNext()){
|
||||
String headerValue = headerIterator.next();
|
||||
if (isNotBlank(headerValue)) {
|
||||
StringTokenizer tok = new StringTokenizer(headerValue, ";");
|
||||
while (tok.hasMoreTokens()) {
|
||||
String next = trim(tok.nextToken());
|
||||
if (next.equals(Constants.HEADER_RETRY)) {
|
||||
setRetry(true);
|
||||
} else if (next.startsWith(Constants.HEADER_MAX_RETRIES + "=")) {
|
||||
String val = trim(next.substring((Constants.HEADER_MAX_RETRIES + "=").length()));
|
||||
int maxRetries = Integer.parseInt(val);
|
||||
setMaxRetries(maxRetries);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setServletResponse(HttpServletResponse myServletResponse) {
|
||||
this.myServletResponse = myServletResponse;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-spring-boot-sample-client-apache</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-spring-boot-sample-client-okhttp</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-spring-boot-sample-server-jersey</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-spring-boot</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -51,6 +51,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ReindexStep implements IJobStepWorker<ReindexJobParameters, ResourceIdListWorkChunkJson, VoidModel> {
|
||||
|
||||
public static final int REINDEX_MAX_RETRIES = 10;
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(ReindexStep.class);
|
||||
@Autowired
|
||||
private HapiTransactionService myHapiTransactionService;
|
||||
@ -73,6 +75,8 @@ public class ReindexStep implements IJobStepWorker<ReindexJobParameters, Resourc
|
||||
@Nonnull
|
||||
public RunOutcome doReindex(ResourceIdListWorkChunkJson data, IJobDataSink<VoidModel> theDataSink, String theInstanceId, String theChunkId) {
|
||||
RequestDetails requestDetails = new SystemRequestDetails();
|
||||
requestDetails.setRetry(true);
|
||||
requestDetails.setMaxRetries(REINDEX_MAX_RETRIES);
|
||||
TransactionDetails transactionDetails = new TransactionDetails();
|
||||
myHapiTransactionService.execute(requestDetails, transactionDetails, new ReindexJob(data, requestDetails, transactionDetails, theDataSink, theInstanceId, theChunkId));
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -100,12 +100,12 @@ public class ResourceIdListStep<PT extends PartitionedJobParameters, IT extends
|
||||
previousLastTime = nextChunk.getLastDate().getTime();
|
||||
nextStart = nextChunk.getLastDate();
|
||||
|
||||
while (idBuffer.size() >= MAX_BATCH_OF_IDS) {
|
||||
while (idBuffer.size() > MAX_BATCH_OF_IDS) {
|
||||
List<TypedPidJson> submissionIds = new ArrayList<>();
|
||||
for (Iterator<TypedPidJson> iter = idBuffer.iterator(); iter.hasNext(); ) {
|
||||
submissionIds.add(iter.next());
|
||||
iter.remove();
|
||||
if (submissionIds.size() >= MAX_BATCH_OF_IDS) {
|
||||
if (submissionIds.size() == MAX_BATCH_OF_IDS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import ca.uhn.fhir.batch2.jobs.chunk.PartitionedUrlChunkRangeJson;
|
||||
import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson;
|
||||
import ca.uhn.fhir.batch2.jobs.parameters.PartitionedUrlListJobParameters;
|
||||
import ca.uhn.fhir.batch2.model.JobInstance;
|
||||
import ca.uhn.fhir.jpa.api.pid.EmptyResourcePidList;
|
||||
import ca.uhn.fhir.jpa.api.pid.HomogeneousResourcePidList;
|
||||
import ca.uhn.fhir.jpa.api.pid.IResourcePidList;
|
||||
import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc;
|
||||
@ -74,7 +75,9 @@ public class LoadIdsStepTest {
|
||||
when(myBatch2DaoSvc.fetchResourceIdsPage(eq(DATE_2), eq(DATE_END), eq(DEFAULT_PAGE_SIZE), isNull(), isNull()))
|
||||
.thenReturn(createIdChunk(20000L, 40000L, DATE_3));
|
||||
when(myBatch2DaoSvc.fetchResourceIdsPage(eq(DATE_3), eq(DATE_END), eq(DEFAULT_PAGE_SIZE), isNull(), isNull()))
|
||||
.thenReturn(createIdChunk(40000L, 40040L, DATE_3));
|
||||
.thenReturn(createIdChunk(40000L, 40040L, DATE_4));
|
||||
when(myBatch2DaoSvc.fetchResourceIdsPage(eq(DATE_4), eq(DATE_END), eq(DEFAULT_PAGE_SIZE), isNull(), isNull()))
|
||||
.thenReturn(new EmptyResourcePidList());
|
||||
|
||||
mySvc.run(details, mySink);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -25,6 +25,7 @@ import ca.uhn.fhir.interceptor.api.Interceptor;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.jpa.api.model.ResourceVersionConflictResolutionStrategy;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@ -46,39 +47,26 @@ import static org.apache.commons.lang3.StringUtils.trim;
|
||||
@Interceptor
|
||||
public class UserRequestRetryVersionConflictsInterceptor {
|
||||
|
||||
/** Deprecated and moved to {@link ca.uhn.fhir.rest.api.Constants#HEADER_RETRY_ON_VERSION_CONFLICT} */
|
||||
@Deprecated
|
||||
public static final String HEADER_NAME = "X-Retry-On-Version-Conflict";
|
||||
|
||||
/** Deprecated and moved to {@link ca.uhn.fhir.rest.api.Constants#HEADER_MAX_RETRIES} */
|
||||
@Deprecated
|
||||
public static final String MAX_RETRIES = "max-retries";
|
||||
|
||||
/** Deprecated and moved to {@link ca.uhn.fhir.rest.api.Constants#HEADER_RETRY} */
|
||||
@Deprecated
|
||||
public static final String RETRY = "retry";
|
||||
|
||||
@Hook(value = Pointcut.STORAGE_VERSION_CONFLICT, order = 100)
|
||||
public ResourceVersionConflictResolutionStrategy check(RequestDetails theRequestDetails) {
|
||||
ResourceVersionConflictResolutionStrategy retVal = new ResourceVersionConflictResolutionStrategy();
|
||||
|
||||
if (theRequestDetails != null) {
|
||||
List<String> headers = theRequestDetails.getHeaders(HEADER_NAME);
|
||||
if (headers != null) {
|
||||
for (String headerValue : headers) {
|
||||
if (isNotBlank(headerValue)) {
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(headerValue, ";");
|
||||
while (tok.hasMoreTokens()) {
|
||||
String next = trim(tok.nextToken());
|
||||
if (next.equals(RETRY)) {
|
||||
retVal.setRetry(true);
|
||||
} else if (next.startsWith(MAX_RETRIES + "=")) {
|
||||
|
||||
String val = trim(next.substring((MAX_RETRIES + "=").length()));
|
||||
int maxRetries = Integer.parseInt(val);
|
||||
maxRetries = Math.min(100, maxRetries);
|
||||
retVal.setMaxRetries(maxRetries);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean shouldSetRetries = theRequestDetails != null && theRequestDetails.isRetry();
|
||||
if (shouldSetRetries) {
|
||||
retVal.setRetry(true);
|
||||
int maxRetries = Math.min(100, theRequestDetails.getMaxRetries());
|
||||
retVal.setMaxRetries(maxRetries);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
@ -90,7 +78,7 @@ public class UserRequestRetryVersionConflictsInterceptor {
|
||||
*/
|
||||
public static void addRetryHeader(SystemRequestDetails theRequestDetails, int theMaxRetries) {
|
||||
Validate.inclusiveBetween(1, Integer.MAX_VALUE, theMaxRetries, "Max retries must be > 0");
|
||||
String value = RETRY + "; " + MAX_RETRIES + "=" + theMaxRetries;
|
||||
theRequestDetails.addHeader(HEADER_NAME, value);
|
||||
theRequestDetails.setRetry(true);
|
||||
theRequestDetails.setMaxRetries(theMaxRetries);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -65,42 +65,42 @@
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r4b</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r5</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<name>HAPI-FHIR</name>
|
||||
<description>An open-source implementation of the FHIR specification in Java.</description>
|
||||
<url>https://hapifhir.io</url>
|
||||
@ -2005,7 +2005,7 @@
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-checkstyle</artifactId>
|
||||
<!-- Remember to bump this when you upgrade the version -->
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>6.2.0-PRE20-SNAPSHOT</version>
|
||||
<version>6.2.0-PRE21-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user