@Test public void testFactory() throws Exception { String name = "factory.ini"; File f = factory.getPath().resolve(name).toFile(); TestHelper.writeFile(ZookeeperUtil.newBytes("a=-1"), f); ProcessInfo info = factory.getInfo(); String path = ZKPaths.makePath(info.getPath(), name, info.getProfile()); final AtomicInteger num = new AtomicInteger(0); RemoteConfigWithCache c = (RemoteConfigWithCache) factory.getConfig(name); c.setDelaySeconds(1); c.addListener(new IChangeListener() { @Override public void changed(IConfig config) { num.incrementAndGet(); } }, false); assertThat(c.getInt("a"), is(-1)); Thread.sleep(2000); ZookeeperUtil.create(factory.getClient(), path, ZookeeperUtil.newBytes("a=1")); TestHelper.busyWait(num); assertThat(c.getInt("a"), is(1)); num.set(0); ZookeeperUtil.setData(factory.getClient(), path, ZookeeperUtil.newBytes("a=2")); TestHelper.busyWait(num); assertThat(c.getInt("a"), is(2)); TestHelper.deleteFile(f); }
public Path getPath() { return path; }
RemoteConfigWithCacheFactory extends RemoteConfigFactory { public Path getPath() { return path; } }
RemoteConfigWithCacheFactory extends RemoteConfigFactory { public Path getPath() { return path; } RemoteConfigWithCacheFactory(Path localConfigPath, ProcessInfo info, CuratorFramework client); }
RemoteConfigWithCacheFactory extends RemoteConfigFactory { public Path getPath() { return path; } RemoteConfigWithCacheFactory(Path localConfigPath, ProcessInfo info, CuratorFramework client); static RemoteConfigWithCacheFactory getInstance(); Path getPath(); }
RemoteConfigWithCacheFactory extends RemoteConfigFactory { public Path getPath() { return path; } RemoteConfigWithCacheFactory(Path localConfigPath, ProcessInfo info, CuratorFramework client); static RemoteConfigWithCacheFactory getInstance(); Path getPath();  }