Ejemplo n.º 1
0
  /**
   * Add this instance to the leadership election and attempt to acquire leadership.
   *
   * @throws Exception errors
   */
  public void start() throws Exception {
    Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Already started");

    client.getConnectionStateListenable().addListener(listener);

    client.newNamespaceAwareEnsurePath(latchPath).ensure(client.getZookeeperClient());
    internalStart();
  }
Ejemplo n.º 2
0
  LockInternals(
      CuratorFramework client,
      LockInternalsDriver driver,
      String path,
      String lockName,
      int maxLeases) {
    this.driver = driver;
    this.lockName = lockName;
    this.maxLeases = maxLeases;
    PathUtils.validatePath(path);

    this.client = client;
    this.basePath = path;
    this.path = ZKPaths.makePath(path, lockName);

    ensurePath = client.newNamespaceAwareEnsurePath(basePath);
  }