Adapt maxInstancesForQueue to only consider instances of the same job.

Currently the maxInstancesForQueue limit checks the count of all jobs in a
given queue. If there are already too many jobs, the new job is discarded.

However this is not the expected behavior for the two jobs where it's used:
GroupCallPeekWorkerJob and AutomaticSessionResetJob
For both the expected behavior is that there aren't too many jobs of them
started, but that there will be at least one instance of them started.
Both of them use the same queue as the PushProcessMessageJob and the MarkerJob.
Those two jobs are often in the queue at the same time, effectively preventing
the GroupCallPeekWorkerJob and AutomaticSessionResetJob from being enqueued.
This commit is contained in:
AsamK
2021-02-06 16:54:52 +01:00
committed by Cody Henthorne
parent 53dc5bab43
commit 8f51bdcb78
5 changed files with 11 additions and 9 deletions

View File

@@ -547,13 +547,14 @@ public class FastJobStorageTest {
}
@Test
public void getJobCountForQueue_general() {
public void getJobCountForFactoryAndQueue_general() {
FastJobStorage subject = new FastJobStorage(fixedDataDatabase(DataSet1.FULL_SPECS));
subject.init();
assertEquals(1, subject.getJobCountForQueue("q1"));
assertEquals(0, subject.getJobCountForQueue("does-not-exist"));
assertEquals(1, subject.getJobCountForFactoryAndQueue("f1", "q1"));
assertEquals(0, subject.getJobCountForFactoryAndQueue("f2", "q1"));
assertEquals(0, subject.getJobCountForFactoryAndQueue("f1", "does-not-exist"));
}
private JobDatabase noopDatabase() {