zoukankan      html  css  js  c++  java
  • spring cloud 健康监测配置

    配置说明 注意-转驼峰

    english

    http://cloud.spring.io/spring-cloud-static/Dalston.SR2/#spring-cloud-feign

    china

    https://springcloud.cc/spring-cloud-dalston.html

    eureka server配置server:

    server:
    port: 8761
    eureka:
    client:
    register-with-eureka: false
    fetch-registry: false
    server:
    enable-self-preservation: false
    #每指定时间 刷新服务列表
    eviction-interval-timer-in-ms: 5000
     

    eureka client

    server:
      port: 8080
    spring:
      application:
        name: my-health-provider
    endpoints:
      sensitive: false
    eureka:
      instance:
        #每指定时间向发送 eureka服务器发送续约信息
        leaseRenewalIntervalInSeconds: 5
        #每指定时间没有向服务器发送续约信息,即向eureka服务器发送down机信息
        leaseExpirationDurationInSeconds: 10
        metadata-map:
          company-name: crazyit     
      client:
        #指示将实例信息复制到eureka服务器的开始时间(以秒为单位)
        #配合健康检测器,健康指示器 将实例健康状态通知eureka服务器
        instanceInfoReplicationIntervalSeconds: 10
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/

    健康指示器

    @Component
    public class MyHealthIndicator implements HealthIndicator {
    
        public Health health() {
            if(PoliceController.canVisitDb) {
                return new Health.Builder(Status.UP).build();
            } else {
                return new Health.Builder(Status.DOWN).build();
            }
        }
    
    }

    健康监测器

    @Component
    public class MyHealthCheckHandler implements HealthCheckHandler {
    
        @Autowired
        private MyHealthIndicator halthIndicator;
        
        public InstanceStatus getStatus(InstanceStatus currentStatus) {
            Status status = halthIndicator.health().getStatus();
            if(status.equals(Status.UP)) {
                return InstanceStatus.UP;
            } else {
                return InstanceStatus.DOWN;
            }
        }
    
    }
  • 相关阅读:
    (void) (&_x == &_y)的作用
    GNU C 与 ANSI C(下)
    GNU C 与 ANSI C(上)
    “多个单核CPU”与“单个多核CPU”哪种方式性能较强?
    ARM 处理器寻址方式之间接寻址的几种表达
    Video for Linux Two API Specification
    UVC 驱动调用过程与驱动框架的简单分析
    线程安全
    合法的立即数的判断
    Redis的Java客户端Jedis
  • 原文地址:https://www.cnblogs.com/zfzf1/p/8537424.html
Copyright © 2011-2022 走看看