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.api.VoidModel;
import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults; import ca.uhn.fhir.batch2.jobs.reindex.models.ReindexResults;
import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService; import ca.uhn.fhir.batch2.jobs.reindex.svcs.ReindexJobService;
import ca.uhn.fhir.i18n.Msg;
import jakarta.annotation.Nonnull; import jakarta.annotation.Nonnull;
public class CheckPendingReindexWorkStep implements IJobStepWorker<ReindexJobParameters, ReindexResults, VoidModel> { public class CheckPendingReindexWorkStep implements IJobStepWorker<ReindexJobParameters, ReindexResults, VoidModel> {
@ -30,12 +31,7 @@ public class CheckPendingReindexWorkStep implements IJobStepWorker<ReindexJobPar
if (!results.getResourceToHasWorkToComplete().isEmpty()) { if (!results.getResourceToHasWorkToComplete().isEmpty()) {
if (myReindexJobService.anyResourceHasPendingReindexWork(results.getResourceToHasWorkToComplete())) { if (myReindexJobService.anyResourceHasPendingReindexWork(results.getResourceToHasWorkToComplete())) {
/* CHECKSTYLE.OFF: HapiErrorCodeUniqueness throw new RetryChunkLaterException(Msg.code(2553), ReindexUtils.getRetryLaterDelay());
* 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 */
} }
} }

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

View File

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