zookeeper-API操作-删除节点
工程具体结构见上文
https://www.cnblogs.com/aoligei/p/15010287.html
//=============================delete============================== /** * 1.删除单个节点 client.delete().forPath("/test1"); * 2.删除带有子节点的节点 client.delete().deletingChildrenIfNeeded().forPath("/test4"); * 3.必须成功的删除 (防止网络抖动,重试删除) client.delete().guaranteed().forPath("/test2"); * 4.回调 client.delete().guaranteed().inBackground(new BackgroundCallback() { * public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { */ @Test public void testDelete1() throws Exception { //1.删除单个节点 client.delete().forPath("/test1"); } @Test public void testDelete2() throws Exception { //2.删除带有子节点的节点 client.delete().deletingChildrenIfNeeded().forPath("/test4"); } @Test public void testDelete3() throws Exception { //3.必须成功的删除 (网络延迟,没连接上服务端) client.delete().guaranteed().forPath("/test2"); } @Test public void testDelete4() throws Exception { //4.回调 client.delete().guaranteed().inBackground(new BackgroundCallback() { public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { System.out.println("执行删除操作"); System.out.println(event); } }).forPath("/test"); }
1、删除节点
2、删除带有子节点的节点
删除操作后
3、必须成功的删除 (可能网络原因造成删除失败)
4、回调 (节点删完了就自己创建)