《重新定义Spring Cloud实战》——3.1.4 InstanceStatus
3.1.4 InstanceStatus
InstanceStatus用于标识服务实例的状态,它是一个枚举,定义如下:
public enum InstanceStatus {
UP, // Ready to receive traffic
DOWN, // Do not send traffic- healthcheck callback failed
STARTING, // Just about starting- initializations to be done - do not
// send traffic
OUT_OF_SERVICE, // Intentionally shutdown for traffic
UNKNOWN;
public static InstanceStatus toEnum(String s) {
if (s != null) {
try {
return InstanceStatus.valueOf(s.toUpperCase());
} catch (IllegalArgumentException e) {
// ignore and fall through to unknown
logger.debug("illegal argument supplied to InstanceStatus.valueOf: {}, defaulting to {}", s, UNKNOWN);
}
}
return UNKNOWN;
}
}
从定义可以看出,服务实例主要有UP、DOWN、STARTING、OUT_OF_SERVICE、UNKNOWN这几个状态。其中OUT_OF_SERVICE标识停止服务,即停止接收请求,处于这个状态的服务实例将不会被路由到,经常用于升级部署的场景。
- 点赞
- 收藏
- 关注作者
评论(0)