在ZK的DP/SERVER节点下
CuratorRegistry # registerPersistentNode
void registerPersistentNode(String serviceName, String group, String serviceAddress, int weight) throws RegistryException { String weightPath = Utils.getWeightPath(serviceAddress); String servicePath = Utils.getServicePath(serviceName, group); try { if (client.exists(servicePath, false)) { Stat stat = new Stat(); String addressValue = client.getWithNodeExistsEx(servicePath, stat); String[] addressArray = addressValue.split(","); List<String> addressList = new ArrayList<String>(); for (String addr : addressArray) { addr = addr.trim(); if (addr.length() > 0 && !addressList.contains(addr)) { addressList.add(addr.trim()); } } if (!addressList.contains(serviceAddress)) { addressList.add(serviceAddress); Collections.sort(addressList); client.set(servicePath, StringUtils.join(addressList.iterator(), ","), stat.getVersion());//如果是多个多个ip:port用逗号隔开 } } else { client.create(servicePath, serviceAddress);//如果只有一个服务提供者就是一个字符串 } ......