@Test public void testGetServiceString() { String actual = service.getServiceString(); assertTrue(actual.contains("\"invalidIPCount\":0")); assertTrue(actual.contains("\"name\":\"test-service\"")); assertTrue(actual.contains("\"ipCount\":0")); assertTrue(actual.contains("\"owners\":[]")); assertTrue(actual.contains("\"protectThreshold\":0.0")); assertTrue(actual.contains("\"clusters\":[]")); }
@JsonIgnore public String getServiceString() { Map<Object, Object> serviceObject = new HashMap<Object, Object>(10); Service service = this; serviceObject.put("name", service.getName()); List<Instance> ips = service.allIPs(); int invalidIpCount = 0; int ipCount = 0; for (Instance ip : ips) { if (!ip.isHealthy()) { invalidIpCount++; } ipCount++; } serviceObject.put("ipCount", ipCount); serviceObject.put("invalidIPCount", invalidIpCount); serviceObject.put("owners", service.getOwners()); serviceObject.put("token", service.getToken()); serviceObject.put("protectThreshold", service.getProtectThreshold()); List<Object> clustersList = new ArrayList<Object>(); for (Map.Entry<String, Cluster> entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map<Object, Object> clusters = new HashMap<Object, Object>(10); clusters.put("name", cluster.getName()); clusters.put("healthChecker", cluster.getHealthChecker()); clusters.put("defCkport", cluster.getDefCkport()); clusters.put("defIPPort", cluster.getDefIPPort()); clusters.put("useIPPort4Check", cluster.isUseIPPort4Check()); clusters.put("sitegroup", cluster.getSitegroup()); clustersList.add(clusters); } serviceObject.put("clusters", clustersList); try { return JacksonUtils.toJson(serviceObject); } catch (Exception e) { throw new RuntimeException("Service toJson failed", e); } }
Service extends com.alibaba.nacos.api.naming.pojo.Service implements Record, RecordListener<Instances> { @JsonIgnore public String getServiceString() { Map<Object, Object> serviceObject = new HashMap<Object, Object>(10); Service service = this; serviceObject.put("name", service.getName()); List<Instance> ips = service.allIPs(); int invalidIpCount = 0; int ipCount = 0; for (Instance ip : ips) { if (!ip.isHealthy()) { invalidIpCount++; } ipCount++; } serviceObject.put("ipCount", ipCount); serviceObject.put("invalidIPCount", invalidIpCount); serviceObject.put("owners", service.getOwners()); serviceObject.put("token", service.getToken()); serviceObject.put("protectThreshold", service.getProtectThreshold()); List<Object> clustersList = new ArrayList<Object>(); for (Map.Entry<String, Cluster> entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map<Object, Object> clusters = new HashMap<Object, Object>(10); clusters.put("name", cluster.getName()); clusters.put("healthChecker", cluster.getHealthChecker()); clusters.put("defCkport", cluster.getDefCkport()); clusters.put("defIPPort", cluster.getDefIPPort()); clusters.put("useIPPort4Check", cluster.isUseIPPort4Check()); clusters.put("sitegroup", cluster.getSitegroup()); clustersList.add(clusters); } serviceObject.put("clusters", clustersList); try { return JacksonUtils.toJson(serviceObject); } catch (Exception e) { throw new RuntimeException("Service toJson failed", e); } } }
Service extends com.alibaba.nacos.api.naming.pojo.Service implements Record, RecordListener<Instances> { @JsonIgnore public String getServiceString() { Map<Object, Object> serviceObject = new HashMap<Object, Object>(10); Service service = this; serviceObject.put("name", service.getName()); List<Instance> ips = service.allIPs(); int invalidIpCount = 0; int ipCount = 0; for (Instance ip : ips) { if (!ip.isHealthy()) { invalidIpCount++; } ipCount++; } serviceObject.put("ipCount", ipCount); serviceObject.put("invalidIPCount", invalidIpCount); serviceObject.put("owners", service.getOwners()); serviceObject.put("token", service.getToken()); serviceObject.put("protectThreshold", service.getProtectThreshold()); List<Object> clustersList = new ArrayList<Object>(); for (Map.Entry<String, Cluster> entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map<Object, Object> clusters = new HashMap<Object, Object>(10); clusters.put("name", cluster.getName()); clusters.put("healthChecker", cluster.getHealthChecker()); clusters.put("defCkport", cluster.getDefCkport()); clusters.put("defIPPort", cluster.getDefIPPort()); clusters.put("useIPPort4Check", cluster.isUseIPPort4Check()); clusters.put("sitegroup", cluster.getSitegroup()); clustersList.add(clusters); } serviceObject.put("clusters", clustersList); try { return JacksonUtils.toJson(serviceObject); } catch (Exception e) { throw new RuntimeException("Service toJson failed", e); } } Service();  Service(String name); }
Service extends com.alibaba.nacos.api.naming.pojo.Service implements Record, RecordListener<Instances> { @JsonIgnore public String getServiceString() { Map<Object, Object> serviceObject = new HashMap<Object, Object>(10); Service service = this; serviceObject.put("name", service.getName()); List<Instance> ips = service.allIPs(); int invalidIpCount = 0; int ipCount = 0; for (Instance ip : ips) { if (!ip.isHealthy()) { invalidIpCount++; } ipCount++; } serviceObject.put("ipCount", ipCount); serviceObject.put("invalidIPCount", invalidIpCount); serviceObject.put("owners", service.getOwners()); serviceObject.put("token", service.getToken()); serviceObject.put("protectThreshold", service.getProtectThreshold()); List<Object> clustersList = new ArrayList<Object>(); for (Map.Entry<String, Cluster> entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map<Object, Object> clusters = new HashMap<Object, Object>(10); clusters.put("name", cluster.getName()); clusters.put("healthChecker", cluster.getHealthChecker()); clusters.put("defCkport", cluster.getDefCkport()); clusters.put("defIPPort", cluster.getDefIPPort()); clusters.put("useIPPort4Check", cluster.isUseIPPort4Check()); clusters.put("sitegroup", cluster.getSitegroup()); clustersList.add(clusters); } serviceObject.put("clusters", clustersList); try { return JacksonUtils.toJson(serviceObject); } catch (Exception e) { throw new RuntimeException("Service toJson failed", e); } } Service();  Service(String name); @JsonIgnore PushService getPushService(); long getIpDeleteTimeout(); void setIpDeleteTimeout(long ipDeleteTimeout); void processClientBeat(final RsInfo rsInfo); Boolean getEnabled(); void setEnabled(Boolean enabled); long getLastModifiedMillis(); void setLastModifiedMillis(long lastModifiedMillis); Boolean getResetWeight(); void setResetWeight(Boolean resetWeight); Selector getSelector(); void setSelector(Selector selector); @Override boolean interests(String key); @Override boolean matchUnlistenKey(String key); @Override void onChange(String key, Instances value); @Override void onDelete(String key); int healthyInstanceCount(); boolean triggerFlag(); void updateIPs(Collection<Instance> instances, boolean ephemeral); void init(); void destroy(); boolean isEmpty(); List<Instance> allIPs(); List<Instance> allIPs(boolean ephemeral); List<Instance> allIPs(List<String> clusters); List<Instance> srvIPs(List<String> clusters); String toJson(); @JsonIgnore String getServiceString(); String getToken(); void setToken(String token); List<String> getOwners(); void setOwners(List<String> owners); Map<String, Cluster> getClusterMap(); void setClusterMap(Map<String, Cluster> clusterMap); String getNamespaceId(); void setNamespaceId(String namespaceId); void update(Service vDom); @Override String getChecksum(); synchronized void recalculateChecksum(); int getFinalizeCount(); void setFinalizeCount(int finalizeCount); void addCluster(Cluster cluster); void validate(); }
Service extends com.alibaba.nacos.api.naming.pojo.Service implements Record, RecordListener<Instances> { @JsonIgnore public String getServiceString() { Map<Object, Object> serviceObject = new HashMap<Object, Object>(10); Service service = this; serviceObject.put("name", service.getName()); List<Instance> ips = service.allIPs(); int invalidIpCount = 0; int ipCount = 0; for (Instance ip : ips) { if (!ip.isHealthy()) { invalidIpCount++; } ipCount++; } serviceObject.put("ipCount", ipCount); serviceObject.put("invalidIPCount", invalidIpCount); serviceObject.put("owners", service.getOwners()); serviceObject.put("token", service.getToken()); serviceObject.put("protectThreshold", service.getProtectThreshold()); List<Object> clustersList = new ArrayList<Object>(); for (Map.Entry<String, Cluster> entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map<Object, Object> clusters = new HashMap<Object, Object>(10); clusters.put("name", cluster.getName()); clusters.put("healthChecker", cluster.getHealthChecker()); clusters.put("defCkport", cluster.getDefCkport()); clusters.put("defIPPort", cluster.getDefIPPort()); clusters.put("useIPPort4Check", cluster.isUseIPPort4Check()); clusters.put("sitegroup", cluster.getSitegroup()); clustersList.add(clusters); } serviceObject.put("clusters", clustersList); try { return JacksonUtils.toJson(serviceObject); } catch (Exception e) { throw new RuntimeException("Service toJson failed", e); } } Service();  Service(String name); @JsonIgnore PushService getPushService(); long getIpDeleteTimeout(); void setIpDeleteTimeout(long ipDeleteTimeout); void processClientBeat(final RsInfo rsInfo); Boolean getEnabled(); void setEnabled(Boolean enabled); long getLastModifiedMillis(); void setLastModifiedMillis(long lastModifiedMillis); Boolean getResetWeight(); void setResetWeight(Boolean resetWeight); Selector getSelector(); void setSelector(Selector selector); @Override boolean interests(String key); @Override boolean matchUnlistenKey(String key); @Override void onChange(String key, Instances value); @Override void onDelete(String key); int healthyInstanceCount(); boolean triggerFlag(); void updateIPs(Collection<Instance> instances, boolean ephemeral); void init(); void destroy(); boolean isEmpty(); List<Instance> allIPs(); List<Instance> allIPs(boolean ephemeral); List<Instance> allIPs(List<String> clusters); List<Instance> srvIPs(List<String> clusters); String toJson(); @JsonIgnore String getServiceString(); String getToken(); void setToken(String token); List<String> getOwners(); void setOwners(List<String> owners); Map<String, Cluster> getClusterMap(); void setClusterMap(Map<String, Cluster> clusterMap); String getNamespaceId(); void setNamespaceId(String namespaceId); void update(Service vDom); @Override String getChecksum(); synchronized void recalculateChecksum(); int getFinalizeCount(); void setFinalizeCount(int finalizeCount); void addCluster(Cluster cluster); void validate();  }