Search in sources :

Example 1 with WatchedUpdateListener

use of com.netflix.config.WatchedUpdateListener in project archaius by Netflix.

the class ZooKeeperConfigurationSourceTest method setZkProperty.

private static void setZkProperty(String key, String value) throws Exception {
    // update the underlying zk property and assert that the new value is picked up
    final CountDownLatch updateLatch = new CountDownLatch(1);
    zkConfigSource.addUpdateListener(new WatchedUpdateListener() {

        public void updateConfiguration(WatchedUpdateResult result) {
            updateLatch.countDown();
        }
    });
    zkConfigSource.setZkProperty(key, value);
    updateLatch.await();
}
Also used : WatchedUpdateListener(com.netflix.config.WatchedUpdateListener) CountDownLatch(java.util.concurrent.CountDownLatch) WatchedUpdateResult(com.netflix.config.WatchedUpdateResult)

Example 2 with WatchedUpdateListener

use of com.netflix.config.WatchedUpdateListener in project chassis by Kixeye.

the class DynamicZookeeperConfigurationSource method initializeZookeeperConfigurationSource.

private void initializeZookeeperConfigurationSource() {
    if (running) {
        LOGGER.warn("Detected creation of node {}, but zookeeper configuration source already running. This should not happen. Ignoring event...", instanceConfigPath);
        return;
    }
    this.zooKeeperConfigurationSource = new ZooKeeperConfigurationSource(curatorFramework, instanceConfigPath);
    listeners.forEach(new Function<WatchedUpdateListener, Void>() {

        @Nullable
        @Override
        public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) {
            zooKeeperConfigurationSource.addUpdateListener(watchedUpdateListener);
            return null;
        }
    });
    try {
        zooKeeperConfigurationSource.start();
    } catch (Exception e) {
        LOGGER.error("errro starting zookeeper configuration source", e);
        throw new BootstrapException("Error initializing zookeeper configuration source", e);
    }
    running = true;
}
Also used : ZooKeeperConfigurationSource(com.netflix.config.source.ZooKeeperConfigurationSource) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) WatchedUpdateListener(com.netflix.config.WatchedUpdateListener) Nullable(javax.annotation.Nullable) BootstrapException(com.kixeye.chassis.bootstrap.BootstrapException) IOException(java.io.IOException)

Aggregations

WatchedUpdateListener (com.netflix.config.WatchedUpdateListener)2 BootstrapException (com.kixeye.chassis.bootstrap.BootstrapException)1 WatchedUpdateResult (com.netflix.config.WatchedUpdateResult)1 ZooKeeperConfigurationSource (com.netflix.config.source.ZooKeeperConfigurationSource)1 IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Nullable (javax.annotation.Nullable)1