Skip to content

Commit

Permalink
Merge branch '9/asyncmultiservice' into nine
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Oct 18, 2013
2 parents d4c219a + 2d73fa5 commit 6d8183a
Show file tree
Hide file tree
Showing 40 changed files with 327 additions and 211 deletions.
13 changes: 6 additions & 7 deletions master/buildbot/buildslave/base.py
Expand Up @@ -20,21 +20,20 @@
from zope.interface import implements
from twisted.python import log
from twisted.internet import defer, reactor
from twisted.application import service
from twisted.python.reflect import namedModule

from buildbot.status.slave import SlaveStatus
from buildbot.status.mail import MailNotifier
from buildbot.process import metrics
from buildbot.interfaces import IBuildSlave, ILatentBuildSlave
from buildbot.process.properties import Properties
from buildbot.util import ascii2unicode
from buildbot.util import ascii2unicode, service
from buildbot.util.eventual import eventually
from buildbot import config


class AbstractBuildSlave(config.ReconfigurableServiceMixin,
service.MultiService):
service.AsyncMultiService):
"""This is the master-side representative for a remote buildbot slave.
There is exactly one for each slave described in the config file (the
c['slaves'] list). When buildbots connect in (.attach), they get a
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__(self, name, password, max_builds=None,
"""
name = ascii2unicode(name)

service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.slavename = name
self.password = password

Expand Down Expand Up @@ -189,7 +188,7 @@ def setServiceParent(self, parent):
# botmaster needs to set before setServiceParent which calls startService
self.botmaster = parent
self.master = parent.master
service.MultiService.setServiceParent(self, parent)
return service.AsyncMultiService.setServiceParent(self, parent)

@defer.inlineCallbacks
def startService(self):
Expand All @@ -200,7 +199,7 @@ def startService(self):
self.slavename)

yield self._getSlaveInfo()
yield service.MultiService.startService(self)
yield service.AsyncMultiService.startService(self)

@defer.inlineCallbacks
def reconfigService(self, new_config):
Expand Down Expand Up @@ -249,7 +248,7 @@ def stopService(self):
yield self.registration.unregister()
self.registration = None
self.stopMissingTimer()
yield service.MultiService.stopService(self)
yield service.AsyncMultiService.stopService(self)

def findNewSlaveInstance(self, new_config):
# TODO: called multiple times per reconfig; use 1-element cache?
Expand Down
7 changes: 3 additions & 4 deletions master/buildbot/buildslave/protocols/base.py
Expand Up @@ -13,14 +13,13 @@
#
# Copyright Buildbot Team Members

from twisted.application import service
from buildbot.util import subscription
from buildbot.util import subscription, service
from buildbot import config

class Listener(config.ReconfigurableServiceMixin, service.MultiService):
class Listener(config.ReconfigurableServiceMixin, service.AsyncMultiService):

def __init__(self, master):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.master = master


Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/changes/manager.py
Expand Up @@ -16,11 +16,11 @@
from zope.interface import implements
from twisted.python import log
from twisted.internet import defer
from twisted.application import service
from buildbot.util import service
from buildbot import interfaces, config, util
from buildbot.process import metrics

class ChangeManager(config.ReconfigurableServiceMixin, service.MultiService):
class ChangeManager(config.ReconfigurableServiceMixin, service.AsyncMultiService):
"""
This is the master-side service which receives file change notifications
from version-control systems.
Expand All @@ -35,7 +35,7 @@ class ChangeManager(config.ReconfigurableServiceMixin, service.MultiService):
name = "changemanager"

def __init__(self, master):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.setName('change_manager')
self.master = master

Expand All @@ -59,7 +59,7 @@ def reconfigService(self, new_config):

for src in added:
src.master = self.master
src.setServiceParent(self)
yield src.setServiceParent(self)

num_sources = len(list(self))
assert num_sources == len(new_config.change_sources)
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/data/connector.py
Expand Up @@ -16,8 +16,7 @@
import inspect
from twisted.python import reflect
from twisted.internet import defer
from twisted.application import service
from buildbot.util import pathmatch
from buildbot.util import pathmatch, service
from buildbot.data import exceptions, base, resultspec

class Updates(object):
Expand All @@ -30,7 +29,7 @@ class RTypes(object):
pass


class DataConnector(service.Service):
class DataConnector(service.AsyncService):

submodules = [
'buildbot.data.builders',
Expand Down
7 changes: 4 additions & 3 deletions master/buildbot/db/connector.py
Expand Up @@ -16,8 +16,9 @@
import textwrap
from twisted.internet import defer
from twisted.python import log
from twisted.application import internet, service
from twisted.application import internet
from buildbot import config
from buildbot.util import service
from buildbot.db import enginestrategy, exceptions
from buildbot.db import pool, model, changes, changesources, schedulers, sourcestamps
from buildbot.db import state, buildsets, buildrequests
Expand All @@ -34,7 +35,7 @@
want to make a backup of your buildmaster before doing so.
""").strip()

class DBConnector(config.ReconfigurableServiceMixin, service.MultiService):
class DBConnector(config.ReconfigurableServiceMixin, service.AsyncMultiService):
# The connection between Buildbot and its backend database. This is
# generally accessible as master.db, but is also used during upgrades.
#
Expand All @@ -47,7 +48,7 @@ class DBConnector(config.ReconfigurableServiceMixin, service.MultiService):
CLEANUP_PERIOD = 3600

def __init__(self, master, basedir):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.setName('db')
self.master = master
self.basedir = basedir
Expand Down
10 changes: 5 additions & 5 deletions master/buildbot/manhole.py
Expand Up @@ -21,7 +21,7 @@
import binascii
import base64
from twisted.python import log
from twisted.application import service, strports
from twisted.application import strports
from twisted.cred import checkers, portal
from twisted.conch import manhole, telnet
try:
Expand All @@ -35,7 +35,7 @@
from twisted.internet import protocol

from buildbot import config
from buildbot.util import ComparableMixin
from buildbot.util import ComparableMixin, service
from zope.interface import implements # requires Twisted-2.0 or later

# makeTelnetProtocol and _TelnetRealm are for the TelnetManhole
Expand Down Expand Up @@ -106,7 +106,7 @@ def checkKey(self, credentials):
return 0


class _BaseManhole(service.MultiService):
class _BaseManhole(service.AsyncMultiService):
"""This provides remote access to a python interpreter (a read/exec/print
loop) embedded in the buildmaster via an internal SSH server. This allows
detailed inspection of the buildmaster state. It is of most use to
Expand Down Expand Up @@ -142,7 +142,7 @@ def __init__(self, port, checker, using_ssh=True):
#c = conchc.SSHPublicKeyDatabase() # ~/.ssh/authorized_keys
# and I can't get UNIXPasswordDatabase to work

service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
if type(port) is int:
port = "tcp:%d" % port
self.port = port # for comparison later
Expand Down Expand Up @@ -178,12 +178,12 @@ def makeProtocol():


def startService(self):
service.MultiService.startService(self)
if self.using_ssh:
via = "via SSH"
else:
via = "via telnet"
log.msg("Manhole listening %s on port %s" % (via, self.port))
return service.AsyncMultiService.startService(self)


class TelnetManhole(_BaseManhole, ComparableMixin):
Expand Down
12 changes: 6 additions & 6 deletions master/buildbot/master.py
Expand Up @@ -22,7 +22,7 @@
from zope.interface import implements
from twisted.python import log, components, failure
from twisted.internet import defer, reactor, task
from twisted.application import service, internet
from twisted.application import internet

import buildbot
import buildbot.pbmanager
Expand All @@ -44,6 +44,7 @@
from buildbot.process import cache
from buildbot.process.users.manager import UserManagerManager
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE
from buildbot.util import service
from buildbot.util.eventual import eventually
from buildbot import monkeypatches
from buildbot import config
Expand All @@ -55,7 +56,7 @@ def __init__(self):
self.rotateLength = 1 * 1000 * 1000
self.maxRotatedFiles = 10

class BuildMaster(config.ReconfigurableServiceMixin, service.MultiService):
class BuildMaster(config.ReconfigurableServiceMixin, service.AsyncMultiService):

# frequency with which to reclaim running builds; this should be set to
# something fairly long, to avoid undue database load
Expand All @@ -66,7 +67,7 @@ class BuildMaster(config.ReconfigurableServiceMixin, service.MultiService):
UNCLAIMED_BUILD_FACTOR = 6

def __init__(self, basedir, configFileName="master.cfg", umask=None):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.setName("buildmaster")

self.umask = umask
Expand Down Expand Up @@ -235,8 +236,7 @@ def sigusr1(*args):
name=self.name)

# call the parent method
yield defer.maybeDeferred(lambda :
service.MultiService.startService(self))
yield service.AsyncMultiService.startService(self)

# give all services a chance to load the new configuration, rather
# than the base configuration
Expand All @@ -257,7 +257,7 @@ def sigusr1(*args):
@defer.inlineCallbacks
def stopService(self):
if self.running:
yield service.MultiService.stopService(self)
yield service.AsyncMultiService.stopService(self)
if self.masterid is not None:
yield self.data.updates.masterStopped(
name=self.name, masterid=self.masterid)
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/mq/base.py
Expand Up @@ -15,9 +15,9 @@

from twisted.python import log, failure
from twisted.internet import defer
from twisted.application import service
from buildbot.util import service

class MQBase(service.Service):
class MQBase(service.AsyncService):

def __init__(self, master):
self.setName('mq-implementation')
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/mq/connector.py
Expand Up @@ -14,10 +14,10 @@
# Copyright Buildbot Team Members

from buildbot import config
from twisted.application import service
from buildbot.util import service
from twisted.python.reflect import namedObject

class MQConnector(config.ReconfigurableServiceMixin, service.MultiService):
class MQConnector(config.ReconfigurableServiceMixin, service.AsyncMultiService):

classes = {
'simple' : {
Expand All @@ -27,7 +27,7 @@ class MQConnector(config.ReconfigurableServiceMixin, service.MultiService):
}

def __init__(self, master):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.setName('mq')
self.master = master
self.impl = None # set in setup
Expand Down
11 changes: 6 additions & 5 deletions master/buildbot/pbmanager.py
Expand Up @@ -18,19 +18,20 @@
from twisted.python import failure, log
from twisted.internet import defer
from twisted.cred import portal, checkers, credentials, error
from twisted.application import service, strports
from twisted.application import strports
from buildbot.util import service

debug = False

class PBManager(service.MultiService):
class PBManager(service.AsyncMultiService):
"""
A centralized manager for PB ports and authentication on them.
Allows various pieces of code to request a (port, username) combo, along
with a password and a perspective factory.
"""
def __init__(self):
service.MultiService.__init__(self)
service.AsyncMultiService.__init__(self)
self.setName('pbmanager')
self.dispatchers = {}

Expand Down Expand Up @@ -96,7 +97,7 @@ def getPort(self):
return disp.port.getHost().port


class Dispatcher(service.Service):
class Dispatcher(service.AsyncService):
implements(portal.IRealm, checkers.ICredentialsChecker)

credentialInterfaces = [ credentials.IUsernamePassword,
Expand All @@ -120,7 +121,7 @@ def __repr__(self):
def stopService(self):
# stop listening on the port when shut down
d = defer.maybeDeferred(self.port.stopListening)
d.addCallback(lambda _ : service.Service.stopService(self))
d.addCallback(lambda _ : service.AsyncService.stopService(self))
return d

def register(self, username, password, pfactory):
Expand Down

0 comments on commit 6d8183a

Please sign in to comment.