Package buildbot :: Package changes :: Module manager
[frames] | no frames]

Source Code for Module buildbot.changes.manager

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  from zope.interface import implements 
17  from twisted.python import log 
18  from twisted.internet import defer 
19  from twisted.application import service 
20  from buildbot import interfaces, config, util 
21  from buildbot.process import metrics 
22 23 -class ChangeManager(config.ReconfigurableServiceMixin, service.MultiService):
24 """ 25 This is the master-side service which receives file change notifications 26 from version-control systems. 27 28 It is a Twisted service, which has instances of 29 L{buildbot.interfaces.IChangeSource} as child services. These are added by 30 the master with C{addSource}. 31 """ 32 33 implements(interfaces.IEventSource) 34 35 name = "changemanager" 36
37 - def __init__(self, master):
38 service.MultiService.__init__(self) 39 self.setName('change_manager') 40 self.master = master
41 42 @defer.deferredGenerator
43 - def reconfigService(self, new_config):
44 timer = metrics.Timer("ChangeManager.reconfigService") 45 timer.start() 46 47 removed, added = util.diffSets( 48 set(self), 49 new_config.change_sources) 50 51 if removed or added: 52 log.msg("adding %d new changesources, removing %d" % 53 (len(added), len(removed))) 54 55 for src in removed: 56 wfd = defer.waitForDeferred( 57 defer.maybeDeferred( 58 src.disownServiceParent)) 59 yield wfd 60 wfd.getResult() 61 src.master = None 62 63 for src in added: 64 src.master = self.master 65 src.setServiceParent(self) 66 67 num_sources = len(list(self)) 68 assert num_sources == len(new_config.change_sources) 69 metrics.MetricCountEvent.log("num_sources", num_sources, absolute=True) 70 71 # reconfig any newly-added change sources, as well as existing 72 wfd = defer.waitForDeferred( 73 config.ReconfigurableServiceMixin.reconfigService(self, 74 new_config)) 75 yield wfd 76 wfd.getResult() 77 78 timer.stop()
79