Some final cleanup minor updates.

This commit is contained in:
ianmarshall 2020-05-22 13:36:08 -04:00
parent a60e5809b2
commit b501a601b7
3 changed files with 13 additions and 26 deletions

View File

@ -84,8 +84,6 @@ public class DaoConfig {
private static final int DEFAULT_EXPUNGE_BATCH_SIZE = 800;
private IndexEnabledEnum myIndexMissingFieldsEnabled = IndexEnabledEnum.DISABLED;
private static final int DEFAULT_MAXIMUM_DELETE_CONFLICT_COUNT = 60;
private static final int DEFAULT_MAXIMUM_DELETE_CONFLICT_RETRY_ATTEMPTS = 10;
/**
* Child Configurations

View File

@ -45,7 +45,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
@Service
@ -87,7 +86,7 @@ public class DeleteConflictService {
++retryCount;
}
theDeleteConflicts.addAll(newConflicts);
if(retryCount >= MAX_RETRY_ATTEMPTS && !newConflicts.isEmpty()) {
if(retryCount >= MAX_RETRY_ATTEMPTS && !theDeleteConflicts.isEmpty()) {
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(myFhirContext);
OperationOutcomeUtil.addIssue(myFhirContext, oo, BaseHapiFhirDao.OO_SEVERITY_ERROR, MAX_RETRY_ATTEMPTS_EXCEEDED_MSG,null, "processing");
throw new ResourceVersionConflictException(MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, oo);
@ -149,17 +148,13 @@ public class DeleteConflictService {
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(theFhirContext);
String firstMsg = null;
Iterator<DeleteConflict> iterator = theDeleteConflicts.iterator();
while (iterator.hasNext()) {
DeleteConflict next = iterator.next();
StringBuilder b = new StringBuilder();
b.append("Unable to delete ");
b.append(next.getTargetId().toUnqualifiedVersionless().getValue());
b.append(" because at least one resource has a reference to this resource. First reference found was resource ");
b.append(next.getSourceId().toUnqualifiedVersionless().getValue());
b.append(" in path ");
b.append(next.getSourcePath());
String msg = b.toString();
for (DeleteConflict next : theDeleteConflicts) {
String msg = "Unable to delete " +
next.getTargetId().toUnqualifiedVersionless().getValue() +
" because at least one resource has a reference to this resource. First reference found was resource " +
next.getSourceId().toUnqualifiedVersionless().getValue() +
" in path " +
next.getSourcePath();
if (firstMsg == null) {
firstMsg = msg;
}

View File

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
@ -33,7 +32,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
@Autowired
DaoConfig myDaoConfig;
private DeleteConflictInterceptor myDeleteInterceptor = new DeleteConflictInterceptor();
private final DeleteConflictInterceptor myDeleteInterceptor = new DeleteConflictInterceptor();
private int myInterceptorDeleteCount;
@Before
@ -157,7 +156,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
myDeleteInterceptor.deleteConflictFunction = this::deleteConflictsFixedRetryCount;
try {
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();
} catch (ResourceVersionConflictException e) {
assertEquals(DeleteConflictService.MAX_RETRY_ATTEMPTS_EXCEEDED_MSG, e.getMessage());
@ -188,7 +187,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
Patient patient = new Patient();
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
myDeleteInterceptor.deleteConflictFunction = t -> new DeleteConflictOutcome().setShouldRetryCount(Integer.MAX_VALUE);
@ -232,9 +231,7 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
}
private DeleteConflictOutcome deleteConflicts(DeleteConflictList theList) {
Iterator<DeleteConflict> iterator = theList.iterator();
while (iterator.hasNext()) {
DeleteConflict next = iterator.next();
for (DeleteConflict next : theList) {
IdDt source = next.getSourceId();
if ("Patient".equals(source.getResourceType())) {
ourLog.info("Deleting {}", source);
@ -246,14 +243,11 @@ public class DeleteConflictServiceR4Test extends BaseJpaR4Test {
}
private DeleteConflictOutcome deleteConflictsFixedRetryCount(DeleteConflictList theList) {
Iterator<DeleteConflict> iterator = theList.iterator();
while (iterator.hasNext()) {
DeleteConflict next = iterator.next();
for (DeleteConflict next : theList) {
IdDt source = next.getSourceId();
if ("Patient".equals(source.getResourceType())) {
ourLog.info("Deleting {}", source);
myPatientDao.delete(source, theList, null, null);
// myPatientDao.delete(source);
++myInterceptorDeleteCount;
}
}