Add the build worker and job count information to the charts
This commit is contained in:
parent
63cd6ffcc3
commit
d359c849cd
9 changed files with 134 additions and 9 deletions
|
@ -8,3 +8,6 @@ class BaseComponent(ApplicationSession):
|
|||
self.parent_manager = None
|
||||
self.build_logs = None
|
||||
self.user_files = None
|
||||
|
||||
def kind(self):
|
||||
raise NotImplementedError
|
|
@ -49,6 +49,9 @@ class BuildComponent(BaseComponent):
|
|||
|
||||
BaseComponent.__init__(self, config, **kwargs)
|
||||
|
||||
def kind(self):
|
||||
return 'builder'
|
||||
|
||||
def onConnect(self):
|
||||
self.join(self.builder_realm)
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ logger = logging.getLogger(__name__)
|
|||
class DynamicRegistrationComponent(BaseComponent):
|
||||
""" Component session that handles dynamic registration of the builder components. """
|
||||
|
||||
def kind(self):
|
||||
return 'registration'
|
||||
|
||||
def onConnect(self):
|
||||
self.join(REGISTRATION_REALM)
|
||||
|
||||
|
@ -69,6 +72,7 @@ class EnterpriseManager(BaseManager):
|
|||
|
||||
def build_component_disposed(self, build_component, timed_out):
|
||||
self.build_components.remove(build_component)
|
||||
self.unregister_component(build_component)
|
||||
|
||||
def num_workers(self):
|
||||
return len(self.build_components)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import trollius
|
||||
import json
|
||||
|
||||
from autobahn.asyncio.wamp import RouterFactory, RouterSessionFactory
|
||||
from autobahn.asyncio.websocket import WampWebSocketServerFactory
|
||||
|
@ -63,7 +64,20 @@ class BuilderServer(object):
|
|||
|
||||
@controller_app.route('/status')
|
||||
def status():
|
||||
return server._current_status
|
||||
(running_count, available_count) = server._queue.get_metrics()
|
||||
|
||||
workers = [component for component in server._current_components
|
||||
if component.kind() == 'builder']
|
||||
|
||||
data = {
|
||||
'status': server._current_status,
|
||||
'running_local': server._job_count,
|
||||
'running_total': running_count,
|
||||
'workers': len(workers),
|
||||
'job_total': available_count
|
||||
}
|
||||
|
||||
return json.dumps(data)
|
||||
|
||||
self._controller_app = controller_app
|
||||
|
||||
|
|
Reference in a new issue