ZookeeperCoordinator implements ClusterRegister, ClusterNodesQuery { @Override public synchronized void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException { try { if (needUsingInternalAddr()) { remoteInstance = new RemoteInstance(new Address(config.getInternalComHost(), config.getInternalComPort(), true)); } ServiceInstance<RemoteInstance> thisInstance = ServiceInstance.<RemoteInstance>builder().name(REMOTE_NAME_PATH) .id(UUID.randomUUID() .toString()) .address(remoteInstance .getAddress() .getHost()) .port(remoteInstance .getAddress() .getPort()) .payload(remoteInstance) .build(); serviceDiscovery.registerService(thisInstance); this.selfAddress = remoteInstance.getAddress(); } catch (Exception e) { throw new ServiceRegisterException(e.getMessage()); } } ZookeeperCoordinator(ClusterModuleZookeeperConfig config,
                         ServiceDiscovery<RemoteInstance> serviceDiscovery); @Override synchronized void registerRemote(RemoteInstance remoteInstance); @Override List<RemoteInstance> queryRemoteNodes();  }
@Test public void registerRemote() throws Exception { config.setInternalComHost(selfAddress.getHost()); config.setInternalComPort(selfAddress.getPort()); RemoteInstance instance = new RemoteInstance(address); coordinator.registerRemote(instance); validateServiceInstance(selfAddress, new RemoteInstance(selfAddress)); }
@Test public void registerRemoteNoNeedInternal() throws Exception { RemoteInstance instance = new RemoteInstance(address); coordinator.registerRemote(instance); validateServiceInstance(address, instance); }