com.hazelcast.nio.Address类的使用及代码示例

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

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

Address介绍

[英]Represents an address of a member in the cluster.
[中]表示群集中成员的地址。

代码示例

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

private Member newMember(String name) {
  Member member = mock(Member.class, Mockito.RETURNS_MOCKS);
  when(member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME.getKey())).thenReturn(name);
  when(member.getAddress()).thenReturn(new Address(AN_ADDRESS, 6789));
  return member;
 }
}

代码示例来源: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: hazelcast/hazelcast-jet

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

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

@Override
protected void readInternal(final ObjectDataInput in) throws IOException {
  masterAddress = new Address();
  masterAddress.readData(in);
}

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

private Map<Address, Address> parseResponse(InputStream is) throws IOException {
  JsonValue jsonValue = Json.parse(readInputStream(is));
  List<JsonValue> response = jsonValue.asArray().values();
  Map<Address, Address> privateToPublicAddresses = new HashMap<Address, Address>();
  for (JsonValue value : response) {
    String privateAddress = value.asObject().get(PRIVATE_ADDRESS_PROPERTY).asString();
    String publicAddress = value.asObject().get(PUBLIC_ADDRESS_PROPERTY).asString();
    Address publicAddr = createAddress(publicAddress);
    privateToPublicAddresses.put(new Address(privateAddress, publicAddr.getPort()), publicAddr);
  }
  return privateToPublicAddresses;
}

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

private static int[] arrangeLocalPartitions(Address[] partitionOwners, Address thisAddress) {
  return IntStream.range(0, partitionOwners.length)
      .filter(partitionId -> thisAddress.equals(partitionOwners[partitionId]))
      .toArray();
}

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

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

代码示例来源:origin: com.hazelcast.simulator/tests-hz38

public MockIOService(Address thisAddress, LoggingService loggingService) throws Exception {
  this.thisAddress = thisAddress;
  this.loggingService = loggingService;
  serverSocketChannel = ServerSocketChannel.open();
  ServerSocket serverSocket = serverSocketChannel.socket();
  serverSocket.setReuseAddress(true);
  serverSocket.setSoTimeout(1000);
  serverSocket.bind(new InetSocketAddress("0.0.0.0", thisAddress.getPort()));
  this.serializationService = new DefaultSerializationServiceBuilder().build();
}

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

protected AbstractMember(Address address, MemberVersion version, String uuid, Map<String, Object> attributes,
             boolean liteMember) {
  assert address != null : "Address is required!";
  this.address = address;
  this.version = version;
  this.uuid = uuid != null ? uuid : "<" + address.toString() + ">";
  if (attributes != null) {
    this.attributes.putAll(attributes);
  }
  this.liteMember = liteMember;
}

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

public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
  return new InetSocketAddress(getInetAddress(), port);
}

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

private MemberImpl createMember(MemberInfo memberInfo, Map<String, Object> attributes) {
  Address address = memberInfo.getAddress();
  Address thisAddress = node.getThisAddress();
  String ipV6ScopeId = thisAddress.getScopeId();
  address.setScopeId(ipV6ScopeId);
  boolean localMember = thisAddress.equals(address);
  return new MemberImpl(address, memberInfo.getVersion(), localMember, memberInfo.getUuid(), attributes,
      memberInfo.isLiteMember(), memberInfo.getMemberListJoinVersion(), node.hazelcastInstance);
}

代码示例来源: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

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
  newTargetAddress = new Address();
  newTargetAddress.readData(in);
}

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

private Map<Address, Address> parseResponse(InputStream is) throws IOException {
  JsonValue jsonValue = Json.parse(readInputStream(is));
  List<JsonValue> response = jsonValue.asArray().values();
  Map<Address, Address> privateToPublicAddresses = new HashMap<Address, Address>();
  for (JsonValue value : response) {
    String privateAddress = value.asObject().get(PRIVATE_ADDRESS_PROPERTY).asString();
    String publicAddress = value.asObject().get(PUBLIC_ADDRESS_PROPERTY).asString();
    Address publicAddr = createAddress(publicAddress);
    privateToPublicAddresses.put(new Address(privateAddress, publicAddr.getPort()), publicAddr);
  }
  return privateToPublicAddresses;
}

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

@Override
public boolean isOwnerOrBackup(Address address) {
  if (address == null) {
    return false;
  }
  for (int i = 0; i < MAX_REPLICA_COUNT; i++) {
    if (address.equals(getAddress(replicas[i]))) {
      return true;
    }
  }
  return false;
}

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

private static void printMemberPort(HazelcastInstance hz) throws Exception {
    String printPort = System.getProperty("print.port");
    if (printPort != null) {
      PrintWriter printWriter = null;
      try {
        printWriter = new PrintWriter("ports" + File.separator + printPort, "UTF-8");
        printWriter.println(hz.getCluster().getLocalMember().getAddress().getPort());
      } finally {
        closeResource(printWriter);
      }
    }
  }
}

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

protected AbstractMember(Address address, MemberVersion version, String uuid, Map<String, Object> attributes,
             boolean liteMember) {
  assert address != null : "Address is required!";
  this.address = address;
  this.version = version;
  this.uuid = uuid != null ? uuid : "<" + address.toString() + ">";
  if (attributes != null) {
    this.attributes.putAll(attributes);
  }
  this.liteMember = liteMember;
}

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

public InetSocketAddress getInetSocketAddress() throws UnknownHostException {
  return new InetSocketAddress(getInetAddress(), port);
}

代码示例来源: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 void readData(ObjectDataInput in)
    throws IOException {
  super.readData(in);
  address = new Address();
  address.readData(in);
}

相关文章