监测某个interface中provider的权重的变化信息 :param event: :return:
(self, event)
| 190 | logger.debug('{} providers: {}'.format(interface, self.hosts[interface])) |
| 191 | |
| 192 | def _watch_configurators(self, event): |
| 193 | """ |
| 194 | 监测某个interface中provider的权重的变化信息 |
| 195 | :param event: |
| 196 | :return: |
| 197 | """ |
| 198 | path = event.path |
| 199 | logger.debug('zookeeper node changed: {}'.format(path)) |
| 200 | interface = path.split('/')[2] |
| 201 | |
| 202 | # 试图从配置中取出权重相关的信息 |
| 203 | configurators = self.zk.get_children(DUBBO_ZK_CONFIGURATORS.format(interface), |
| 204 | watch=self._watch_configurators) |
| 205 | if configurators: |
| 206 | configurators = map(parse_url, configurators) |
| 207 | conf = {} |
| 208 | for configurator in configurators: |
| 209 | conf[configurator['host']] = configurator['fields'].get('weight', 100) |
| 210 | logger.debug('{} configurators: {}'.format(interface, conf)) |
| 211 | self.weights[interface] = conf |
| 212 | else: |
| 213 | logger.debug('No configurator for interface {}') |
| 214 | self.weights[interface] = {} |
| 215 | |
| 216 | def _register_consumer(self, providers): |
| 217 | """ |