com.hazelcast.nio.Address.getHost()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(97)

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

Address.getHost介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
public Optional<String> getLeaderHostName() {
 String leaderId = (String) hzMember.getAtomicReference(LEADER).get();
 if (leaderId != null) {
  Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderId)).findFirst();
  if (leader.isPresent()) {
   return Optional.of(leader.get().getAddress().getHost());
  }
 }
 return Optional.empty();
}

代码示例来源:origin: SonarSource/sonarqube

public Collection<NodeInfo> load() throws InterruptedException {
 Map<String, NodeInfo> nodesByName = new HashMap<>();
 MemberSelector memberSelector = HazelcastMemberSelectors.selectorForProcessIds(ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE);
 DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer = hzMember.call(ProcessInfoProvider::provide, memberSelector, DISTRIBUTED_TIMEOUT_MS);
 for (Member member : distributedAnswer.getMembers()) {
  String nodeName = member.getStringAttribute(NODE_NAME.getKey());
  NodeInfo nodeInfo = nodesByName.computeIfAbsent(nodeName, name -> {
   NodeInfo info = new NodeInfo(name);
   info.setHost(member.getAddress().getHost());
   return info;
  });
  completeNodeInfo(distributedAnswer, member, nodeInfo);
 }
 return nodesByName.values();
}

代码示例来源:origin: hazelcast/hazelcast-jet

public String getScopedHost() {
  return (isIPv4() || hostSet || scopeId == null) ? getHost()
      : getHost() + '%' + scopeId;
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public String toUrn() {
  return URN_BASE + (address == null ? "-" : (address.getHost() + ":" + String.valueOf(address.getPort()))) + DESC_SEP
      + String.valueOf(partitionId) + DESC_SEP + schedulerName + DESC_SEP + taskName;
}

代码示例来源:origin: hazelcast/hazelcast-jet

public static int calculateDataSize(Address address) {
    int dataSize = ParameterUtil.calculateDataSize(address.getHost());
    dataSize += Bits.INT_SIZE_IN_BYTES;
    return dataSize;
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public String toUrn() {
  return URN_BASE + (address == null ? "-" : (address.getHost() + ":" + String.valueOf(address.getPort()))) + DESC_SEP
      + String.valueOf(partitionId) + DESC_SEP + schedulerName + DESC_SEP + taskName;
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public String toString() {
  return "[" + address.getHost() + "]" + ":" + address.getPort() + " - " + uuid;
}

代码示例来源:origin: com.hazelcast/hazelcast-all

public static int calculateDataSize(Address address) {
    int dataSize = ParameterUtil.calculateDataSize(address.getHost());
    dataSize += Bits.INT_SIZE_IN_BYTES;
    return dataSize;
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-client-protocol

public static int calculateDataSize(Address address) {
    int dataSize = ParameterUtil.calculateDataSize(address.getHost());
    dataSize += Bits.INT_SIZE_IN_BYTES;
    return dataSize;
  }
}

代码示例来源:origin: bitsofinfo/hazelcast-docker-swarm-discovery-spi

@Override
public InetSocketAddress getBindAddress() {
  Address addr = this.swarmDiscoveryUtil.getMyAddress();
  return new InetSocketAddress(addr.getHost(), addr.getPort());
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void writeObject(ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  Address address = member.getAddress();
  String host = address.getHost();
  int port = address.getPort();
  out.writeUTF(member.getUuid());
  out.writeUTF(host);
  out.writeInt(port);
  out.writeBoolean(member.isLiteMember());
  out.writeObject(member.getVersion());
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private void writeObject(ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  Address address = member.getAddress();
  String host = address.getHost();
  int port = address.getPort();
  out.writeUTF(member.getUuid());
  out.writeUTF(host);
  out.writeInt(port);
  out.writeBoolean(member.isLiteMember());
  out.writeObject(member.getVersion());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-main

@Override
public Optional<String> getLeaderHostName() {
 String leaderId = (String) hzMember.getAtomicReference(LEADER).get();
 if (leaderId != null) {
  Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderId)).findFirst();
  if (leader.isPresent()) {
   return Optional.of(leader.get().getAddress().getHost());
  }
 }
 return Optional.empty();
}

代码示例来源:origin: hazelcast/hazelcast-jet

public void setThisMember(MemberImpl thisMember) {
  this.thisMember = thisMember;
  this.thisAddressString = "[" + thisMember.getAddress().getHost() + "]:"
      + thisMember.getAddress().getPort() + " ";
}

代码示例来源:origin: com.hazelcast/hazelcast-all

public void setThisMember(MemberImpl thisMember) {
  this.thisMember = thisMember;
  this.thisAddressString = "[" + thisMember.getAddress().getHost() + "]:"
      + thisMember.getAddress().getPort() + " ";
}

代码示例来源:origin: hazelcast/hazelcast-jet

private Diagnostics newDiagnostics() {
  Address address = node.getThisAddress();
  String addressString = address.getHost().replace(":", "_") + "_" + address.getPort();
  String name = "diagnostics-" + addressString + "-" + currentTimeMillis();
  return new Diagnostics(
      name,
      loggingService.getLogger(Diagnostics.class),
      getHazelcastInstance().getName(),
      node.getProperties());
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private Diagnostics newDiagnostics() {
  Address address = node.getThisAddress();
  String addressString = address.getHost().replace(":", "_") + "_" + address.getPort();
  String name = "diagnostics-" + addressString + "-" + currentTimeMillis();
  return new Diagnostics(
      name,
      loggingService.getLogger(Diagnostics.class),
      getHazelcastInstance().getName(),
      node.getProperties());
}

代码示例来源:origin: hazelcast/hazelcast-jet

private URL newGetTaskUrl() throws IOException {
  GroupConfig groupConfig = instance.getConfig().getGroupConfig();
  Address localAddress = instance.node.getClusterService().getLocalMember().getAddress();
  String urlString = cleanupUrl(managementCenterUrl) + "getTask.do?member=" + localAddress.getHost()
      + ":" + localAddress.getPort() + "&cluster=" + encode(groupConfig.getName(), "UTF-8");
  return new URL(urlString);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private URL newGetTaskUrl() throws IOException {
  GroupConfig groupConfig = instance.getConfig().getGroupConfig();
  Address localAddress = instance.node.getClusterService().getLocalMember().getAddress();
  String urlString = cleanupUrl(managementCenterUrl) + "getTask.do?member=" + localAddress.getHost()
      + ":" + localAddress.getPort() + "&cluster=" + encode(groupConfig.getName(), "UTF-8");
  return new URL(urlString);
}

代码示例来源:origin: com.hazelcast/hazelcast-zookeeper

private void prepareServiceInstance() throws Exception {
  Address privateAddress = thisNode.getPrivateAddress();
  serviceInstance = ServiceInstance.<Void>builder()
      .uriSpec(new UriSpec("{scheme}://{address}:{port}"))
      .address(privateAddress.getHost())
      .port(privateAddress.getPort())
      .name(group)
      .build();
}

相关文章