之前alarm evaluator service and alarm notifier services之间的通信采用RPC的方式,消耗较大,增加work queue的方式可以获得更好的性能,
+ if conf.ipc_protocol == ‘rpc‘: + self.ipc = ‘rpc‘ + self.rpc_server = messaging.get_rpc_server( + conf, transport, conf.notifier_rpc_topic, self) + else: + self.ipc = ‘queue‘ + target = oslo_messaging.Target(topic=conf.notifier_topic) + self.listener = messaging.get_notification_listener( + transport, [target], + [AlarmEndpoint(self.notifiers)])
所谓work queue的方式就是把evaluator 的结果作为消息的payload发送给alarm:
+ payload = {‘actions‘: actions, + ‘alarm_id‘: alarm.alarm_id, + ‘alarm_name‘: alarm.name, + ‘severity‘: alarm.severity, + ‘previous‘: previous, + ‘current‘: alarm.state, + ‘reason‘: six.text_type(reason), + ‘reason_data‘: reason_data} + self.notifier.sample(self.ctxt, ‘alarm.update‘, payload)
参考:https://review.openstack.org/#/c/247211/
时间: 2024-10-08 20:50:32