ZooKeeperConfigurationSource implements WatchedConfigurationSource, Closeable { synchronized void setZkProperty(String key, String value) throws Exception { final String path = configRootPath + "/" + key; byte[] data = value.getBytes(charset); try { client.create().creatingParentsIfNeeded().forPath(path, data); } catch (NodeExistsException exc) { client.setData().forPath(path, data); } } ZooKeeperConfigurationSource(CuratorFramework client, String configRootPath); void start(); @Override Map<String, Object> getCurrentData(); @Override void addUpdateListener(WatchedUpdateListener l); @Override void removeUpdateListener(WatchedUpdateListener l); void close();  }
@Test public void testZkPropertyOverride() throws Exception { setZkProperty("test.key1", "test.value1-zk"); Assert.assertEquals("test.value1-zk", DynamicPropertyFactory.getInstance() .getStringProperty("test.key1", "default").get()); }
@Test public void testUpdatePropertyOverride() throws Exception { setZkProperty("test.key1", "test.value1-zk"); mapConfig.setProperty("test.key1", "prop1"); Assert.assertEquals("test.value1-zk", DynamicPropertyFactory.getInstance() .getStringProperty("test.key1", "default").get()); }
@Test public void testUpdateZkProperty() throws Exception { setZkProperty("test.key1", "test.value1-zk-override"); Assert.assertEquals("test.value1-zk-override", DynamicPropertyFactory.getInstance() .getStringProperty("test.key1", "default").get()); }