#当zookeeper的/dubbo/cn.javacoder.test.dubbo.IHelloWorldService(服务名)路径下的子路径(configurators, routers, providers)下有变动时回调ZookeeperRegistry.this.notify(url, listener, toUrlsWithEmpty(url, parentPath, currentChilds)); 方法分别对应动态规格变化, 路由规则变化和提供者变化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
ZookeeperRegistry.doSubscribe(){ .... for (String path : toCategoriesPath(url)) { ConcurrentMap<NotifyListener, ChildListener> listeners = zkListeners.get(url); if (listeners == null) { zkListeners.putIfAbsent(url, new ConcurrentHashMap<NotifyListener, ChildListener>()); listeners = zkListeners.get(url); } ChildListener zkListener = listeners.get(listener); if (zkListener == null) { listeners.putIfAbsent(listener, new ChildListener() { public void childChanged(String parentPath, List currentChilds) { ZookeeperRegistry.this.notify(url, listener, toUrlsWithEmpty(url, parentPath, currentChilds)); } }); zkListener = listeners.get(listener); } zkClient.create(path, false); List children = zkClient.addChildListener(path, zkListener); if (children != null) { urls.addAll(toUrlsWithEmpty(url, path, children)); } } ... } |
在AbstractRegistry.saveProperties(URL url) 实现了服务治理信息的本地缓存功能, 当注册中心崩溃时也能正常使用
Posted in: MySQL practise
Comments are closed.