OLD | NEW |
1 URL: http://buildbot.net/trac | 1 URL: http://buildbot.net/trac |
2 Version: 0.8.4p1 | 2 Version: 0.8.4p1 |
3 License: GNU General Public License (GPL) Version 2 | 3 License: GNU General Public License (GPL) Version 2 |
4 | 4 |
5 This is a forked copy of buildbot v0.8.4p1. | 5 This is a forked copy of buildbot v0.8.4p1. |
6 | 6 |
7 Make hidden steps stay hidden even if not finished, add brDoStepIf | 7 Make hidden steps stay hidden even if not finished, add brDoStepIf |
8 to support buildrunner. | 8 to support buildrunner. |
9 | 9 |
10 | 10 |
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 - if build_status.getSlavename() == self.name: | 3006 - if build_status.getSlavename() == self.name: |
3007 - builds.append(build_status.getNumber()) | 3007 - builds.append(build_status.getNumber()) |
3008 - results['builders'][builderName] = builds | 3008 - results['builders'][builderName] = builds |
3009 + # Enhance it by adding more information. | 3009 + # Enhance it by adding more information. |
3010 + results['builders'] = self.getSlaveBuildMap( | 3010 + results['builders'] = self.getSlaveBuildMap( |
3011 + request.custom_data['buildcache'], | 3011 + request.custom_data['buildcache'], |
3012 + request.custom_data['buildercache']) | 3012 + request.custom_data['buildercache']) |
3013 return results | 3013 return results |
3014 | 3014 |
3015 | 3015 |
| 3016 |
| 3017 diff --git a/third_party/buildbot_8_4p1/buildbot/status/builder.py b/third_party
/buildbot_8_4p1/buildbot/status/builder.py |
| 3018 index 3f42eb6..c5bd1ec 100644 |
| 3019 --- a/third_party/buildbot_8_4p1/buildbot/status/builder.py |
| 3020 +++ b/third_party/buildbot_8_4p1/buildbot/status/builder.py |
| 3021 @@ -17,6 +17,7 @@ |
| 3022 import weakref |
| 3023 import gc |
| 3024 import os, re, itertools |
| 3025 +import random |
| 3026 from cPickle import load, dump |
| 3027 |
| 3028 from zope.interface import implements |
| 3029 @@ -323,17 +324,58 @@ class BuilderStatus(styles.Versioned): |
| 3030 def getCategory(self): |
| 3031 return self.category |
| 3032 |
| 3033 - def getBuild(self, number): |
| 3034 + def _resolveBuildNumber(self, number): |
| 3035 if number < 0: |
| 3036 number = self.nextBuildNumber + number |
| 3037 if number < 0 or number >= self.nextBuildNumber: |
| 3038 return None |
| 3039 + return number |
| 3040 |
| 3041 + def _safeGetBuild(self, build_number): |
| 3042 try: |
| 3043 - return self.getBuildByNumber(number) |
| 3044 + return self.getBuildByNumber(build_number) |
| 3045 except IndexError: |
| 3046 return None |
| 3047 |
| 3048 + def getBuild(self, number): |
| 3049 + number = self._resolveBuildNumber(number) |
| 3050 + |
| 3051 + if number is None: |
| 3052 + return None |
| 3053 + |
| 3054 + return self._safeGetBuild(number) |
| 3055 + |
| 3056 + def getBuilds(self, numbers): |
| 3057 + """Cache-aware method to get multiple builds. |
| 3058 + |
| 3059 + Prevents cascading evict/load when multiple builds are requested in |
| 3060 + succession: requesting build 1 evicts build 2, requesting build 2 evict
s |
| 3061 + build 3, etc. |
| 3062 + |
| 3063 + We query the buildCache and load hits first, then misses. When loading
, |
| 3064 + we randomize the load order to alleviate the problem when external web |
| 3065 + requests load builds sequentially (they don't have access to this |
| 3066 + function). |
| 3067 + """ |
| 3068 + |
| 3069 + numbers = list(enumerate(self._resolveBuildNumber(x) for x in numbers)) |
| 3070 + random.shuffle(numbers) |
| 3071 + |
| 3072 + builds = [None] * len(numbers) |
| 3073 + misses = [] |
| 3074 + for idx, build_number in numbers: |
| 3075 + if build_number is None: |
| 3076 + continue |
| 3077 + if build_number in self.buildCache.cache: |
| 3078 + builds[idx] = self._safeGetBuild(build_number) |
| 3079 + else: |
| 3080 + misses.append((idx, build_number)) |
| 3081 + |
| 3082 + for idx, build_number in misses: |
| 3083 + builds[idx] = self._safeGetBuild(build_number) |
| 3084 + |
| 3085 + return builds |
| 3086 + |
| 3087 def getEvent(self, number): |
| 3088 try: |
| 3089 return self.events[number] |
| 3090 @@ -616,6 +658,11 @@ class BuilderStatus(styles.Versioned): |
| 3091 # Collect build numbers. |
| 3092 # Important: Only grab the *cached* builds numbers to reduce I/O. |
| 3093 current_builds = [b.getNumber() for b in self.currentBuilds] |
| 3094 + |
| 3095 + # Populates buildCache with last N builds. |
| 3096 + buildnums = range(-1, -(self.buildCacheSize - 1), -1) |
| 3097 + self.getBuilds(buildnums) |
| 3098 + |
| 3099 cached_builds = list(set(self.buildCache.cache.keys() + current_builds)
) |
| 3100 cached_builds.sort() |
| 3101 result['cachedBuilds'] = cached_builds |
| 3102 diff --git a/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py b/thi
rd_party/buildbot_8_4p1/buildbot/status/web/status_json.py |
| 3103 index c357939..e7cd932 100644 |
| 3104 --- a/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py |
| 3105 +++ b/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py |
| 3106 @@ -641,8 +641,11 @@ class SlaveJsonResource(JsonResource): |
| 3107 if builderName not in buildercache: |
| 3108 buildercache.add(builderName) |
| 3109 builder_status = self.status.getBuilder(builderName) |
| 3110 - for i in range(1, builder_status.buildCacheSize - 1): |
| 3111 - build_status = builder_status.getBuild(-i) |
| 3112 + |
| 3113 + buildnums = range(-1, -(builder_status.buildCacheSize - 1), -1) |
| 3114 + builds = builder_status.getBuilds(buildnums) |
| 3115 + |
| 3116 + for build_status in builds: |
| 3117 if not build_status or not build_status.isFinished(): |
| 3118 # If not finished, it will appear in runningBuilds. |
| 3119 break |
OLD | NEW |