public void testZKBackedConfigStore() throws IOException,
InterruptedException {
for (int i = 0; i < 10; ++i) {
LOG.info("Opening ZK, attempt " + i);
File tmp = FileUtil.mktempdir();
FlumeConfiguration cfg = FlumeConfiguration.createTestableConfiguration();
cfg.set(FlumeConfiguration.MASTER_ZK_LOGDIR, tmp.getAbsolutePath());
cfg.set(FlumeConfiguration.MASTER_ZK_SERVERS, "localhost:2181:3181:4181");
ZooKeeperService.getAndInit(cfg);
ZooKeeperConfigStore store = new ZooKeeperConfigStore();
store.init();
ConfigManager manager = new ConfigManager(store);
manager.setConfig("foo", "my-test-flow", "null", "console");
FlumeConfigData data = manager.getConfig("foo");
assertEquals(data.getSinkConfig(), "console");
assertEquals(data.getSourceConfig(), "null");
store.shutdown();
store = new ZooKeeperConfigStore();
store.init();
manager = new ConfigManager(store);
data = manager.getConfig("foo");
assertEquals(data.getSinkConfig(), "console");
assertEquals(data.getSourceConfig(), "null");
Map<String, FlumeConfigData> cfgs = new HashMap<String, FlumeConfigData>();
String defaultFlowName = cfg.getDefaultFlowName();
cfgs.put("bulk1", new FlumeConfigData(0, "s1", "sk1",
LogicalNode.VERSION_INFIMUM, LogicalNode.VERSION_INFIMUM,
"my-test-flow"));
cfgs.put("bulk2", new FlumeConfigData(0, "s2", "sk2",
LogicalNode.VERSION_INFIMUM, LogicalNode.VERSION_INFIMUM,