-
Notifications
You must be signed in to change notification settings - Fork 483
ZooKeeper Dynamic Configuration
jon-ruckwood edited this page Nov 19, 2014
·
8 revisions
- FluxCapacitor uses ZooKeeper as its dynamic configuration source through archaius-zookeeper.
- Changes to these ZK-based properties will be picked up dynamically at runtime using ZK's watcher/callback functionality.
- [ZooKeeperConfigurationSource] (https://github.com/Netflix/archaius/blob/master/archaius-zookeeper/src/main/java/com/netflix/config/source/ZooKeeperConfigurationSource.java)
- This implementation requires the path to the ZK root parent node that contains the hierarchy of configuration properties. An example is
/[my-app]/config
- Properties are direct ZK child nodes of the root parent ZK node. An example ZK child property node is
/[my-app]/config/com.fluxcapacitor.my.property
- The value is stored in the ZK child property node and can be updated at any time.
- All servers will receive a ZK Watcher callback and automatically update their value similar to other dynamic configuration sources (ie. DynamoDB, etc.)
- Any node created or updated under this node - even dynamically at runtime - will be accessible through the archaius dynamic property framework.
String zkConfigRootPath = "/[my-app]/config";
CuratorFramework client CuratorFrameworkFactory.newClient(zkConnectionString,
new ExponentialBackoffRetry(1000, 3));
ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(client, zkConfigRootPath);
zkConfigSource.start();
DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource);
ConfigurationManager.install(zkDynamicConfig);
The property value is retrieved from the /[my-app]/config/com.fluxcapacitor.my.property
ZK node:
String myProperty = DynamicPropertyFactory.getInstance()
.getStringProperty("com.fluxcapacitor.my.property", "<none>")
.get();
- [Flux Capacitor] (https://github.com/cfregly/fluxcapacitor)