def __init__(self, serverUrl, authkey, debug=None, maxMemoryItems=None, maxDiskItems=None, chunkSize=200, maxHttpRequestSize=2**20, **kwargs): """ @serverUrl: Base URL to be used to push events notifications. @maxMemoryItems: Maximum number of items to keep queued in memory. @maxDiskItems: Maximum number of items to buffer to disk, if 0, doesn't use disk at all. @debug: Save the json with nice formatting. @chunkSize: maximum number of items to send in each at each HTTP POST. @maxHttpRequestSize: limits the size of encoded data for AE, the default is 1MB. """ # Parameters. self.serverUrl = serverUrl self.authkey = authkey self.debug = debug self.chunkSize = chunkSize self.lastPushWasSuccessful = True self.maxHttpRequestSize = maxHttpRequestSize if maxDiskItems != 0: # The queue directory is determined by the server url. path = ('events_' + urlparse.urlparse(self.serverUrl)[1].split(':')[0]) queue = PersistentQueue( primaryQueue=MemoryQueue(maxItems=maxMemoryItems), secondaryQueue=DiskQueue(path, maxItems=maxDiskItems)) else: path = None queue = MemoryQueue(maxItems=maxMemoryItems) # Use the unbounded method. StatusPush.__init__(self, serverPushCb=CustomStatusPush.pushHttp, queue=queue, path=path, **kwargs)
def __init__(self, queuedir, ignoreBuilders=None, send_logs=False, heartbeat_time=900): self.queuedir = queuedir self.send_logs = send_logs self.ignoreBuilders = [] if ignoreBuilders: for i in ignoreBuilders: if isinstance(i, basestring): self.ignoreBuilders.append(re.compile(i)) else: assert hasattr(i, 'match') and callable(i.match) self.ignoreBuilders.append(i) self.watched = [] # Set up heartbeat self.heartbeat_time = heartbeat_time self._heartbeat_loop = LoopingCall(self.heartbeat) # Wait 10 seconds before sending our stuff self.push_delay = 10 self.delayed_push = None StatusPush.__init__(self, PulseStatus.pushEvents, filter=False)
def __init__(self, publisher, ignoreBuilders=None, send_logs=False, max_connect_time=600, max_idle_time=300, heartbeat_time=900): self.publisher = publisher self.send_logs = send_logs self.ignoreBuilders = [] if ignoreBuilders: for i in ignoreBuilders: if isinstance(i, basestring): self.ignoreBuilders.append(re.compile(i)) else: assert hasattr(i, 'match') and callable(i.match) self.ignoreBuilders.append(i) self.watched = [] self.max_connect_time = max_connect_time self.max_idle_time = max_idle_time self.heartbeat_time = heartbeat_time self._disconnect_timer = None self._idle_timer = None # Lock to make sure only one thread is active at a time self._thread_lock = DeferredLock() # Set up heartbeat self._heartbeat_loop = LoopingCall(self.heartbeat) StatusPush.__init__(self, PulseStatus.pushEvents, filter=False)
def setServiceParent(self, parent): StatusPush.setServiceParent(self, parent) # Start heartbeat # This should be done in startService, but our base class isn't # behaving # See http://trac.buildbot.net/ticket/1793 self._heartbeat_loop.start(self.heartbeat_time)
def stopService(self): log.msg("Pulse %s: shutting down" % (hexid(self),)) if self._heartbeat_loop.running: self._heartbeat_loop.stop() self.status.unsubscribe(self) for w in self.watched: w.unsubscribe(self) return StatusPush.stopService(self)
def __init__(self, debug=None, maxMemoryItems=None, maxDiskItems=None, chunkSize=200, maxPushSize=2**20, **kwargs): """ @serverUrl: The Nats server to be used to push events notifications to. @subject: The subject to use when publishing data @maxMemoryItems: Maximum number of items to keep queued in memory. @maxDiskItems: Maximum number of items to buffer to disk, if 0, doesn't use disk at all. @debug: Save the json with nice formatting. @chunkSize: maximum number of items to send in each at each PUSH. @maxPushSize: limits the size of encoded data for AE, the default is 1MB. """ # Parameters. self.debug = debug self.chunkSize = chunkSize self.lastPushWasSuccessful = True self.maxPushSize = maxPushSize if maxDiskItems != 0: # The queue directory is determined by the server url. path = 'queue_%s' % (self.eventName()) queue = PersistentQueue( primaryQueue=MemoryQueue(maxItems=maxMemoryItems), secondaryQueue=DiskQueue(path, maxItems=maxDiskItems)) else: path = None queue = MemoryQueue(maxItems=maxMemoryItems) # Use the unbounded method. StatusPush.__init__(self, serverPushCb=QueuedStatusPush._pushData, queue=queue, path=path, **kwargs)
def stopService(self): log.msg("Pulse %s: shutting down" % (hexid(self),)) if self._heartbeat_loop.running: self._heartbeat_loop.stop() self.status.unsubscribe(self) for w in self.watched: w.unsubscribe(self) # Write out any pending events if self.delayed_push: self.delayed_push.cancel() self.delayed_push = None while self.queue.nbItems() > 0: self._do_push() return StatusPush.stopService(self)
def stopService(self): log.msg("Pulse %s: shutting down" % (hexid(self), )) if self._heartbeat_loop.running: self._heartbeat_loop.stop() self.status.unsubscribe(self) for w in self.watched: w.unsubscribe(self) # Write out any pending events if self.delayed_push: self.delayed_push.cancel() self.delayed_push = None while self.queue.nbItems() > 0: self._do_push() return StatusPush.stopService(self)
def __init__(self, serverAddr=_SERVER_ADDRESS): self.currentBuilds = {} self.serverAddress = serverAddr StatusPush.__init__(self, GraphiteStatusPush.pushGraphite)