adding the code

This commit is contained in:
leif stawnyczy 2024-09-27 13:43:06 -04:00
parent f33999efef
commit 5e13c2e41e
3 changed files with 14 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import ca.uhn.fhir.batch2.api.StepExecutionDetails;
import ca.uhn.fhir.batch2.api.VoidModel;
import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults;
import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService;
import ca.uhn.fhir.i18n.Msg;
import jakarta.annotation.Nonnull;
public class CheckPendingReindexWorkStep implements IJobStepWorker<ReindexJobParameters, ReindexResults, VoidModel> {
@ -30,12 +31,7 @@ public class CheckPendingReindexWorkStep implements IJobStepWorker<ReindexJobPar
if (!results.getResourceToHasWorkToComplete().isEmpty()) {
if (myReindexJobService.anyResourceHasPendingReindexWork(results.getResourceToHasWorkToComplete())) {
/* CHECKSTYLE.OFF: HapiErrorCodeUniqueness
* This exception is never fed to users and is only part of our structure
* So there's no need to use an error code
*/
throw new RetryChunkLaterException(ReindexUtils.getRetryLaterDelay());
/* CHECKSTYLE.ON: HapiErrorCodeUniqueness */
throw new RetryChunkLaterException(Msg.code(2553), ReindexUtils.getRetryLaterDelay());
}
}

View File

@ -9,6 +9,7 @@ import ca.uhn.fhir.batch2.api.StepExecutionDetails;
import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson;
import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults;
import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
@ -53,12 +54,8 @@ public class ReindexStepV2 extends BaseReindexStep
resourceTypesToCheckFlag.put(id.getResourceType(), true);
});
if (myReindexJobService.anyResourceHasPendingReindexWork(resourceTypesToCheckFlag)) {
/* CHECKSTYLE.OFF: HapiErrorCodeUniqueness
* This exception is never fed to users and is only part of our structure
* So there's no need to use an error code
*/
throw new RetryChunkLaterException(ReindexUtils.getRetryLaterDelay());
/* CHECKSTYLE.ON: HapiErrorCodeUniqueness */
throw new RetryChunkLaterException(Msg.code(2552), ReindexUtils.getRetryLaterDelay());
}
ReindexResults results = doReindex(

View File

@ -38,11 +38,18 @@ public class RetryChunkLaterException extends RuntimeException {
private final Duration myNextPollDuration;
public RetryChunkLaterException() {
this(ONE_MINUTE);
this("", ONE_MINUTE);
}
/**
* For HAPI exceptions, use {@link RetryChunkLaterException#RetryChunkLaterException(String, Duration)}
*/
public RetryChunkLaterException(Duration theDuration) {
super();
this("", theDuration);
}
public RetryChunkLaterException(String theCode, Duration theDuration) {
super(theCode);
this.myNextPollDuration = theDuration;
}