Jetcd 是 etcd 的简单 Java 客户端开发包。etcd 是 CoreOS 中的高可用 Key/Value 存储和
示例代码:
EtcdClient client = new EtcdClient(URI.create("http://127.0.0.1:4001/")); String key = "/watch"; EtcdResult result = this.client.set(key, "hello"); Assert.assertEquals("hello", result.value); result = this.client.get(key); Assert.assertEquals("hello", result.value); ListenableFuture<EtcdResult> watchFuture = this.client.watch(key, result.index + 1); Assert.assertFalse(watchFuture.isDone()); result = this.client.set(key, "world"); Assert.assertEquals("world", result.value); EtcdResult watchResult = watchFuture.get(100, TimeUnit.MILLISECONDS); Assert.assertNotNull(result); Assert.assertEquals("world", result.value);