* @return true if the connection succeeded, false if not * @throws InterruptedException interrupted while waiting */ public boolean blockUntilConnectedOrTimedOut() throws InterruptedException { Preconditions.checkState(started.get(), "Client is not started"); log.debug("blockUntilConnectedOrTimedOut()...
STARTED) { throw new SofaRpcRuntimeException("Zookeeper client is not available"); } return zkClient; } 代码示例来源:origin: apache/hive private CuratorFramework getSession() { if (zkSession == null || zkSession.getState() == CuratorFrameworkState.STOPPED) { synchronized (this) { if (zk...
getState(); if (state != CuratorFrameworkState.STARTED) { builder.down().withDetail("error", "Client not started"); } else if (this.curator.checkExists().forPath("/") == null) { builder.down().withDetail("error", "Root for namespace does not exist"); } else { builder.up();...
STARTED) && isConnected.get() ) { client.checkExists().creatingParentContainersIfNeeded().usingWatcher(watcher).inBackground(backgroundCallback).forPath(path); } } 监听对象watcher 所干的事情就是不断重新执行reset方法,把监听器重新注册到对应的节点上面。 代码语言:java 复制 private Watcher watcher =...
// reset() 方法内部实现 private void reset() throws Exception { if ( (state.get() == State.STARTED) && isConnected.get() ) { client.checkExists().creatingParentContainersIfNeeded().usingWatcher(watcher).inBackground(backgroundCallback).forPath(path); } } 监听对象watcher 所干的事情就是...
currentClient = clients[index.getAndIncrement() % clients.length]; } try { boolean isAsync = RpcUtils.isAsync(getUrl(), invocation); boolean isOneway = RpcUtils.isOneway(getUrl(), invocation); int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TI...
client.create().forPath(path); 1. // 创建一个节点,初始内容为空 client.create().forPath("/tmp"); 1. 2. 从结果可以看到,如果没有设置节点属性,那么Curator默认创建的是持久节点。 创建一个节点,附带初始内容 // 创建一个节点,附带初始内容 client.create().forPath("/tmp", "init".getBytes())...
If one of the files defined in the configuration settingsclient.certificate,client.client_certorclient.client_keyis not found (or can not be accessed e.g. due to permission denied),curatorshould report a meaningful error indicating the problem. ...
if(client.isConnected()){ returnResult.healthy(); }else{ returnResult.unhealthy("CuratorZookeeperClient reports that it is not connected"); } } } 代码示例来源:origin: Netflix/curator @Override publicvoidprocessResult(CuratorFrameworkclient,CuratorEventevent)throwsException ...
Zkclient是在原生zookeeper基础上进行扩展的开源第三方Java客户端,使用起来相比较原生客户端,方便太多了。 Github源码:https://github.com/sgroschupf/zkclient 4.1 官方自带的zookeeper客户端存在的问题 session会话超时异常时,不支持自动重连,需要手动重新连接,编程繁琐(生产环境中如果网络出现不稳定情况,那么这种情况出现...