congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
me.hao0.antares.common.zk
Code IndexAdd Tabnine to your IDE (free)

How to use me.hao0.antares.common.zk

Best Java code snippets using me.hao0.antares.common.zk (Showing top 20 results out of 315)

origin: ihaolin/antares

/**
 * Create a client instancclientAppPathExiste
 * @param hosts host strings: zk01:2181,zk02:2181,zk03:2181
 * @param namespace path root, such as app name
 */
public static ZkClient newClient(String hosts, String namespace){
  return newClient(hosts, namespace, DEFAULT_RETRY_STRATEGY);
}
origin: ihaolin/antares

/**
 * Create an ephemeral path
 * @param path path
 * @return the path created
 */
public String createEphemeral(String path) {
  return createEphemeral(path, (byte[]) null);
}
origin: ihaolin/antares

  @Override
  protected void doShutdown() {
    if (watcher != null){
      watcher.stop();
    }
  }
}
origin: ihaolin/antares

/**
 * new a watcher of path child
 * @param path the parent path
 * @param listener a listener
 * NOTE:
 *   Only watch first level children, not recursive
 */
public ChildWatcher newChildWatcher(String path, ChildListener listener) {
  return newChildWatcher(path, listener, Boolean.TRUE);
}
origin: ihaolin/antares

/**
 * Acquire the leadership
 * @param leaderPath the leader node path
 * @param listener the leader listener
 * @return the leadership
 */
public Leader acquireLeader(String leaderPath, LeaderListener listener){
  return acquireLeader(null, leaderPath, listener);
}
origin: ihaolin/antares

  @Override
  public void destroy() throws Exception {
    client.shutdown();
  }
}
origin: ihaolin/antares

/**
 * Create a client instance
 * @param hosts host strings: zk01:2181,zk02:2181,zk03:2181
 * @param namespace path root, such as app name
 * @param retryStrategy client retry strategy
 */
public static ZkClient newClient(String hosts, String namespace, ExponentialBackoffRetry retryStrategy){
  ZkClient zc = new ZkClient(hosts, namespace, retryStrategy);
  zc.start();
  return zc;
}
origin: ihaolin/antares

/**
 * Create an persistent path
 * @param path path
 * @return the path created
 */
public String create(String path) {
  return create(path, (byte[])null);
}
origin: ihaolin/antares

/**
 * new a node watcher
 * @param nodePath the node path
 * @return the node watcher
 */
public NodeWatcher newNodeWatcher(String nodePath){
  return newNodeWatcher(nodePath, null);
}
origin: ihaolin/antares

/**
 * Acquire the leadership
 * @param id identify of the current participant
 * @param leaderPath the leader node path
 * @param listener the leader listener
 * @return the leadership
 */
public Leader acquireLeader(String id, String leaderPath, LeaderListener listener){
  return new Leader(client, id, leaderPath, listener);
}
origin: ihaolin/antares

private void start() {
  if (started){
    return;
  }
  doStart();
}
origin: ihaolin/antares

/**
 * lock the path
 * @param path the path
 */
public Lock newLock(String path) {
  return new Lock(client, path);
}
origin: ihaolin/antares

/**
 * Get the current leader host
 * @return the current leader host
 */
public String getLeader(){
  return leader.getLeader();
}
origin: ihaolin/antares

/**
 * Create a node if not exists
 * @param path path
 * @return return true if create
 */
public Boolean createIfNotExists(String path) {
  return createIfNotExists(path, (byte[])null);
}
origin: ihaolin/antares

/**
 * new a node watcher
 * @param nodePath the node path
 * @param listener the node listener
 * @return the node watcher
 */
public NodeWatcher newNodeWatcher(String nodePath, NodeListener listener){
  return new NodeWatcher(client, nodePath, listener);
}
origin: ihaolin/antares

/**
 * Is the leader or not
 * @return return true if I'm the leader, or false
 */
public Boolean isLeader(){
  return leader.isLeader();
}
origin: ihaolin/antares

/**
 * new a watcher of path child
 * @param path the parent path
 * @param listener a listener
 * @param cacheChildData cache child or not
 *
 * <p>NOTE:
 *   Only watch first level children, not recursive
 * </p>
 * @return the child watcher
 */
public ChildWatcher newChildWatcher(String path, ChildListener listener, Boolean cacheChildData) {
  return new ChildWatcher(client, path, cacheChildData, listener);
}
origin: ihaolin/antares

AntaresZkAgent(AbstractAntaresClient client, String zkServers, String namespace){
  this.client = client;
  this.zk = ZkClient.newClient(zkServers, namespace);
}
origin: ihaolin/antares

  @Override
  public void doShutdown() {
    watcher.stop();
  }
}
origin: ihaolin/antares

@Override
public void doShutdown() {
  watcher.stop();
}
me.hao0.antares.common.zk

Most used classes

  • ZkClient
    Author: haolin Email : haolin.h0@gmail.com
  • ChildWatcher
    The node child watcher
  • Lock
    Distribute lock, usually should be singleton
  • Leader
    Author: haolin Email: haolin.h0@gmail.com
  • NodeWatcher
    The node watcher
  • LeaderListener,
  • NodeListener
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now