예제 #1
0
    def __init__(self, spec):
        # typical args = (dbmodule, dbname, username, password)
        self._query_times = collections.deque()
        self._spec = spec

        # this is for synchronous calls: runQueryNow, runInteractionNow
        self._dbapi = spec.get_dbapi()
        self._nonpool = None
        self._nonpool_lastused = None
        self._nonpool_max_idle = spec.get_maxidle()

        # pass queries in with "?" placeholders. If the backend uses a
        # different style, we'll replace them.
        self.paramstyle = self._dbapi.paramstyle

        self._pool = spec.get_async_connection_pool()
        self._pool.transactionFactory = MyTransaction
        # the pool must be started before it can be used. The real
        # buildmaster process will do this at reactor start. CLI tools (like
        # "buildbot upgrade-master") must do it manually. Unit tests are run
        # in an environment in which it is already started.

        self._change_cache = util.LRUCache()
        self._sourcestamp_cache = util.LRUCache()
        self._active_operations = set()  # protected by synchronized=
        self._pending_notifications = []
        self._subscribers = bbcollections.defaultdict(set)

        self._pending_operation_count = 0

        self._started = False
예제 #2
0
    def __init__(self, spec):
        # self._query_times = collections.deque()
        self._spec = spec

        # this is for synchronous calls: runQueryNow, runInteractionNow
        self._dbapi = spec.get_dbapi()
        self._nonpool = None
        self._nonpool_lastused = None
        self._nonpool_max_idle = spec.get_maxidle()

        self._change_cache = util.LRUCache()
        self._sourcestamp_cache = util.LRUCache()
        self._active_operations = set()  # protected by synchronized=
        self._pending_notifications = []
        self._subscribers = bbcollections.defaultdict(set)

        self._pending_operation_count = 0

        self._started = False
예제 #3
0
    def __init__(self, master, db_url, basedir):
        service.MultiService.__init__(self)
        self.master = master
        self.basedir = basedir
        "basedir for this master - used for upgrades"

        self._engine = enginestrategy.create_engine(db_url,
                                                    basedir=self.basedir)
        self.pool = pool.DBThreadPool(self._engine)
        "thread pool (L{buildbot.db.pool.DBThreadPool}) for this db"

        self._oldpool = TempAdbapiPool(self._engine)

        self._sourcestamp_cache = util.LRUCache()  # TODO: remove
        self._active_operations = set(
        )  # protected by synchronized= TODO: remove
        self._pending_notifications = []  # TODO: remove
        self._subscribers = bbcollections.defaultdict(set)

        self._started = False

        # set up components
        self.model = model.Model(self)
        "L{buildbot.db.model.Model} instance"

        self.changes = changes.ChangesConnectorComponent(self)
        "L{buildbot.db.changes.ChangesConnectorComponent} instance"

        self.schedulers = schedulers.SchedulersConnectorComponent(self)
        "L{buildbot.db.schedulers.ChangesConnectorComponent} instance"

        self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self)
        "L{buildbot.db.sourcestamps.SourceStampsConnectorComponent} instance"

        self.buildsets = buildsets.BuildsetsConnectorComponent(self)
        "L{buildbot.db.sourcestamps.BuildsetsConnectorComponent} instance"

        self.buildrequests = buildrequests.BuildRequestsConnectorComponent(
            self)
        "L{buildbot.db.sourcestamps.BuildRequestsConnectorComponent} instance"

        self.state = state.StateConnectorComponent(self)
        "L{buildbot.db.state.StateConnectorComponent} instance"

        self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD,
                                                   self.doCleanup)
        self.cleanup_timer.setServiceParent(self)

        self.changeHorizon = None  # default value; set by master
예제 #4
0
    def testDBGetChangeNumberedNow(self):
        db = self.db

        c = Change(who="catlee", files=["foo"], comments="", branch="b1")
        c.properties.setProperty("foo", "bar", "property_source")
        db.addChangeToDatabase(c)

        c1 = db.getChangeNumberedNow(c.number)
        self.assertEquals(c1.properties, c.properties)

        # Flush the cache
        db._change_cache = util.LRUCache()

        c1 = db.getChangeNumberedNow(c.number)
        self.assertEquals(c1.properties, c.properties)
예제 #5
0
 def setUp(self):
     self.lru = util.LRUCache(3)
     self.a = "AAA"
     self.b = "BBB"
     self.x = "XXX"
     self.y = "YYY"
예제 #6
0
 def __init__(self):
     service.MultiService.__init__(self)
     self._cache = util.LRUCache()
예제 #7
0
 def __init__(self):
     service.MultiService.__init__(self)
     self._cache = util.LRUCache()
     self.lastPruneChanges = 0
     self.changeHorizon = 0
예제 #8
0
 def flush(ign):
     # Flush the cache
     db._change_cache = util.LRUCache()
     return db.getChangeByNumber(c.number)
예제 #9
0
 def __init__(self):
     service.MultiService.__init__(self)
     self.master = None
     self._cache = util.LRUCache()
     self.lastPruneChanges = 0