org.apache.zookeeper.ZooKeeper.getConfig()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(187)

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

ZooKeeper.getConfig介绍

[英]The asynchronous version of getConfig.
[中]getConfig的异步版本。

代码示例

代码示例来源:origin: apache/zookeeper

/**
 * The Asynchronous version of getConfig. 
 * 
 * @see #getData(String, boolean, Stat)
 */
public void getConfig(boolean watch, DataCallback cb, Object ctx) {
  getConfig(watch ? watchManager.defaultWatcher : null, cb, ctx);
}

代码示例来源:origin: apache/zookeeper

/**
 * Return the last committed configuration (as known to the server to which the client is connected)
 * and the stat of the configuration.
 * <p>
 * If the watch is true and the call is successful (no exception is
 * thrown), a watch will be left on the configuration node (ZooDefs.CONFIG_NODE). The watch
 * will be triggered by a successful reconfig operation
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param watch whether need to watch this node
 * @param stat the stat of the configuration node ZooDefs.CONFIG_NODE
 * @return configuration data stored in ZooDefs.CONFIG_NODE
 * @throws KeeperException If the server signals an error with a non-zero error code
 * @throws InterruptedException If the server transaction is interrupted.
 */
public byte[] getConfig(boolean watch, Stat stat)
    throws KeeperException, InterruptedException {
  return getConfig(watch ? watchManager.defaultWatcher : null, stat);
}

代码示例来源:origin: apache/zookeeper

@Override
  public boolean exec() throws CliException {
    boolean watch = cl.hasOption("w");        
    Stat stat = new Stat();
    byte data[];
    try {
      data = zk.getConfig(watch, stat);
    } catch (KeeperException|InterruptedException ex) {
      throw new CliWrapperException(ex);
    }
    data = (data == null) ? "null".getBytes() : data;
    if (cl.hasOption("c")) {
      out.println(ConfigUtils.getClientConfigStr(new String(data)));
    } else {
      out.println(new String(data));
    }
    
    if (cl.hasOption("s")) {
      new StatPrinter(out).print(stat);
    }                
    
    return watch;
  }
}

代码示例来源:origin: apache/zookeeper

config = zk.getConfig(false, new Stat());
  break;
} catch (KeeperException.ConnectionLossException e) {

代码示例来源:origin: apache/zookeeper

ReconfigTest.testServerHasConfig(zkHandles[leaderId], null, null);
LOG.info("Initial Configuration:\n"
     + new String(zkHandles[leaderId].getConfig(this, new Stat())));
testReconfig(leaderId, true, reconfigServers);
LOG.info("Configuration after adding 2 followers:\n"
     + new String(zkHandles[leaderId].getConfig(this, new Stat())));
testReconfig(follower2, false, reconfigServers);
LOG.info("Configuration after removing leader and follower 1:\n"
    + new String(zkHandles[follower2].getConfig(this, new Stat())));
testReconfig(follower2, true, observerStrings); //change to observers
LOG.info("Configuration after adding two observers:\n"
    + new String(zkHandles[follower2].getConfig(this, new Stat())));

代码示例来源:origin: org.apache.curator/curator-framework

@Override
  public byte[] call() throws Exception
  {
    if ( watching.isWatched() )
    {
      return client.getZooKeeper().getConfig(true, stat);
    }
    byte[] config = client.getZooKeeper().getConfig(watching.getWatcher(ZooDefs.CONFIG_NODE), stat);
    watching.commitWatcher(KeeperException.NoNodeException.Code.OK.intValue(), false);
    return config;
  }
}

代码示例来源:origin: org.apache.curator/curator-framework

if ( watching.isWatched() )
  client.getZooKeeper().getConfig(true, callback, backgrounding.getContext());
  client.getZooKeeper().getConfig(watching.getWatcher(ZooDefs.CONFIG_NODE), callback, backgrounding.getContext());

相关文章