gpt4 book ai didi

com.github.zkclient.ZkClient.exists()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:30:51 26 4
gpt4 key购买 nike

本文整理了Java中com.github.zkclient.ZkClient.exists()方法的一些代码示例,展示了ZkClient.exists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.exists()方法的具体详情如下:
包路径:com.github.zkclient.ZkClient
类名称:ZkClient
方法名:exists

ZkClient.exists介绍

暂无

代码示例

代码示例来源:origin: adyliu/jafka

public static void makeSurePersistentPathExists(ZkClient zkClient, String path) {
  if (!zkClient.exists(path)) {
    zkClient.createPersistent(path, true);
  }
}

代码示例来源:origin: com.github.adyliu/zkclient

@Override
  public List<String> call() throws Exception {
    exists(path, true);
    try {
      return getChildren(path, true);
    } catch (ZkNoNodeException e) {
      // ignore, the "exists" watch will listen for the parent node to appear
    }
    return null;
  }
});

代码示例来源:origin: adyliu/zkclient

@Override
  public List<String> call() throws Exception {
    exists(path, true);
    try {
      return getChildren(path, true);
    } catch (ZkNoNodeException e) {
      // ignore, the "exists" watch will listen for the parent node to appear
    }
    return null;
  }
});

代码示例来源:origin: adyliu/zkclient

public boolean exists(final String path) {
  return exists(path, hasListeners(path));
}

代码示例来源:origin: com.github.adyliu/zkclient

public boolean exists(final String path) {
  return exists(path, hasListeners(path));
}

代码示例来源:origin: com.github.adyliu/zkclient

@Override
  public void run() throws Exception {
    // reinstall watch
    exists(path, true);
    try {
      byte[] data = readData(path, null, true);
      listener.handleDataChange(path, data);
    } catch (ZkNoNodeException e) {
      listener.handleDataDeleted(path);
    }
  }
});

代码示例来源:origin: adyliu/zkclient

@Override
  public void run() throws Exception {
    // reinstall watch
    exists(path, true);
    try {
      byte[] data = readData(path, null, true);
      listener.handleDataChange(path, data);
    } catch (ZkNoNodeException e) {
      listener.handleDataDeleted(path);
    }
  }
});

代码示例来源:origin: com.github.adyliu/zkclient

@Override
  public void run() throws Exception {
    try {
      // if the node doesn't exist we should listen for the root node to reappear
      exists(path);
      List<String> children = getChildren(path);
      listener.handleChildChange(path, children);
    } catch (ZkNoNodeException e) {
      listener.handleChildChange(path, null);
    }
  }
});

代码示例来源:origin: com.github.adyliu/zkclient

public boolean waitUntilExists(String path, TimeUnit timeUnit, long time) throws ZkInterruptedException {
  Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
  LOG.debug("Waiting until znode '" + path + "' becomes available.");
  if (exists(path)) {
    return true;
  }
  acquireEventLock();
  try {
    while (!exists(path, true)) {
      boolean gotSignal = getEventLock().getZNodeEventCondition().awaitUntil(timeout);
      if (!gotSignal) {
        return false;
      }
    }
    return true;
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  } finally {
    getEventLock().unlock();
  }
}

代码示例来源:origin: adyliu/zkclient

@Override
  public void run() throws Exception {
    try {
      // if the node doesn't exist we should listen for the root node to reappear
      exists(path);
      List<String> children = getChildren(path);
      listener.handleChildChange(path, children);
    } catch (ZkNoNodeException e) {
      listener.handleChildChange(path, null);
    }
  }
});

代码示例来源:origin: adyliu/zkclient

public boolean waitUntilExists(String path, TimeUnit timeUnit, long time) throws ZkInterruptedException {
  Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
  LOG.debug("Waiting until znode '" + path + "' becomes available.");
  if (exists(path)) {
    return true;
  }
  acquireEventLock();
  try {
    while (!exists(path, true)) {
      boolean gotSignal = getEventLock().getZNodeEventCondition().awaitUntil(timeout);
      if (!gotSignal) {
        return false;
      }
    }
    return true;
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  } finally {
    getEventLock().unlock();
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com