ZookeeperRegistry extends CommandFailbackRegistry implements Closable { @Override protected String discoverCommand(URL url) { try { String commandPath = ZkUtils.toCommandPath(url); String command = ""; if (zkClient.exists(commandPath)) { command = zkClient.readData(commandPath); } return command; } catch (Throwable e) { throw new MotanFrameworkException(String.format("Failed to discover command %s from zookeeper(%s), cause: %s", url, getUrl(), e.getMessage())); } } ZookeeperRegistry(URL url, ZkClient client); ConcurrentHashMap<URL, ConcurrentHashMap<ServiceListener, IZkChildListener>> getServiceListeners(); ConcurrentHashMap<URL, ConcurrentHashMap<CommandListener, IZkDataListener>> getCommandListeners(); @Override void close();  }
@Test public void discoverCommand() throws Exception { String result = registry.discoverCommand(clientUrl); Assert.assertTrue(result.equals("")); String command = "{\"index\":0,\"mergeGroups\":[\"aaa:1\",\"bbb:1\"],\"pattern\":\"*\",\"routeRules\":[]}\n"; String commandPath = ZkUtils.toCommandPath(clientUrl); if (!zkClient.exists(commandPath)) { zkClient.createPersistent(commandPath, true); } zkClient.writeData(commandPath, command); result = registry.discoverCommand(clientUrl); Assert.assertTrue(result.equals(command)); }