use of com.alibaba.nacos.api.naming.pojo.healthcheck.HealthCheckType in project nacos by alibaba.
the class HealthCheckExtendProvider method loadExtend.
private void loadExtend() {
Iterator<HealthCheckProcessor> processorIt = processors.iterator();
Iterator<AbstractHealthChecker> healthCheckerIt = checkers.iterator();
Set<String> origin = new HashSet<>();
for (HealthCheckType type : HealthCheckType.values()) {
origin.add(type.name());
}
Set<String> processorType = new HashSet<>(origin);
Set<String> healthCheckerType = new HashSet<>(origin);
while (processorIt.hasNext()) {
HealthCheckProcessor processor = processorIt.next();
String type = processor.getType();
if (processorType.contains(type)) {
throw new RuntimeException("More than one processor of the same type was found : [type=\"" + type + "\"]");
}
processorType.add(type);
registry.registerSingleton(lowerFirstChar(processor.getClass().getSimpleName()), processor);
}
while (healthCheckerIt.hasNext()) {
AbstractHealthChecker checker = healthCheckerIt.next();
String type = checker.getType();
if (healthCheckerType.contains(type)) {
throw new RuntimeException("More than one healthChecker of the same type was found : [type=\"" + type + "\"]");
}
healthCheckerType.add(type);
HealthCheckType.registerHealthChecker(checker.getType(), checker.getClass());
}
if (!processorType.equals(healthCheckerType)) {
throw new RuntimeException("An unmatched processor and healthChecker are detected in the extension package.");
}
if (processorType.size() > origin.size()) {
processorType.removeAll(origin);
LOGGER.debug("init health plugin : types=" + processorType);
}
}
Aggregations