Attempt to prevent message retry loops.

This commit is contained in:
Greyson Parrelli
2024-02-23 15:36:05 -05:00
parent dc32e51ac2
commit c4842ae7c5
14 changed files with 280 additions and 73 deletions

View File

@@ -76,6 +76,15 @@ class JobController {
notifyAll();
}
@WorkerThread
void submitNewJobChains(@NonNull List<List<List<Job>>> chains) {
synchronized (this) {
for (List<List<Job>> chain : chains) {
submitNewJobChain(chain);
}
}
}
@WorkerThread
void submitNewJobChain(@NonNull List<List<Job>> chain) {
synchronized (this) {

View File

@@ -35,6 +35,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Allows the scheduling of durable jobs that will be run as early as possible.
@@ -208,6 +209,24 @@ public class JobManager implements ConstraintObserver.Notifier {
});
}
public void addAllChains(@NonNull List<JobManager.Chain> chains) {
if (chains.isEmpty()) {
return;
}
for (Chain chain : chains) {
for (List<Job> jobList : chain.getJobListChain()) {
for (Job job : jobList) {
jobTracker.onStateChange(job, JobTracker.JobState.PENDING);
}
}
}
runOnExecutor(() -> {
jobController.submitNewJobChains(chains.stream().map(Chain::getJobListChain).collect(Collectors.toList()));
});
}
/**
* Begins the creation of a job chain with a single job.
* @see Chain