Exemplo n.º 1
0
  private void processBackgroundCallback(CuratorEvent event) throws Exception {
    String path = null;
    boolean nodeExists = false;
    if (event.getResultCode() == KeeperException.Code.NODEEXISTS.intValue()) {
      path = event.getPath();
      nodeExists = true;
    } else if (event.getResultCode() == KeeperException.Code.OK.intValue()) {
      path = event.getName();
    } else if (event.getResultCode() == KeeperException.Code.NOAUTH.intValue()) {
      log.warn("Client does not have authorisation to write node at path {}", event.getPath());
      authFailure.set(true);
      return;
    }
    if (path != null) {
      authFailure.set(false);
      nodePath.set(path);
      watchNode();

      if (nodeExists) {
        client.setData().inBackground(setDataCallback).forPath(getActualPath(), getData());
      } else {
        initialisationComplete();
      }
    } else {
      createNode();
    }
  }
Exemplo n.º 2
0
 @Override
 public void processResult(CuratorFramework client, CuratorEvent event) throws Exception {
   // If the result is ok then initialisation is complete (if we're still initialising)
   // Don't retry on other errors as the only recoverable cases will be connection loss
   // and the node not existing, both of which are already handled by other watches.
   if (event.getResultCode() == KeeperException.Code.OK.intValue()) {
     // Update is ok, mark initialisation as complete if required.
     initialisationComplete();
   }
 }