Skip to content
Permalink
Browse files
fix issue #2064: bug where RuntimeJobDag.generateJobList could loop u…
…ntil parallelism is reached when in JobQueue mode (#2065)
  • Loading branch information
richardstartin committed Apr 28, 2022
1 parent 41ddeaa commit 77389ac7705f280ae5a7a3c15fc4e6bea6e797c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
@@ -198,12 +198,14 @@ public void generateJobList() {
resetJobListAndDependencyMaps();
computeIndependentNodes();
_readyJobList.addAll(_independentNodes);
if (_isJobQueue && _readyJobList.size() > 0) {
if (_isJobQueue && !_readyJobList.isEmpty()) {
// For job queue, only get number of parallel jobs to run in the ready list.
for (int i = 1; i < _numParallelJobs; i++) {
if (_parentsToChildren.containsKey(_readyJobList.peekLast())) {
_readyJobList.offer(_parentsToChildren.get(_readyJobList.peekLast()).iterator().next());
Set<String> children = _parentsToChildren.get(_readyJobList.peekLast());
if (children == null) {
break;
}
_readyJobList.offer(children.iterator().next());
}
}
_hasDagChanged = false;
@@ -24,11 +24,25 @@
import java.util.List;
import java.util.Set;

import org.apache.helix.task.JobDag;
import org.apache.helix.task.RuntimeJobDag;
import org.testng.Assert;
import org.testng.annotations.Test;

public class TestRuntimeJobDag {

@Test
public void testBuildJobQueueWithParallelismExceedingJobCount() {
JobDag jobDag = new JobDag();
jobDag.addNode("parent");
jobDag.addParentToChild("parent", "child");
jobDag.addParentToChild("child", "grandchild");
RuntimeJobDag runtimeJobDag = new RuntimeJobDag(jobDag, true, Integer.MAX_VALUE, 1);
Assert.assertEquals(runtimeJobDag.getNextJob(), "parent");
Assert.assertEquals(runtimeJobDag.getNextJob(), "child");
Assert.assertEquals(runtimeJobDag.getNextJob(), "grandchild");
}

private Set<String> actualJobs;
private Set<String> expectedJobs;

0 comments on commit 77389ac

Please sign in to comment.