Skip to content

Commit

Permalink
[JENKINS-13619] - Check configured options for multi-config throttling
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>

Conflicts:
	src/main/java/hudson/plugins/throttleconcurrents/ThrottleQueueTaskDispatcher.java
  • Loading branch information
oleg-nenashev committed May 17, 2014
1 parent bdad9a6 commit 739c4a7
Showing 1 changed file with 23 additions and 4 deletions.
Expand Up @@ -24,10 +24,11 @@ public class ThrottleQueueTaskDispatcher extends QueueTaskDispatcher {

@Override
public CauseOfBlockage canTake(Node node, Task task) {

ThrottleJobProperty tjp = getThrottleJobProperty(task);

if (task instanceof MatrixConfiguration && !tjp.getThrottleConfiguration()){

// Handle multi-configuration filters
if (!shouldBeThrottled(task, tjp)) {
return null;
}

Expand Down Expand Up @@ -93,9 +94,27 @@ public CauseOfBlockage canRun(Queue.Item item) {
}
return null;
}

private boolean shouldBeThrottled(Task task, ThrottleJobProperty tjp) {
if (tjp == null) return false;
if (!tjp.getThrottleEnabled()) return false;

// Handle matrix options
ThrottleMatrixProjectOptions matrixOptions = tjp.getMatrixOptions();
if (matrixOptions == null) matrixOptions = ThrottleMatrixProjectOptions.DEFAULT;
if (!matrixOptions.isThrottleMatrixConfigurations() && task instanceof MatrixConfiguration) {
return false;
}
if (!matrixOptions.isThrottleMatrixBuilds()&& task instanceof MatrixProject) {
return false;
}

// Allow throttling by default
return true;
}

public CauseOfBlockage canRun(Task task, ThrottleJobProperty tjp) {
if (task instanceof MatrixConfiguration && !tjp.getThrottleConfiguration()){
if (!shouldBeThrottled(task, tjp)) {
return null;
}
if (Hudson.getInstance().getQueue().isPending(task)) {
Expand Down

0 comments on commit 739c4a7

Please sign in to comment.