Search in sources :

Example 1 with NacosServiceMetaData

use of com.alibaba.nacos.spring.metadata.NacosServiceMetaData in project nacos-spring-boot-project by nacos-group.

the class NacosConfigHealthIndicator method doHealthCheck.

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    builder.up();
    NacosServiceFactory nacosServiceFactory = CacheableEventPublishingNacosServiceFactory.getSingleton();
    for (ConfigService configService : nacosServiceFactory.getConfigServices()) {
        if (configService instanceof NacosServiceMetaData) {
            NacosServiceMetaData nacosServiceMetaData = (NacosServiceMetaData) configService;
            Properties properties = nacosServiceMetaData.getProperties();
            builder.withDetail(JacksonUtils.toJson(PropertiesUtils.extractSafeProperties(properties)), configService.getServerStatus());
        }
        if (!configService.getServerStatus().toLowerCase().equals(UP_STATUS)) {
            builder.down();
        }
    }
}
Also used : ConfigService(com.alibaba.nacos.api.config.ConfigService) NacosServiceMetaData(com.alibaba.nacos.spring.metadata.NacosServiceMetaData) CacheableEventPublishingNacosServiceFactory(com.alibaba.nacos.spring.factory.CacheableEventPublishingNacosServiceFactory) NacosServiceFactory(com.alibaba.nacos.spring.factory.NacosServiceFactory) Properties(java.util.Properties)

Example 2 with NacosServiceMetaData

use of com.alibaba.nacos.spring.metadata.NacosServiceMetaData in project nacos-spring-boot-project by nacos-group.

the class NacosDiscoveryHealthIndicator method doHealthCheck.

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    builder.up();
    NacosServiceFactory nacosServiceFactory = CacheableEventPublishingNacosServiceFactory.getSingleton();
    for (NamingService namingService : nacosServiceFactory.getNamingServices()) {
        if (namingService instanceof NacosServiceMetaData) {
            NacosServiceMetaData nacosServiceMetaData = (NacosServiceMetaData) namingService;
            Properties properties = nacosServiceMetaData.getProperties();
            builder.withDetail(JacksonUtils.toJson(PropertiesUtils.extractSafeProperties(properties)), namingService.getServerStatus());
        }
        if (!namingService.getServerStatus().equalsIgnoreCase(UP_STATUS)) {
            builder.down();
        }
    }
}
Also used : NacosServiceMetaData(com.alibaba.nacos.spring.metadata.NacosServiceMetaData) NamingService(com.alibaba.nacos.api.naming.NamingService) CacheableEventPublishingNacosServiceFactory(com.alibaba.nacos.spring.factory.CacheableEventPublishingNacosServiceFactory) NacosServiceFactory(com.alibaba.nacos.spring.factory.NacosServiceFactory) Properties(java.util.Properties)

Aggregations

CacheableEventPublishingNacosServiceFactory (com.alibaba.nacos.spring.factory.CacheableEventPublishingNacosServiceFactory)2 NacosServiceFactory (com.alibaba.nacos.spring.factory.NacosServiceFactory)2 NacosServiceMetaData (com.alibaba.nacos.spring.metadata.NacosServiceMetaData)2 Properties (java.util.Properties)2 ConfigService (com.alibaba.nacos.api.config.ConfigService)1 NamingService (com.alibaba.nacos.api.naming.NamingService)1