summaryrefslogtreecommitdiff
path: root/distbuild
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-05-01 15:58:07 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-05-12 07:33:04 +0000
commitf4360e39ecf9e53347c58d2480fde0cd8402579d (patch)
treed0a009260d5adc9cdb491f8b554b0d62f57121c2 /distbuild
parentcc79a6ba5bbc3a28b150b944ea57521fd3f27d03 (diff)
downloadmorph-f4360e39ecf9e53347c58d2480fde0cd8402579d.tar.gz
Add GraphProgress messages
Adds distinct message types to give us more flexibility over message handling now that we have multiple initiator types with different requirements. Change-Id: Ib2af8736b83d66ef20a8e37591ca68c9441b6497
Diffstat (limited to 'distbuild')
-rw-r--r--distbuild/__init__.py2
-rw-r--r--distbuild/build_controller.py35
-rw-r--r--distbuild/initiator.py17
-rw-r--r--distbuild/initiator_connection.py34
-rw-r--r--distbuild/protocol.py13
5 files changed, 91 insertions, 10 deletions
diff --git a/distbuild/__init__.py b/distbuild/__init__.py
index 62cf414c..bb9ddc6e 100644
--- a/distbuild/__init__.py
+++ b/distbuild/__init__.py
@@ -50,10 +50,12 @@ from worker_build_scheduler import (WorkerBuildQueuer,
WorkerBuildFinished,
WorkerBuildFailed,
WorkerBuildStepStarted)
+
from build_controller import (BuildController, BuildFailed, BuildProgress,
BuildStepStarted, BuildStepAlreadyStarted,
BuildOutput, BuildStepFinished, BuildStepFailed,
BuildFinished, BuildCancel, BuildStarted,
+ GraphingStarted, GraphingFinished, CacheState,
build_step_name, map_build_graph)
from initiator import (Initiator, InitiatorStart, InitiatorCancel,
InitiatorListJobs, InitiatorStatus)
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py
index 8acbcb43..5f281682 100644
--- a/distbuild/build_controller.py
+++ b/distbuild/build_controller.py
@@ -76,6 +76,26 @@ class BuildProgress(object):
self.message_text = message_text
+class GraphingStarted(object):
+
+ def __init__(self, id):
+ self.id = id
+
+
+class GraphingFinished(object):
+
+ def __init__(self, id):
+ self.id = id
+
+
+class CacheState(object):
+
+ def __init__(self, id, unbuilt, total):
+ self.id = id
+ self.unbuilt = unbuilt
+ self.total = total
+
+
class BuildStepStarted(object):
def __init__(self, request_id, step_name, worker_name):
@@ -327,8 +347,8 @@ class BuildController(distbuild.StateMachine):
self._helper_id = self._idgen.next()
self._request_command_execution(argv, self._helper_id)
- progress = BuildProgress(self._request['id'], 'Computing build graph')
- self.mainloop.queue_event(BuildController, progress)
+ self.mainloop.queue_event(BuildController,
+ GraphingStarted(self._request['id']))
def _maybe_collect_graph(self, event_source, event):
distbuild.crash_point()
@@ -343,9 +363,8 @@ class BuildController(distbuild.StateMachine):
def notify_success(artifact):
logging.debug('Graph is finished')
- progress = BuildProgress(
- self._request['id'], 'Finished computing build graph')
- self.mainloop.queue_event(BuildController, progress)
+ self.mainloop.queue_event(BuildController,
+ GraphingFinished(self._request['id']))
self.mainloop.queue_event(self, _GotGraph(artifact))
@@ -442,10 +461,8 @@ class BuildController(distbuild.StateMachine):
total.update([a for a in c.walk()])
total = len(total) or len([a for _ in self._artifact.walk()])
- progress = BuildProgress(
- self._request['id'],
- 'Need to build %d artifacts, of %d total' % (unbuilt, total))
- self.mainloop.queue_event(BuildController, progress)
+ cache_state_msg = CacheState(self._request['id'], unbuilt, total)
+ self.mainloop.queue_event(BuildController, cache_state_msg)
if total == 0:
logging.info('There seems to be nothing to build')
diff --git a/distbuild/initiator.py b/distbuild/initiator.py
index 3b85826c..5fc74086 100644
--- a/distbuild/initiator.py
+++ b/distbuild/initiator.py
@@ -136,6 +136,9 @@ class Initiator(distbuild.StateMachine):
'step-output': self._handle_step_output_message,
'step-finished': self._handle_step_finished_message,
'step-failed': self._handle_step_failed_message,
+ 'graphing-started': self._handle_graphing_started_message,
+ 'graphing-finished': self._handle_graphing_finished_message,
+ 'cache-state': self._handle_cache_state_message
}
handler = handlers[event.msg['type']]
@@ -154,6 +157,17 @@ class Initiator(distbuild.StateMachine):
def _handle_build_progress_message(self, msg):
self._app.status(msg='Progress: %(msgtext)s', msgtext=msg['message'])
+ def _handle_graphing_started_message(self, msg):
+ self._app.status(msg='Computing build graph')
+
+ def _handle_graphing_finished_message(self, msg):
+ self._app.status(msg='Finished computing build graph')
+
+ def _handle_cache_state_message(self, msg):
+ self._app.status(
+ msg='Need to build %(unbuilt)d/%(total)d artifacts',
+ unbuilt=msg['unbuilt'], total=msg['total'])
+
def _get_step_output_dir(self):
if self._step_output_dir is None:
configured_dir = self._app.settings['initiator-step-output-dir']
@@ -298,6 +312,9 @@ class InitiatorStart(Initiator):
'build-finished': self._handle_build_finished_message,
'build-failed': self._handle_build_failed_message,
'build-cancelled': self._handle_build_cancelled_message,
+ 'graphing-started': self._handle_graphing_started_message,
+ 'graphing-finished': self._handle_graphing_finished_message,
+ 'cache-state': self._handle_cache_state_message
}
msg_type = event.msg['type']
diff --git a/distbuild/initiator_connection.py b/distbuild/initiator_connection.py
index f0586d9d..72b3abfd 100644
--- a/distbuild/initiator_connection.py
+++ b/distbuild/initiator_connection.py
@@ -82,6 +82,12 @@ class InitiatorConnection(distbuild.StateMachine):
'idle', self._send_build_failed_message),
('idle', distbuild.BuildController, distbuild.BuildProgress,
'idle', self._send_build_progress_message),
+ ('idle', distbuild.BuildController, distbuild.GraphingStarted,
+ 'idle', self._send_graphing_started_message),
+ ('idle', distbuild.BuildController, distbuild.GraphingFinished,
+ 'idle', self._send_graphing_finished_message),
+ ('idle', distbuild.BuildController, distbuild.CacheState,
+ 'idle', self._send_cache_state_message),
('idle', distbuild.BuildController, distbuild.BuildCancel,
'idle', self._send_build_cancelled_message),
('idle', distbuild.BuildController, distbuild.BuildStepStarted,
@@ -286,6 +292,34 @@ class InitiatorConnection(distbuild.StateMachine):
self.jm.send(msg)
self._log_send(msg)
+ def _send_graphing_started_message(self, event_source, event):
+ logging.debug('InitiatorConnection: graphing_started: id=%s', event.id)
+
+ if event.id in self.our_ids:
+ msg = distbuild.message('graphing-started', id=event.id)
+ self.jm.send(msg)
+ self._log_send(msg)
+
+ def _send_graphing_finished_message(self, event_source, event):
+ logging.debug('InitiatorConnection: graphing_finished: id=%s',
+ event.id)
+
+ if event.id in self.our_ids:
+ msg = distbuild.message('graphing-finished', id=event.id)
+ self.jm.send(msg)
+ self._log_send(msg)
+
+ def _send_cache_state_message(self, event_source, event):
+ logging.debug('InitiatorConnection: cache_state: id=%s', event.id)
+
+ if event.id in self.our_ids:
+ msg = distbuild.message('cache-state',
+ id=event.id,
+ unbuilt=event.unbuilt,
+ total=event.total)
+ self.jm.send(msg)
+ self._log_send(msg)
+
def _send_build_step_started_message(self, event_source, event):
logging.debug('InitiatorConnection: build_step_started: '
'id=%s step_name=%s worker_name=%s' %
diff --git a/distbuild/protocol.py b/distbuild/protocol.py
index 8de60ba4..9aab6a6d 100644
--- a/distbuild/protocol.py
+++ b/distbuild/protocol.py
@@ -22,7 +22,7 @@
# time a change is introduced that would break server/initiator compatibility
-VERSION = 3
+VERSION = 4
_required_fields = {
@@ -107,6 +107,17 @@ _required_fields = {
'id',
'protocol_version',
],
+ 'graphing-started': [
+ 'id',
+ ],
+ 'graphing-finished': [
+ 'id'
+ ],
+ 'cache-state': [
+ 'id',
+ 'unbuilt',
+ 'total'
+ ]
}