use of com.alibaba.nacos.spring.factory.NacosServiceFactory 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();
}
}
}
use of com.alibaba.nacos.spring.factory.NacosServiceFactory in project nacos-spring-boot-project by nacos-group.
the class NacosDiscoveryEndpoint method invoke.
@ReadOperation
public Map<String, Object> invoke() {
Map<String, Object> result = new HashMap<>(8);
result.put("nacosDiscoveryGlobalProperties", PropertiesUtils.extractSafeProperties(applicationContext.getBean(DISCOVERY_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, Properties.class)));
NacosServiceFactory nacosServiceFactory = CacheableEventPublishingNacosServiceFactory.getSingleton();
ArrayNode array = JacksonUtils.createEmptyArrayNode();
for (NamingService namingService : nacosServiceFactory.getNamingServices()) {
ObjectNode jsonObject = JacksonUtils.createEmptyJsonNode();
try {
jsonObject.putPOJO("servicesOfServer", namingService.getServicesOfServer(0, PAGE_SIZE));
jsonObject.putPOJO("subscribeServices", namingService.getSubscribeServices());
array.add(jsonObject);
} catch (Exception e) {
jsonObject.put("serverStatus", namingService.getServerStatus() + ": " + NacosUtils.SEPARATOR + e.getMessage());
}
}
result.put("namingServersStatus", array);
return result;
}
use of com.alibaba.nacos.spring.factory.NacosServiceFactory 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();
}
}
}
Aggregations