Skip to content
Permalink
Browse files

[JENKINS-23557] Add matrix child jobs in the fron of the queue

MatrixConfiguration (children) will now inherit the place 
in the queue from the MatrixProject (parent)
  • Loading branch information...
emsa23 committed Apr 25, 2015
1 parent fc9df24 commit 78ce5bebeec9227a270b83942be7db24a18c8f8a
@@ -7,5 +7,7 @@
PriorityConfigurationCallback setPrioritySelection(int priority);

PriorityConfigurationCallback setPrioritySelection(int priority, int jobGroupId, PriorityStrategy reason);


PriorityConfigurationCallback setPrioritySelection(int priority, long sortAsInQueueSince, int jobGroupId, PriorityStrategy reason);

}
@@ -21,8 +21,7 @@ PriorityConfigurationCallback getPriority(MatrixConfiguration matrixConfiguratio
priorityCallback.addDecisionLog(0, "Job is MatrixConfiguration [" + matrixProject.getName() + "] ...");
ItemInfo itemInfo = QueueItemCache.get().getItem(matrixProject.getName());
// Can be null (for example) at startup when the MatrixBuild got
// lost (was running at
// restart)
// lost (was running at restart)
if (itemInfo != null) {
priorityCallback.addDecisionLog(0, "MatrixProject found in cache, using priority from queue-item ["
+ itemInfo.getItemId() + "]");
@@ -34,6 +34,11 @@ public PriorityConfigurationCallback setPrioritySelection(int priority) {
public PriorityConfigurationCallback addDecisionLog(int indent, String log) {
return this;
}

public PriorityConfigurationCallback setPrioritySelection(int priority, long sortAsInQueueSince,
int jobGroupId, PriorityStrategy reason) {
return this;
}
};

@Extension
@@ -95,6 +95,11 @@ public PriorityConfigurationCallback setPrioritySelection(int priority) {
public PriorityConfigurationCallback addDecisionLog(int indent, String log) {
return this;
}

public PriorityConfigurationCallback setPrioritySelection(int priority, long sortAsInQueueSince,
int jobGroupId, PriorityStrategy reason) {
return this;
}
};

@Override
@@ -45,6 +45,8 @@
private int itemId;

private long inQueueSince;

private Long sortAsInQueueSince = null;

private int jobGroupId;

@@ -74,6 +76,14 @@ public PriorityConfigurationCallback setPrioritySelection(int priority, int jobG
return this;
}

public PriorityConfigurationCallback setPrioritySelection(int priority, long sortAsInQueueSince, int jobGroupId, PriorityStrategy reason) {
this.priority = priority;
this.sortAsInQueueSince = sortAsInQueueSince;
this.jobGroupId = jobGroupId;
this.priorityStrategy = reason;
return this;
}

public PriorityConfigurationCallback addDecisionLog(int indent, String log) {
this.decisionLog.add(String.format("%"+ ((indent + 1) * 2) + "s%s", "", log));
return this;
@@ -107,6 +117,13 @@ public long getInQueueSince() {
return inQueueSince;
}

public long getSortableInQueueSince() {
if(sortAsInQueueSince != null) {
return sortAsInQueueSince;
}
return inQueueSince;
}

public int getJobGroupId() {
return jobGroupId;
}
@@ -133,7 +150,7 @@ public ItemStatus getItemStatus() {

public int compareTo(ItemInfo o) {
if(this.getWeight() == o.getWeight()) {
if(this.getInQueueSince() == o.getInQueueSince()) {
if(this.getSortableInQueueSince() == o.getSortableInQueueSince()) {
return Integer.compare(this.getItemId(), o.getItemId());
}
return Long.compare(this.getInQueueSince(), o.getInQueueSince());

0 comments on commit 78ce5be

Please sign in to comment.
You can’t perform that action at this time.