Some final cleanup minor updates.
This commit is contained in:
parent
a60e5809b2
commit
b501a601b7
|
@ -84,8 +84,6 @@ public class DaoConfig {
|
||||||
private static final int DEFAULT_EXPUNGE_BATCH_SIZE = 800;
|
private static final int DEFAULT_EXPUNGE_BATCH_SIZE = 800;
|
||||||
private IndexEnabledEnum myIndexMissingFieldsEnabled = IndexEnabledEnum.DISABLED;
|
private IndexEnabledEnum myIndexMissingFieldsEnabled = IndexEnabledEnum.DISABLED;
|
||||||
private static final int DEFAULT_MAXIMUM_DELETE_CONFLICT_COUNT = 60;
|
private static final int DEFAULT_MAXIMUM_DELETE_CONFLICT_COUNT = 60;
|
||||||
private static final int DEFAULT_MAXIMUM_DELETE_CONFLICT_RETRY_ATTEMPTS = 10;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child Configurations
|
* Child Configurations
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -87,7 +86,7 @@ public class DeleteConflictService {
|
||||||
++retryCount;
|
++retryCount;
|
||||||
}
|
}
|
||||||
theDeleteConflicts.addAll(newConflicts);
|
theDeleteConflicts.addAll(newConflicts);
|
||||||
if(retryCount >= MAX_RETRY_ATTEMPTS && !newConflicts.isEmpty()) {
|
if(retryCount >= MAX_RETRY_ATTEMPTS && !theDeleteConflicts.isEmpty()) {
|
||||||
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(myFhirContext);
|
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(myFhirContext);
|
||||||
OperationOutcomeUtil.addIssue(myFhirContext, oo, BaseHapiFhirDao.OO_SEVERITY_ERROR, MAX_RETRY_ATTEMPTS_EXCEEDED_MSG,null, "processing");
|
OperationOutcomeUtil.addIssue(myFhirContext, oo, BaseHapiFhirDao.OO_SEVERITY_ERROR, MAX_RETRY_ATTEMPTS_EXCEEDED_MSG,null, "processing");
|
||||||
throw new ResourceVersionConflictException(MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, oo);
|
throw new ResourceVersionConflictException(MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, oo);
|
||||||
|
@ -149,17 +148,13 @@ public class DeleteConflictService {
|
||||||
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(theFhirContext);
|
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(theFhirContext);
|
||||||
String firstMsg = null;
|
String firstMsg = null;
|
||||||
|
|
||||||
Iterator<DeleteConflict> iterator = theDeleteConflicts.iterator();
|
for (DeleteConflict next : theDeleteConflicts) {
|
||||||
while (iterator.hasNext()) {
|
String msg = "Unable to delete " +
|
||||||
DeleteConflict next = iterator.next();
|
next.getTargetId().toUnqualifiedVersionless().getValue() +
|
||||||
StringBuilder b = new StringBuilder();
|
" because at least one resource has a reference to this resource. First reference found was resource " +
|
||||||
b.append("Unable to delete ");
|
next.getSourceId().toUnqualifiedVersionless().getValue() +
|
||||||
b.append(next.getTargetId().toUnqualifiedVersionless().getValue());
|
" in path " +
|
||||||
b.append(" because at least one resource has a reference to this resource. First reference found was resource ");
|
next.getSourcePath();
|
||||||
b.append(next.getSourceId().toUnqualifiedVersionless().getValue());
|
|
||||||
b.append(" in path ");
|
|
||||||
b.append(next.getSourcePath());
|
|
||||||
String msg = b.toString();
|
|
||||||
if (firstMsg == null) {
|
if (firstMsg == null) {
|
||||||
firstMsg = msg;
|
firstMsg = msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
|
||||||
@Autowired
|
@Autowired
|
||||||
DaoConfig myDaoConfig;
|
DaoConfig myDaoConfig;
|
||||||
|
|
||||||
private DeleteConflictInterceptor myDeleteInterceptor = new DeleteConflictInterceptor();
|
private final DeleteConflictInterceptor myDeleteInterceptor = new DeleteConflictInterceptor();
|
||||||
private int myInterceptorDeleteCount;
|
private int myInterceptorDeleteCount;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -157,7 +156,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
|
||||||
myDeleteInterceptor.deleteConflictFunction = this::deleteConflictsFixedRetryCount;
|
myDeleteInterceptor.deleteConflictFunction = this::deleteConflictsFixedRetryCount;
|
||||||
try {
|
try {
|
||||||
myOrganizationDao.delete(organizationId);
|
myOrganizationDao.delete(organizationId);
|
||||||
// Needs a fourth pass to ensure that all conflicts are now gone.
|
// Needs a fourth and final pass to ensure that all conflicts are now gone.
|
||||||
fail();
|
fail();
|
||||||
} catch (ResourceVersionConflictException e) {
|
} catch (ResourceVersionConflictException e) {
|
||||||
assertEquals(DeleteConflictService.MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, e.getMessage());
|
assertEquals(DeleteConflictService.MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, e.getMessage());
|
||||||
|
@ -188,7 +187,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
|
||||||
|
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
patient.setManagingOrganization(new Reference(organizationId));
|
patient.setManagingOrganization(new Reference(organizationId));
|
||||||
IIdType patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
|
myPatientDao.create(patient).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
// Always returning true is bad behaviour. Our infinite loop checker should halt it
|
// Always returning true is bad behaviour. Our infinite loop checker should halt it
|
||||||
myDeleteInterceptor.deleteConflictFunction = t -> new DeleteConflictOutcome().setShouldRetryCount(Integer.MAX_VALUE);
|
myDeleteInterceptor.deleteConflictFunction = t -> new DeleteConflictOutcome().setShouldRetryCount(Integer.MAX_VALUE);
|
||||||
|
@ -232,9 +231,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeleteConflictOutcome deleteConflicts(DeleteConflictList theList) {
|
private DeleteConflictOutcome deleteConflicts(DeleteConflictList theList) {
|
||||||
Iterator<DeleteConflict> iterator = theList.iterator();
|
for (DeleteConflict next : theList) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
DeleteConflict next = iterator.next();
|
|
||||||
IdDt source = next.getSourceId();
|
IdDt source = next.getSourceId();
|
||||||
if ("Patient".equals(source.getResourceType())) {
|
if ("Patient".equals(source.getResourceType())) {
|
||||||
ourLog.info("Deleting {}", source);
|
ourLog.info("Deleting {}", source);
|
||||||
|
@ -246,14 +243,11 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeleteConflictOutcome deleteConflictsFixedRetryCount(DeleteConflictList theList) {
|
private DeleteConflictOutcome deleteConflictsFixedRetryCount(DeleteConflictList theList) {
|
||||||
Iterator<DeleteConflict> iterator = theList.iterator();
|
for (DeleteConflict next : theList) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
DeleteConflict next = iterator.next();
|
|
||||||
IdDt source = next.getSourceId();
|
IdDt source = next.getSourceId();
|
||||||
if ("Patient".equals(source.getResourceType())) {
|
if ("Patient".equals(source.getResourceType())) {
|
||||||
ourLog.info("Deleting {}", source);
|
ourLog.info("Deleting {}", source);
|
||||||
myPatientDao.delete(source, theList, null, null);
|
myPatientDao.delete(source, theList, null, null);
|
||||||
// myPatientDao.delete(source);
|
|
||||||
++myInterceptorDeleteCount;
|
++myInterceptorDeleteCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue