mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 14:02:22 +00:00
Proactive fix in case some plugins take too long to calculate their health report. Will now cache the health reports until the next build. Should speed display of main page.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4106 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
a8dc04a1f2
commit
fbb95cd54b
1 file changed
+20
-2
@@ -73,6 +73,13 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
|
||||
protected transient int nextBuildNumber = 1;
|
||||
|
||||
private LogRotator logRotator;
|
||||
|
||||
/**
|
||||
* Not all plugins are good at calculating their health report quickly.
|
||||
* These fields are used to cache the health reports to speed up rendering the main page.
|
||||
*/
|
||||
private transient Integer cachedBuildHealthReportsBuildNumber = null;
|
||||
private transient List<HealthReport> cachedBuildHealthReports = null;
|
||||
|
||||
private boolean keepDependencies;
|
||||
|
||||
@@ -546,7 +553,13 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
|
||||
lastBuild = lastBuild.getPreviousBuild();
|
||||
}
|
||||
|
||||
if (lastBuild != null) {
|
||||
// check the cache
|
||||
if (cachedBuildHealthReportsBuildNumber != null &&
|
||||
cachedBuildHealthReports != null &&
|
||||
lastBuild != null &&
|
||||
cachedBuildHealthReportsBuildNumber.intValue() == lastBuild.getNumber()) {
|
||||
reports.addAll(cachedBuildHealthReports);
|
||||
} else if (lastBuild != null) {
|
||||
for (HealthReportingAction healthReportingAction : lastBuild.getActions(HealthReportingAction.class)) {
|
||||
final HealthReport report = healthReportingAction.getBuildHealth();
|
||||
if (report != null) {
|
||||
@@ -565,9 +578,14 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
|
||||
reports.add(report);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(reports);
|
||||
|
||||
// store the cache
|
||||
cachedBuildHealthReportsBuildNumber = lastBuild.getNumber();
|
||||
cachedBuildHealthReports = new ArrayList<HealthReport>(reports);
|
||||
}
|
||||
|
||||
Collections.sort(reports);
|
||||
return reports;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user