@Test public void re() throws InterruptedException { Provider provider = new Provider(); provider.setHost("227.2.22.100"); provider.setPort(43276); provider.setServiceName("top.huzhurong.fuck.UserService"); provider.setVersion("0.0.1"); provider.setWeight(11); provider.setSerialization("jdk"); Thread.sleep(5000); register.registerService(Collections.singletonList(provider)); Thread.sleep(100000000000L); }
@Override public void registerService(List<Provider> providerList) { assert zkClient != null; providerList.parallelStream().forEach(provider -> { String host = provider.getHost(); Integer port = provider.getPort(); String serviceName = provider.getServiceName(); String version = provider.getVersion(); Integer weight = provider.getWeight(); String serverPath = root_path + "/" + serviceName + root_provider; if (!zkClient.exists(serverPath)) { zkClient.createPersistent(serverPath, true); } String finalInfo = host + split + port + split + serviceName + split + version + split + weight + split + provider.getSerialization(); String path = serverPath + "/" + finalInfo; if (!zkClient.exists(path)) { log.info("注册服务:{}到ZooKeeper", serverPath); zkClient.createEphemeral(path); } else { log.warn("服务:{}已被注册", serverPath); } }); }
ZkRegister implements IRegister { @Override public void registerService(List<Provider> providerList) { assert zkClient != null; providerList.parallelStream().forEach(provider -> { String host = provider.getHost(); Integer port = provider.getPort(); String serviceName = provider.getServiceName(); String version = provider.getVersion(); Integer weight = provider.getWeight(); String serverPath = root_path + "/" + serviceName + root_provider; if (!zkClient.exists(serverPath)) { zkClient.createPersistent(serverPath, true); } String finalInfo = host + split + port + split + serviceName + split + version + split + weight + split + provider.getSerialization(); String path = serverPath + "/" + finalInfo; if (!zkClient.exists(path)) { log.info("注册服务:{}到ZooKeeper", serverPath); zkClient.createEphemeral(path); } else { log.warn("服务:{}已被注册", serverPath); } }); } }
ZkRegister implements IRegister { @Override public void registerService(List<Provider> providerList) { assert zkClient != null; providerList.parallelStream().forEach(provider -> { String host = provider.getHost(); Integer port = provider.getPort(); String serviceName = provider.getServiceName(); String version = provider.getVersion(); Integer weight = provider.getWeight(); String serverPath = root_path + "/" + serviceName + root_provider; if (!zkClient.exists(serverPath)) { zkClient.createPersistent(serverPath, true); } String finalInfo = host + split + port + split + serviceName + split + version + split + weight + split + provider.getSerialization(); String path = serverPath + "/" + finalInfo; if (!zkClient.exists(path)) { log.info("注册服务:{}到ZooKeeper", serverPath); zkClient.createEphemeral(path); } else { log.warn("服务:{}已被注册", serverPath); } }); } ZkRegister(String host);  ZkRegister(String host, Integer sessionOut, Integer connectionOut); }
ZkRegister implements IRegister { @Override public void registerService(List<Provider> providerList) { assert zkClient != null; providerList.parallelStream().forEach(provider -> { String host = provider.getHost(); Integer port = provider.getPort(); String serviceName = provider.getServiceName(); String version = provider.getVersion(); Integer weight = provider.getWeight(); String serverPath = root_path + "/" + serviceName + root_provider; if (!zkClient.exists(serverPath)) { zkClient.createPersistent(serverPath, true); } String finalInfo = host + split + port + split + serviceName + split + version + split + weight + split + provider.getSerialization(); String path = serverPath + "/" + finalInfo; if (!zkClient.exists(path)) { log.info("注册服务:{}到ZooKeeper", serverPath); zkClient.createEphemeral(path); } else { log.warn("服务:{}已被注册", serverPath); } }); } ZkRegister(String host);  ZkRegister(String host, Integer sessionOut, Integer connectionOut); @Override void registerService(List<Provider> providerList); @Override List<Provider> discover(String serviceName, String version); @Override void registerConsumer(Consumer consumer); @Override void subscribe(String service); }
ZkRegister implements IRegister { @Override public void registerService(List<Provider> providerList) { assert zkClient != null; providerList.parallelStream().forEach(provider -> { String host = provider.getHost(); Integer port = provider.getPort(); String serviceName = provider.getServiceName(); String version = provider.getVersion(); Integer weight = provider.getWeight(); String serverPath = root_path + "/" + serviceName + root_provider; if (!zkClient.exists(serverPath)) { zkClient.createPersistent(serverPath, true); } String finalInfo = host + split + port + split + serviceName + split + version + split + weight + split + provider.getSerialization(); String path = serverPath + "/" + finalInfo; if (!zkClient.exists(path)) { log.info("注册服务:{}到ZooKeeper", serverPath); zkClient.createEphemeral(path); } else { log.warn("服务:{}已被注册", serverPath); } }); } ZkRegister(String host);  ZkRegister(String host, Integer sessionOut, Integer connectionOut); @Override void registerService(List<Provider> providerList); @Override List<Provider> discover(String serviceName, String version); @Override void registerConsumer(Consumer consumer); @Override void subscribe(String service);  }