org.apache.twill.zookeeper.ZKClient.getSessionId()方法的使用及代码示例

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

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

ZKClient.getSessionId介绍

[英]Returns the current Zookeeper session ID of this client. If this ZKClient is not connected, null is returned.
[中]返回此客户端的当前Zookeeper会话ID。如果该客户端未连接,则返回null。

代码示例

代码示例来源:origin: org.apache.twill/twill-zookeeper

@Override
public Long getSessionId() {
 return client.getSessionId();
}

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

@Override
public Long getSessionId() {
 return delegate.getSessionId();
}

代码示例来源:origin: org.apache.twill/twill-zookeeper

@Override
public Long getSessionId() {
 return delegate.getSessionId();
}

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

@Override
public Long getSessionId() {
 return delegate.getSessionId();
}

代码示例来源:origin: org.apache.twill/twill-zookeeper

@Override
public Long getSessionId() {
 return delegate.getSessionId();
}

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

@Override
public Long getSessionId() {
 return client.getSessionId();
}

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

@Override
public void onSuccess(@Nullable Stat result) {
 if (result == null) {
  // If the node is gone, simply retry.
  LOG.info("Node {} is gone. Retry registration for {}.", path, discoverable);
  retryRegister(discoverable, creationCallback);
  return;
 }
 long ephemeralOwner = result.getEphemeralOwner();
 if (ephemeralOwner == 0) {
  // it is not an ephemeral node, something wrong.
  LOG.error("Node {} already exists and is not an ephemeral node. Discoverable registration failed: {}.",
       path, discoverable);
  completion.setException(failureCause);
  return;
 }
 Long sessionId = zkClient.getSessionId();
 if (sessionId == null || ephemeralOwner != sessionId) {
  // This zkClient is not valid or doesn't own the ephemeral node, simply keep retrying.
  LOG.info("Owner of {} is different. Retry registration for {}.", path, discoverable);
  retryRegister(discoverable, creationCallback);
 } else {
  // This client owned the node, treat the registration as completed.
  // This could happen if same client tries to register twice (due to mistake or failure race condition).
  completion.set(path);
 }
}

代码示例来源:origin: org.apache.twill/twill-discovery-core

@Override
public void onSuccess(@Nullable Stat result) {
 if (result == null) {
  // If the node is gone, simply retry.
  LOG.info("Node {} is gone. Retry registration for {}.", path, discoverable);
  retryRegister(discoverable, creationCallback);
  return;
 }
 long ephemeralOwner = result.getEphemeralOwner();
 if (ephemeralOwner == 0) {
  // it is not an ephemeral node, something wrong.
  LOG.error("Node {} already exists and is not an ephemeral node. Discoverable registration failed: {}.",
       path, discoverable);
  completion.setException(failureCause);
  return;
 }
 Long sessionId = zkClient.getSessionId();
 if (sessionId == null || ephemeralOwner != sessionId) {
  // This zkClient is not valid or doesn't own the ephemeral node, simply keep retrying.
  LOG.info("Owner of {} is different. Retry registration for {}.", path, discoverable);
  retryRegister(discoverable, creationCallback);
 } else {
  // This client owned the node, treat the registration as completed.
  // This could happen if same client tries to register twice (due to mistake or failure race condition).
  completion.set(path);
 }
}

相关文章