ZookeeperRegistry extends CommandFailbackRegistry implements Closable { @Override protected List<URL> discoverService(URL url) { try { String parentPath = ZkUtils.toNodeTypePath(url, ZkNodeType.AVAILABLE_SERVER); List<String> currentChilds = new ArrayList<>(); if (zkClient.exists(parentPath)) { currentChilds = zkClient.getChildren(parentPath); } return nodeChildsToUrls(url, parentPath, currentChilds); } catch (Throwable e) { throw new MotanFrameworkException(String.format("Failed to discover service %s from zookeeper(%s), cause: %s", url, getUrl(), e.getMessage()), e); } } ZookeeperRegistry(URL url, ZkClient client); ConcurrentHashMap<URL, ConcurrentHashMap<ServiceListener, IZkChildListener>> getServiceListeners(); ConcurrentHashMap<URL, ConcurrentHashMap<CommandListener, IZkDataListener>> getCommandListeners(); @Override void close();  }
@Test public void discoverService() throws Exception { registry.doRegister(serviceUrl); List<URL> results = registry.discoverService(clientUrl); Assert.assertTrue(results.isEmpty()); registry.doAvailable(serviceUrl); results = registry.discoverService(clientUrl); Assert.assertTrue(results.contains(serviceUrl)); }