Jetcd是etcd的简单Java客户端开发包。etcd是CoreOS中的高可用Key/Value存储和
示例代码:
EtcdClientclient=newEtcdClient(URI.create("https://127.0.0.1:4001/"));Stringkey="/watch";EtcdResultresult=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);EtcdResultwatchResult=watchFuture.get(100,TimeUnit.MILLISECONDS);Assert.assertNotNull(result);Assert.assertEquals("world",result.value);
评论