Home | Trees | Indices | Help |
|
---|
|
1 # ***** BEGIN LICENSE BLOCK ***** 2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 # 4 # The contents of this file are subject to the Mozilla Public License Version 5 # 1.1 (the "License"); you may not use this file except in compliance with 6 # the License. You may obtain a copy of the License at 7 # http://www.mozilla.org/MPL/ 8 # 9 # Software distributed under the License is distributed on an "AS IS" basis, 10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 # for the specific language governing rights and limitations under the 12 # License. 13 # 14 # The Original Code is Mozilla-specific Buildbot steps. 15 # 16 # The Initial Developer of the Original Code is 17 # Mozilla Foundation. 18 # Portions created by the Initial Developer are Copyright (C) 2009 19 # the Initial Developer. All Rights Reserved. 20 # 21 # Contributor(s): 22 # Brian Warner <warner@lothar.com> 23 # 24 # Alternatively, the contents of this file may be used under the terms of 25 # either the GNU General Public License Version 2 or later (the "GPL"), or 26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 # in which case the provisions of the GPL or the LGPL are applicable instead 28 # of those above. If you wish to allow use of your version of this file only 29 # under the terms of either the GPL or the LGPL, and not to allow others to 30 # use your version of this file under the terms of the MPL, indicate your 31 # decision by deleting the provisions above and replace them with the notice 32 # and other provisions required by the GPL or the LGPL. If you do not delete 33 # the provisions above, a recipient may use your version of this file under 34 # the terms of any one of the MPL, the GPL or the LGPL. 35 # 36 # ***** END LICENSE BLOCK ***** 37 38 from twisted.internet import defer 39 from twisted.python import log 40 from buildbot.util import loop 41 from buildbot.util import collections 42 from buildbot.util.eventual import eventually 4310246 loop.MultiServiceLoop.__init__(self) 47 self.master = master 48 self.db = db 49 self.change_svc = change_svc 50 self.upstream_subscribers = collections.defaultdict(list)5153 """Add and start any Scheduler that isn't already a child of ours. 54 Stop and remove any that are no longer in the list. Make sure each 55 one has a schedulerid in the database.""" 56 # TODO: this won't tolerate reentrance very well 57 new_names = set() 58 added = set() 59 removed = set() 60 for s in newschedulers: 61 new_names.add(s.name) 62 try: 63 old = self.getServiceNamed(s.name) 64 except KeyError: 65 old = None 66 if old: 67 if old.compareToOther(s): 68 removed.add(old) 69 added.add(s) 70 else: 71 pass # unchanged 72 else: 73 added.add(s) 74 for old in list(self): 75 if old.name not in new_names: 76 removed.add(old) 77 #if removed or added: 78 # # notify Downstream schedulers to potentially pick up 79 # # new schedulers now that we have removed and added some 80 # def updateDownstreams(res): 81 # log.msg("notifying downstream schedulers of changes") 82 # for s in newschedulers: 83 # if interfaces.IDownstreamScheduler.providedBy(s): 84 # s.checkUpstreamScheduler() 85 # d.addCallback(updateDownstreams) 86 log.msg("removing %d old schedulers, adding %d new ones" 87 % (len(removed), len(added))) 88 dl = [defer.maybeDeferred(s.disownServiceParent) for s in removed] 89 d = defer.gatherResults(dl) 90 d.addCallback(lambda ign: self.db.addSchedulers(added)) 91 def _attach(ign): 92 for s in added: 93 s.setServiceParent(self) 94 self.upstream_subscribers = collections.defaultdict(list) 95 for s in list(self): 96 if s.upstream_name: 97 self.upstream_subscribers[s.upstream_name].append(s) 98 eventually(self.trigger)99 d.addCallback(_attach) 100 d.addErrback(log.err) 101 return d104 if upstream_name in self.upstream_subscribers: 105 for s in self.upstream_subscribers[upstream_name]: 106 s.buildSetSubmitted(bsid, t)107109 self.trigger()111 # TODO: this could just run the schedulers that have subscribed to 112 # scheduler_upstream_buildsets, or even just the ones that subscribed 113 # to hear about the specific buildsetid 114 self.trigger()115
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue May 25 17:53:17 2010 | http://epydoc.sourceforge.net |