Merge pull request #401 from klsq94/develop

Fixed #399 配置中心未配置线程池启动报错
pull/403/head
Huahua Yin 2 years ago committed by GitHub
commit 52fcda11f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,6 +29,7 @@ import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -42,6 +43,7 @@ import java.util.stream.Collectors;
* @date 2022/2/25 00:24 * @date 2022/2/25 00:24
*/ */
@AllArgsConstructor @AllArgsConstructor
@Slf4j
public class CoreNotifyConfigBuilder implements NotifyConfigBuilder { public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
private final AlarmControlHandler alarmControlHandler; private final AlarmControlHandler alarmControlHandler;
@ -53,15 +55,17 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
Map<String, List<NotifyConfigDTO>> resultMap = Maps.newHashMap(); Map<String, List<NotifyConfigDTO>> resultMap = Maps.newHashMap();
boolean globalAlarm = bootstrapCoreProperties.getAlarm(); boolean globalAlarm = bootstrapCoreProperties.getAlarm();
List<ExecutorProperties> executors = bootstrapCoreProperties.getExecutors(); List<ExecutorProperties> executors = bootstrapCoreProperties.getExecutors();
if (CollectionUtil.isEmpty(executors)) {
log.warn("Failed to build notify, executors configuration is empty.");
return resultMap;
}
List<ExecutorProperties> actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getIsAlarm()).orElse(false)).collect(Collectors.toList()); List<ExecutorProperties> actual = executors.stream().filter(each -> Optional.ofNullable(each.getNotify()).map(notify -> notify.getIsAlarm()).orElse(false)).collect(Collectors.toList());
if (!globalAlarm && CollectionUtil.isEmpty(actual)) { if (!globalAlarm && CollectionUtil.isEmpty(actual)) {
return resultMap; return resultMap;
} }
if (CollectionUtil.isNotEmpty(executors)) {
for (ExecutorProperties executor : executors) { for (ExecutorProperties executor : executors) {
resultMap.putAll(buildSingleNotifyConfig(executor)); resultMap.putAll(buildSingleNotifyConfig(executor));
} }
}
return resultMap; return resultMap;
} }

Loading…
Cancel
Save