2017-05-19 3 views

Répondre

1

Nous pouvons exécuter l'opération de création de manière asynchrone étant donné tout en spécifiant le mode de création comme ci-dessous,

client.create() 
      .withMode(CreateMode.PERSISTENT) 
      .inBackground() 
      .forPath("/mypath", new byte[0]); 
1

Si vous êtes sur Java 8 et ZooKeeper 3.5.x, la dernière version du conservateur (note: je m l'auteur principal) a une nouvelle DSL pour async. Vous pouvez lire ici: http://curator.apache.org/curator-x-async/index.html

Par ex

AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client); 
async.checkExists().forPath(somePath).thenAccept(stat -> mySuccessOperation(stat)); 
+0

Dans mon cas, j'utilisais Zookeeper 3.4.10. Et le conservateur 2.9.X –