ConsulCoordinator implements ClusterRegister, ClusterNodesQuery { @Override public void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException { if (needUsingInternalAddr()) { remoteInstance = new RemoteInstance(new Address(config.getInternalComHost(), config.getInternalComPort(), true)); } AgentClient agentClient = client.agentClient(); this.selfAddress = remoteInstance.getAddress(); Registration registration = ImmutableRegistration.builder() .id(remoteInstance.getAddress().toString()) .name(serviceName) .address(remoteInstance.getAddress().getHost()) .port(remoteInstance.getAddress().getPort()) .check(Registration.RegCheck.grpc(remoteInstance.getAddress() .getHost() + ":" + remoteInstance .getAddress() .getPort(), 5)) .build(); agentClient.register(registration); } ConsulCoordinator(ClusterModuleConsulConfig config, Consul client); @Override List<RemoteInstance> queryRemoteNodes(); @Override void registerRemote(RemoteInstance remoteInstance);  }
@Test public void registerRemote() { registerRemote(remoteAddress); }
@Test public void registerSelfRemote() { registerRemote(selfRemoteAddress); }
@Test public void registerRemoteUsingInternal() { consulConfig.setInternalComHost(internalAddress.getHost()); consulConfig.setInternalComPort(internalAddress.getPort()); registerRemote(internalAddress); }