#502 Add NONE healthChecker

This commit is contained in:
nkorange 2019-03-15 15:08:01 +08:00
parent 7bf60c18e7
commit 592f2b4301
3 changed files with 22 additions and 4 deletions

View File

@ -47,6 +47,20 @@ public abstract class AbstractHealthChecker implements Cloneable {
*/
public abstract AbstractHealthChecker clone() throws CloneNotSupportedException;
public static class None extends AbstractHealthChecker {
public static final String TYPE = "NONE";
public None() {
this.setType(TYPE);
}
@Override
public AbstractHealthChecker clone() throws CloneNotSupportedException {
return new None();
}
}
public static class Http extends AbstractHealthChecker {
public static final String TYPE = "HTTP";

View File

@ -87,6 +87,9 @@ public class ClusterController {
case AbstractHealthChecker.Mysql.TYPE:
abstractHealthChecker = JSON.parseObject(healthChecker, AbstractHealthChecker.Mysql.class);
break;
case AbstractHealthChecker.None.TYPE:
abstractHealthChecker = JSON.parseObject(healthChecker, AbstractHealthChecker.None.class);
break;
default:
throw new NacosException(NacosException.INVALID_PARAM, "unknown health check type:" + healthChecker);
}

View File

@ -133,13 +133,13 @@ public class Instance extends com.alibaba.nacos.api.naming.pojo.Instance impleme
if (ipAddressAttributes.length > minimumLength) {
// determine 'valid':
if (Boolean.TRUE.toString().equals(ipAddressAttributes[minimumLength]) ||
Boolean.FALSE.toString().equals(ipAddressAttributes[minimumLength])) {
Boolean.FALSE.toString().equals(ipAddressAttributes[minimumLength])) {
instance.setHealthy(Boolean.parseBoolean(ipAddressAttributes[minimumLength]));
}
// determine 'cluster':
if (!Boolean.TRUE.toString().equals(ipAddressAttributes[ipAddressAttributes.length - 1]) &&
!Boolean.FALSE.toString().equals(ipAddressAttributes[ipAddressAttributes.length - 1])) {
!Boolean.FALSE.toString().equals(ipAddressAttributes[ipAddressAttributes.length - 1])) {
instance.setClusterName(ipAddressAttributes[ipAddressAttributes.length - 1]);
}
}
@ -149,7 +149,7 @@ public class Instance extends com.alibaba.nacos.api.naming.pojo.Instance impleme
if (ipAddressAttributes.length > minimumLength) {
// determine 'marked':
if (Boolean.TRUE.toString().equals(ipAddressAttributes[minimumLength]) ||
Boolean.FALSE.toString().equals(ipAddressAttributes[minimumLength])) {
Boolean.FALSE.toString().equals(ipAddressAttributes[minimumLength])) {
instance.setMarked(Boolean.parseBoolean(ipAddressAttributes[minimumLength]));
}
}
@ -212,7 +212,8 @@ public class Instance extends com.alibaba.nacos.api.naming.pojo.Instance impleme
Instance other = (Instance) obj;
// 0 means wild
return getIp().equals(other.getIp()) && (getPort() == other.getPort() || getPort() == 0);
return getIp().equals(other.getIp()) && (getPort() == other.getPort() || getPort() == 0)
&& this.isEphemeral() == other.isEphemeral();
}
@JSONField(serialize = false)