@Test public void testFromJsonByNoJson() { instance = Instance.fromJson("2.2.2.2:8888_2_TEST1"); assertEquals("2.2.2.2", instance.getIp()); assertEquals(8888, instance.getPort()); assertEquals(2, instance.getWeight(), 0.001); assertEquals("TEST1", instance.getClusterName()); }
public static Instance fromJson(String json) { Instance ip; try { ip = JacksonUtils.toObj(json, Instance.class); } catch (Exception e) { ip = fromString(json); } if (ip == null) { throw new IllegalArgumentException("malformed ip config: " + json); } if (ip.getWeight() > MAX_WEIGHT_VALUE) { ip.setWeight(MAX_WEIGHT_VALUE); } if (ip.getWeight() < MIN_POSITIVE_WEIGHT_VALUE && ip.getWeight() > MIN_WEIGHT_VALUE) { ip.setWeight(MIN_POSITIVE_WEIGHT_VALUE); } else if (ip.getWeight() < MIN_WEIGHT_VALUE) { ip.setWeight(0.0D); } try { ip.validate(); } catch (NacosException e) { throw new IllegalArgumentException("malformed ip config: " + json); } return ip; }
Instance extends com.alibaba.nacos.api.naming.pojo.Instance implements Comparable { public static Instance fromJson(String json) { Instance ip; try { ip = JacksonUtils.toObj(json, Instance.class); } catch (Exception e) { ip = fromString(json); } if (ip == null) { throw new IllegalArgumentException("malformed ip config: " + json); } if (ip.getWeight() > MAX_WEIGHT_VALUE) { ip.setWeight(MAX_WEIGHT_VALUE); } if (ip.getWeight() < MIN_POSITIVE_WEIGHT_VALUE && ip.getWeight() > MIN_WEIGHT_VALUE) { ip.setWeight(MIN_POSITIVE_WEIGHT_VALUE); } else if (ip.getWeight() < MIN_WEIGHT_VALUE) { ip.setWeight(0.0D); } try { ip.validate(); } catch (NacosException e) { throw new IllegalArgumentException("malformed ip config: " + json); } return ip; } }
Instance extends com.alibaba.nacos.api.naming.pojo.Instance implements Comparable { public static Instance fromJson(String json) { Instance ip; try { ip = JacksonUtils.toObj(json, Instance.class); } catch (Exception e) { ip = fromString(json); } if (ip == null) { throw new IllegalArgumentException("malformed ip config: " + json); } if (ip.getWeight() > MAX_WEIGHT_VALUE) { ip.setWeight(MAX_WEIGHT_VALUE); } if (ip.getWeight() < MIN_POSITIVE_WEIGHT_VALUE && ip.getWeight() > MIN_WEIGHT_VALUE) { ip.setWeight(MIN_POSITIVE_WEIGHT_VALUE); } else if (ip.getWeight() < MIN_WEIGHT_VALUE) { ip.setWeight(0.0D); } try { ip.validate(); } catch (NacosException e) { throw new IllegalArgumentException("malformed ip config: " + json); } return ip; } Instance();  Instance(String ip, int port);  Instance(String ip, int port, String clusterName);  Instance(String ip, int port, String clusterName, String tenant, String app); }
Instance extends com.alibaba.nacos.api.naming.pojo.Instance implements Comparable { public static Instance fromJson(String json) { Instance ip; try { ip = JacksonUtils.toObj(json, Instance.class); } catch (Exception e) { ip = fromString(json); } if (ip == null) { throw new IllegalArgumentException("malformed ip config: " + json); } if (ip.getWeight() > MAX_WEIGHT_VALUE) { ip.setWeight(MAX_WEIGHT_VALUE); } if (ip.getWeight() < MIN_POSITIVE_WEIGHT_VALUE && ip.getWeight() > MIN_WEIGHT_VALUE) { ip.setWeight(MIN_POSITIVE_WEIGHT_VALUE); } else if (ip.getWeight() < MIN_WEIGHT_VALUE) { ip.setWeight(0.0D); } try { ip.validate(); } catch (NacosException e) { throw new IllegalArgumentException("malformed ip config: " + json); } return ip; } Instance();  Instance(String ip, int port);  Instance(String ip, int port, String clusterName);  Instance(String ip, int port, String clusterName, String tenant, String app); boolean isMockValid(); void setMockValid(boolean mockValid); long getLastBeat(); void setLastBeat(long lastBeat); static Instance fromString(String config); String toIpAddr(); @Override String toString(); String toJson(); static Instance fromJson(String json); @Override boolean equals(Object obj); @JsonIgnore String getDatumKey(); @JsonIgnore String getDefaultKey(); @Override int hashCode(); void setBeingChecked(boolean isBeingChecked); boolean markChecking(); @JsonIgnore long getCheckRt(); @JsonIgnore AtomicInteger getOkCount(); @JsonIgnore AtomicInteger getFailCount(); @JsonIgnore void setCheckRt(long checkRt); boolean isMarked(); void setMarked(boolean marked); String getApp(); void setApp(String app); String getTenant(); void setTenant(String tenant); String generateInstanceId(); String generateInstanceId(Set<String> currentInstanceIds); void validate(); @Override int compareTo(Object o); }
Instance extends com.alibaba.nacos.api.naming.pojo.Instance implements Comparable { public static Instance fromJson(String json) { Instance ip; try { ip = JacksonUtils.toObj(json, Instance.class); } catch (Exception e) { ip = fromString(json); } if (ip == null) { throw new IllegalArgumentException("malformed ip config: " + json); } if (ip.getWeight() > MAX_WEIGHT_VALUE) { ip.setWeight(MAX_WEIGHT_VALUE); } if (ip.getWeight() < MIN_POSITIVE_WEIGHT_VALUE && ip.getWeight() > MIN_WEIGHT_VALUE) { ip.setWeight(MIN_POSITIVE_WEIGHT_VALUE); } else if (ip.getWeight() < MIN_WEIGHT_VALUE) { ip.setWeight(0.0D); } try { ip.validate(); } catch (NacosException e) { throw new IllegalArgumentException("malformed ip config: " + json); } return ip; } Instance();  Instance(String ip, int port);  Instance(String ip, int port, String clusterName);  Instance(String ip, int port, String clusterName, String tenant, String app); boolean isMockValid(); void setMockValid(boolean mockValid); long getLastBeat(); void setLastBeat(long lastBeat); static Instance fromString(String config); String toIpAddr(); @Override String toString(); String toJson(); static Instance fromJson(String json); @Override boolean equals(Object obj); @JsonIgnore String getDatumKey(); @JsonIgnore String getDefaultKey(); @Override int hashCode(); void setBeingChecked(boolean isBeingChecked); boolean markChecking(); @JsonIgnore long getCheckRt(); @JsonIgnore AtomicInteger getOkCount(); @JsonIgnore AtomicInteger getFailCount(); @JsonIgnore void setCheckRt(long checkRt); boolean isMarked(); void setMarked(boolean marked); String getApp(); void setApp(String app); String getTenant(); void setTenant(String tenant); String generateInstanceId(); String generateInstanceId(Set<String> currentInstanceIds); void validate(); @Override int compareTo(Object o);  }