提交 1b852010 编写于 作者: O Oliver Gondža

[FIXED JENKINS-30705] Optimize TagCloud calculation

上级 699d2b22
......@@ -85,6 +85,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
protected transient final String name;
private transient volatile Set<Node> nodes;
private transient volatile Set<Cloud> clouds;
private transient volatile int tiedJobsCount;
@Exported
public transient final LoadStatistics loadStatistics;
......@@ -376,6 +377,8 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
* @return a count of projects that are tied on this node.
*/
public int getTiedJobCount() {
if (tiedJobsCount != -1) return tiedJobsCount;
// denormalize for performance
// we don't need to respect security as much when returning a simple count
SecurityContext context = ACL.impersonate(ACL.SYSTEM);
......@@ -412,7 +415,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
}
}
}
return result;
return tiedJobsCount = result;
} finally {
SecurityContextHolder.setContext(context);
}
......@@ -433,6 +436,7 @@ public abstract class Label extends Actionable implements Comparable<Label>, Mod
/*package*/ void reset() {
nodes = null;
clouds = null;
tiedJobsCount = -1;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册