Package buildbot :: Package db :: Module connector
[frames] | no frames]

Source Code for Module buildbot.db.connector

 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 twisted.python import log 
17  from twisted.application import internet, service 
18  from buildbot.db import enginestrategy 
19   
20  from buildbot.db import pool, model, changes, schedulers, sourcestamps 
21  from buildbot.db import state, buildsets, buildrequests, builds 
22   
23 -class DBConnector(service.MultiService):
24 """ 25 The connection between Buildbot and its backend database. This is 26 generally accessible as master.db, but is also used during upgrades. 27 28 Most of the interesting operations available via the connector are 29 implemented in connector components, available as attributes of this 30 object, and listed below. 31 """ 32 33 # Period, in seconds, of the cleanup task. This master will perform 34 # periodic cleanup actions on this schedule. 35 CLEANUP_PERIOD = 3600 36
37 - def __init__(self, master, db_url, basedir):
38 service.MultiService.__init__(self) 39 self.master = master 40 self.basedir = basedir 41 42 self._engine = enginestrategy.create_engine(db_url, basedir=self.basedir) 43 self.pool = pool.DBThreadPool(self._engine) 44 45 # set up components 46 self.model = model.Model(self) 47 self.changes = changes.ChangesConnectorComponent(self) 48 self.schedulers = schedulers.SchedulersConnectorComponent(self) 49 self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) 50 self.buildsets = buildsets.BuildsetsConnectorComponent(self) 51 self.buildrequests = buildrequests.BuildRequestsConnectorComponent(self) 52 self.state = state.StateConnectorComponent(self) 53 self.builds = builds.BuildsConnectorComponent(self) 54 55 self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self.doCleanup) 56 self.cleanup_timer.setServiceParent(self) 57 58 self.changeHorizon = None # default value; set by master
59
60 - def doCleanup(self):
61 """ 62 Perform any periodic database cleanup tasks. 63 64 @returns: Deferred 65 """ 66 d = self.changes.pruneChanges(self.master.config.changeHorizon) 67 d.addErrback(log.err, 'while pruning changes') 68 return d
69