Change configuration property naming

pull/592/head
chen.ma 2 years ago
parent 30953eae3c
commit 16097e7a26

@ -31,8 +31,8 @@ import java.util.Map;
*/
@Getter
@Setter
@ConfigurationProperties(prefix = BootstrapCoreProperties.PREFIX)
public class BootstrapCoreProperties implements BootstrapPropertiesInterface {
@ConfigurationProperties(prefix = BootstrapConfigProperties.PREFIX)
public class BootstrapConfigProperties implements BootstrapPropertiesInterface {
public static final String PREFIX = "spring.dynamic.thread-pool";

@ -48,19 +48,19 @@ public class ConfigHandlerConfiguration {
@RequiredArgsConstructor
@ConditionalOnClass(ConfigService.class)
@ConditionalOnMissingClass(NACOS_CONFIG_MANAGER_KEY)
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, name = NACOS_DATA_ID_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacos {
public final BootstrapCoreProperties bootstrapCoreProperties;
public final BootstrapConfigProperties bootstrapConfigProperties;
@Bean
public NacosRefresherHandler nacosRefresherHandler() {
return new NacosRefresherHandler(bootstrapCoreProperties);
return new NacosRefresherHandler(bootstrapConfigProperties);
}
}
@ConditionalOnClass(NacosConfigManager.class)
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, name = NACOS_DATA_ID_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacosCloud {
@Bean
@ -70,7 +70,7 @@ public class ConfigHandlerConfiguration {
}
@ConditionalOnClass(com.ctrip.framework.apollo.ConfigService.class)
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, name = APOLLO_NAMESPACE_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = APOLLO_NAMESPACE_KEY)
static class EmbeddedApollo {
@Bean
@ -80,7 +80,7 @@ public class ConfigHandlerConfiguration {
}
@ConditionalOnClass(CuratorFramework.class)
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, name = ZOOKEEPER_CONNECT_STR_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = ZOOKEEPER_CONNECT_STR_KEY)
static class EmbeddedZookeeper {
@Bean

@ -54,16 +54,16 @@ import org.springframework.core.annotation.Order;
@Configuration
@AllArgsConstructor
@ConditionalOnBean(MarkerConfiguration.Marker.class)
@EnableConfigurationProperties(BootstrapCoreProperties.class)
@EnableConfigurationProperties(BootstrapConfigProperties.class)
@ImportAutoConfiguration({UtilAutoConfiguration.class, MessageConfiguration.class})
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
@Import({
ConfigHandlerConfiguration.EmbeddedNacos.class, ConfigHandlerConfiguration.EmbeddedNacosCloud.class,
ConfigHandlerConfiguration.EmbeddedApollo.class, ConfigHandlerConfiguration.EmbeddedZookeeper.class
})
public class DynamicThreadPoolCoreAutoConfiguration {
private final BootstrapCoreProperties bootstrapCoreProperties;
private final BootstrapConfigProperties bootstrapConfigProperties;
@Bean
@ConditionalOnMissingBean
@ -74,7 +74,7 @@ public class DynamicThreadPoolCoreAutoConfiguration {
@Bean
public NotifyConfigBuilder notifyConfigBuilder(AlarmControlHandler alarmControlHandler) {
return new CoreNotifyConfigBuilder(alarmControlHandler, bootstrapCoreProperties);
return new CoreNotifyConfigBuilder(alarmControlHandler, bootstrapConfigProperties);
}
@Bean
@ -84,12 +84,12 @@ public class DynamicThreadPoolCoreAutoConfiguration {
@Bean
public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor(ApplicationContextHolder hippo4JApplicationContextHolder) {
return new DynamicThreadPoolPostProcessor(bootstrapCoreProperties);
return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties);
}
@Bean
public DynamicThreadPoolMonitorExecutor hippo4jDynamicThreadPoolMonitorExecutor() {
return new DynamicThreadPoolMonitorExecutor(bootstrapCoreProperties);
return new DynamicThreadPoolMonitorExecutor(bootstrapConfigProperties);
}
@Bean
@ -117,12 +117,12 @@ public class DynamicThreadPoolCoreAutoConfiguration {
@Bean
public DynamicThreadPoolAdapterRegister threadPoolAdapterRegister() {
return new DynamicThreadPoolAdapterRegister(bootstrapCoreProperties);
return new DynamicThreadPoolAdapterRegister(bootstrapConfigProperties);
}
@Bean
public DynamicThreadPoolBannerHandler threadPoolBannerHandler() {
return new DynamicThreadPoolBannerHandler(bootstrapCoreProperties);
return new DynamicThreadPoolBannerHandler(bootstrapConfigProperties);
}
@Bean

@ -21,7 +21,7 @@ import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.executor.support.ThreadFactoryBuilder;
import cn.hippo4j.common.spi.DynamicThreadPoolServiceLoader;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.monitor.base.DynamicThreadPoolMonitor;
import cn.hippo4j.monitor.base.ThreadPoolMonitor;
import com.google.common.collect.Lists;
@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
@RequiredArgsConstructor
public class DynamicThreadPoolMonitorExecutor implements ApplicationRunner {
private final BootstrapCoreProperties properties;
private final BootstrapConfigProperties properties;
private ScheduledThreadPoolExecutor collectExecutor;

@ -19,7 +19,7 @@ package cn.hippo4j.core.springboot.starter.notify;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.config.NotifyPlatformProperties;
import cn.hippo4j.message.service.AlarmControlHandler;
@ -45,13 +45,13 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
private final AlarmControlHandler alarmControlHandler;
private final BootstrapCoreProperties bootstrapCoreProperties;
private final BootstrapConfigProperties bootstrapConfigProperties;
@Override
public Map<String, List<NotifyConfigDTO>> buildNotify() {
Map<String, List<NotifyConfigDTO>> resultMap = Maps.newHashMap();
boolean globalAlarm = bootstrapCoreProperties.getAlarm();
List<ExecutorProperties> executors = bootstrapCoreProperties.getExecutors();
boolean globalAlarm = bootstrapConfigProperties.getAlarm();
List<ExecutorProperties> executors = bootstrapConfigProperties.getExecutors();
if (CollectionUtil.isEmpty(executors)) {
log.warn("Failed to build notify, executors configuration is empty.");
return resultMap;
@ -79,7 +79,7 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
String threadPoolId = executor.getThreadPoolId();
String alarmBuildKey = threadPoolId + "+ALARM";
List<NotifyConfigDTO> alarmNotifyConfigs = Lists.newArrayList();
List<NotifyPlatformProperties> notifyPlatforms = bootstrapCoreProperties.getNotifyPlatforms();
List<NotifyPlatformProperties> notifyPlatforms = bootstrapConfigProperties.getNotifyPlatforms();
for (NotifyPlatformProperties platformProperties : notifyPlatforms) {
NotifyConfigDTO notifyConfig = new NotifyConfigDTO();
notifyConfig.setPlatform(platformProperties.getPlatform());
@ -89,7 +89,7 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
notifyConfig.setSecretKey(getToken(platformProperties));
int interval = Optional.ofNullable(executor.getNotify())
.map(each -> each.getInterval())
.orElseGet(() -> bootstrapCoreProperties.getAlarmInterval() != null ? bootstrapCoreProperties.getAlarmInterval() : 5);
.orElseGet(() -> bootstrapConfigProperties.getAlarmInterval() != null ? bootstrapConfigProperties.getAlarmInterval() : 5);
notifyConfig.setInterval(interval);
notifyConfig.setReceives(buildReceive(executor, platformProperties));
alarmNotifyConfigs.add(notifyConfig);
@ -123,10 +123,10 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
if (executor.getNotify() != null) {
receive = executor.getNotify().getReceives();
if (StrUtil.isBlank(receive)) {
receive = bootstrapCoreProperties.getReceives();
receive = bootstrapConfigProperties.getReceives();
}
} else {
receive = bootstrapCoreProperties.getReceives();
receive = bootstrapConfigProperties.getReceives();
}
return receive;
}

@ -21,9 +21,9 @@ import cn.hippo4j.common.api.ThreadPoolDynamicRefresh;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.parser.ConfigParserHandler;
import cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDynamicRefreshEvent;
import cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
@ -39,12 +39,12 @@ import java.util.concurrent.ExecutorService;
@RequiredArgsConstructor
public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh, InitializingBean {
protected final BootstrapCoreProperties bootstrapCoreProperties;
protected final BootstrapConfigProperties bootstrapConfigProperties;
protected final ExecutorService dynamicRefreshExecutorService = ThreadPoolBuilder.builder().singlePool("client.dynamic.refresh").build();
public AbstractCoreThreadPoolDynamicRefresh() {
bootstrapCoreProperties = ApplicationContextHolder.getBean(BootstrapCoreProperties.class);
bootstrapConfigProperties = ApplicationContextHolder.getBean(BootstrapConfigProperties.class);
}
@Override
@ -55,12 +55,12 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
@Override
public void dynamicRefresh(String configContent, Map<String, Object> newValueChangeMap) {
try {
Map<Object, Object> configInfo = ConfigParserHandler.getInstance().parseConfig(configContent, bootstrapCoreProperties.getConfigFileType());
Map<Object, Object> configInfo = ConfigParserHandler.getInstance().parseConfig(configContent, bootstrapConfigProperties.getConfigFileType());
if (CollectionUtil.isNotEmpty(newValueChangeMap)) {
Optional.ofNullable(configInfo).ifPresent(each -> each.putAll(newValueChangeMap));
}
BootstrapCoreProperties bindableCoreProperties = BootstrapCorePropertiesBinderAdapt.bootstrapCorePropertiesBinder(configInfo, bootstrapCoreProperties);
ApplicationContextHolder.getInstance().publishEvent(new Hippo4jCoreDynamicRefreshEvent(this, bindableCoreProperties));
BootstrapConfigProperties bindableCoreProperties = BootstrapCorePropertiesBinderAdapt.bootstrapCorePropertiesBinder(configInfo, bootstrapConfigProperties);
ApplicationContextHolder.getInstance().publishEvent(new Hippo4jConfigDynamicRefreshEvent(this, bindableCoreProperties));
} catch (Exception ex) {
log.error("Hippo-4J core dynamic refresh failed.", ex);
}

@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
import java.util.Map;
import static cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties.PREFIX;
import static cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties.PREFIX;
/**
* Apollo refresher handler.
@ -46,10 +46,10 @@ public class ApolloRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh
public void afterPropertiesSet() {
String[] apolloNamespaces = this.namespace.split(",");
this.namespace = apolloNamespaces[0];
Config config = ConfigService.getConfig(String.format("%s.%s", namespace, bootstrapCoreProperties.getConfigFileType().getValue()));
Config config = ConfigService.getConfig(String.format("%s.%s", namespace, bootstrapConfigProperties.getConfigFileType().getValue()));
ConfigChangeListener configChangeListener = configChangeEvent -> {
String namespace = this.namespace.replaceAll("." + bootstrapCoreProperties.getConfigFileType().getValue(), "");
ConfigFileFormat configFileFormat = ConfigFileFormat.fromString(bootstrapCoreProperties.getConfigFileType().getValue());
String namespace = this.namespace.replaceAll("." + bootstrapConfigProperties.getConfigFileType().getValue(), "");
ConfigFileFormat configFileFormat = ConfigFileFormat.fromString(bootstrapConfigProperties.getConfigFileType().getValue());
ConfigFile configFile = ConfigService.getConfigFile(namespace, configFileFormat);
Map<String, Object> newChangeValueMap = Maps.newHashMap();
configChangeEvent.changedKeys().stream().filter(each -> each.contains(PREFIX)).forEach(each -> {

@ -19,7 +19,7 @@ package cn.hippo4j.core.springboot.starter.refresher;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.DynamicThreadPoolNotifyProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.config.NotifyPlatformProperties;
@ -35,7 +35,7 @@ import org.springframework.boot.context.properties.source.MapConfigurationProper
import java.util.List;
import java.util.Map;
import static cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties.PREFIX;
import static cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties.PREFIX;
/**
* Bootstrap core properties binder adapt.
@ -46,15 +46,15 @@ public class BootstrapCorePropertiesBinderAdapt {
* Bootstrap core properties binder.
*
* @param configInfo
* @param bootstrapCoreProperties
* @param bootstrapConfigProperties
* @return
*/
public static BootstrapCoreProperties bootstrapCorePropertiesBinder(Map<Object, Object> configInfo, BootstrapCoreProperties bootstrapCoreProperties) {
BootstrapCoreProperties bindableCoreProperties = null;
public static BootstrapConfigProperties bootstrapCorePropertiesBinder(Map<Object, Object> configInfo, BootstrapConfigProperties bootstrapConfigProperties) {
BootstrapConfigProperties bindableCoreProperties = null;
try {
ConfigurationPropertySource sources = new MapConfigurationPropertySource(configInfo);
Binder binder = new Binder(sources);
bindableCoreProperties = binder.bind(PREFIX, Bindable.ofInstance(bootstrapCoreProperties)).get();
bindableCoreProperties = binder.bind(PREFIX, Bindable.ofInstance(bootstrapConfigProperties)).get();
} catch (Exception ex) {
try {
Class.forName("org.springframework.boot.context.properties.bind.Binder");
@ -72,8 +72,8 @@ public class BootstrapCorePropertiesBinderAdapt {
* @return
*/
@Deprecated
private static BootstrapCoreProperties adapt(Map<Object, Object> configInfo) {
BootstrapCoreProperties bindableCoreProperties;
private static BootstrapConfigProperties adapt(Map<Object, Object> configInfo) {
BootstrapConfigProperties bindableConfigProperties;
try {
// filter
Map<Object, Object> targetMap = Maps.newHashMap();
@ -150,12 +150,12 @@ public class BootstrapCorePropertiesBinderAdapt {
}
}
}
bindableCoreProperties = new BootstrapCoreProperties();
bindableCoreProperties.setExecutors(executorPropertiesList);
bindableCoreProperties.setNotifyPlatforms(notifyPropertiesList);
bindableConfigProperties = new BootstrapConfigProperties();
bindableConfigProperties.setExecutors(executorPropertiesList);
bindableConfigProperties.setNotifyPlatforms(notifyPropertiesList);
} catch (Exception ex) {
throw ex;
}
return bindableCoreProperties;
return bindableConfigProperties;
}
}

@ -39,7 +39,7 @@ public class NacosCloudRefresherHandler extends AbstractCoreThreadPoolDynamicRef
@Override
public void afterPropertiesSet() throws Exception {
Map<String, String> nacosConfig = bootstrapCoreProperties.getNacos();
Map<String, String> nacosConfig = bootstrapConfigProperties.getNacos();
nacosConfigManager.getConfigService().addListener(nacosConfig.get("data-id"),
nacosConfig.get("group"), new Listener() {

@ -17,7 +17,7 @@
package cn.hippo4j.core.springboot.starter.refresher;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
@ -35,13 +35,13 @@ public class NacosRefresherHandler extends AbstractCoreThreadPoolDynamicRefresh
@NacosInjected
private ConfigService configService;
public NacosRefresherHandler(BootstrapCoreProperties bootstrapCoreProperties) {
super(bootstrapCoreProperties);
public NacosRefresherHandler(BootstrapConfigProperties bootstrapConfigProperties) {
super(bootstrapConfigProperties);
}
@Override
public void afterPropertiesSet() throws Exception {
Map<String, String> nacosConfig = bootstrapCoreProperties.getNacos();
Map<String, String> nacosConfig = bootstrapConfigProperties.getNacos();
configService.addListener(nacosConfig.get("data-id"), nacosConfig.get("group"),
new Listener() {

@ -45,7 +45,7 @@ public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefr
@Override
public void afterPropertiesSet() {
Map<String, String> zkConfigs = bootstrapCoreProperties.getZookeeper();
Map<String, String> zkConfigs = bootstrapConfigProperties.getZookeeper();
curatorFramework = CuratorFrameworkFactory.newClient(zkConfigs.get("zk-connect-str"),
new ExponentialBackoffRetry(1000, 3));
String nodePath = ZKPaths.makePath(ZKPaths.makePath(zkConfigs.get("root-node"),
@ -108,7 +108,7 @@ public class ZookeeperRefresherHandler extends AbstractCoreThreadPoolDynamicRefr
* Register notify alarm manage.
*/
public void registerNotifyAlarmManage() {
bootstrapCoreProperties.getExecutors().forEach(executorProperties -> {
bootstrapConfigProperties.getExecutors().forEach(executorProperties -> {
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm(
executorProperties.getAlarm(),
executorProperties.getCapacityAlarm(),

@ -32,7 +32,7 @@ import java.util.Map;
import java.util.Objects;
import static cn.hippo4j.common.constant.Constants.IDENTIFY_SLICER_SYMBOL;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDynamicRefreshEventOrder.ADAPTER_EXECUTORS_LISTENER;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEventOrder.ADAPTER_EXECUTORS_LISTENER;
import static cn.hippo4j.core.springboot.starter.support.DynamicThreadPoolAdapterRegister.ADAPTER_EXECUTORS_MAP;
/**
@ -40,13 +40,13 @@ import static cn.hippo4j.core.springboot.starter.support.DynamicThreadPoolAdapte
*/
@Slf4j
@Order(ADAPTER_EXECUTORS_LISTENER)
public class AdapterExecutorsRefreshListener implements ApplicationListener<Hippo4jCoreDynamicRefreshEvent> {
public class AdapterExecutorsRefreshListener implements ApplicationListener<Hippo4jConfigDynamicRefreshEvent> {
@Override
public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent event) {
public void onApplicationEvent(Hippo4jConfigDynamicRefreshEvent event) {
List<AdapterExecutorProperties> adapterExecutors;
Map<String, ThreadPoolAdapter> threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class);
if (CollectionUtil.isEmpty(adapterExecutors = event.getBootstrapCoreProperties().getAdapterExecutors()) || CollectionUtil.isEmpty(threadPoolAdapterMap)) {
if (CollectionUtil.isEmpty(adapterExecutors = event.getBootstrapConfigProperties().getAdapterExecutors()) || CollectionUtil.isEmpty(threadPoolAdapterMap)) {
return;
}
for (AdapterExecutorProperties each : adapterExecutors) {

@ -27,7 +27,7 @@ import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
import cn.hippo4j.core.proxy.RejectedProxyUtil;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.core.springboot.starter.support.GlobalCoreThreadPoolManage;
@ -51,7 +51,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_DELIMITER;
import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_THREAD_POOL_TEXT;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDynamicRefreshEventOrder.EXECUTORS_LISTENER;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEventOrder.EXECUTORS_LISTENER;
/**
* Dynamic thread-pool refresh listener.
@ -59,7 +59,7 @@ import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDyna
@Slf4j
@RequiredArgsConstructor
@Order(EXECUTORS_LISTENER)
public class DynamicThreadPoolRefreshListener implements ApplicationListener<Hippo4jCoreDynamicRefreshEvent> {
public class DynamicThreadPoolRefreshListener implements ApplicationListener<Hippo4jConfigDynamicRefreshEvent> {
private final ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler;
@ -68,9 +68,9 @@ public class DynamicThreadPoolRefreshListener implements ApplicationListener<Hip
private final Hippo4jBaseSendMessageService hippo4jBaseSendMessageService;
@Override
public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapCoreProperties bindableCoreProperties = threadPoolDynamicRefreshEvent.getBootstrapCoreProperties();
List<ExecutorProperties> executors = bindableCoreProperties.getExecutors();
public void onApplicationEvent(Hippo4jConfigDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapConfigProperties bindableConfigProperties = threadPoolDynamicRefreshEvent.getBootstrapConfigProperties();
List<ExecutorProperties> executors = bindableConfigProperties.getExecutors();
for (ExecutorProperties properties : executors) {
String threadPoolId = properties.getThreadPoolId();
// Check whether the notification configuration is consistent.

@ -17,22 +17,22 @@
package cn.hippo4j.core.springboot.starter.refresher.event;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
/**
* Hippo-4j core dynamic refresh event.
* Hippo-4j config dynamic refresh event.
*/
public class Hippo4jCoreDynamicRefreshEvent extends ApplicationEvent {
public class Hippo4jConfigDynamicRefreshEvent extends ApplicationEvent {
@Getter
@Setter
private BootstrapCoreProperties bootstrapCoreProperties;
private BootstrapConfigProperties bootstrapConfigProperties;
public Hippo4jCoreDynamicRefreshEvent(Object source, BootstrapCoreProperties bootstrapCoreProperties) {
public Hippo4jConfigDynamicRefreshEvent(Object source, BootstrapConfigProperties bootstrapConfigProperties) {
super(source);
this.bootstrapCoreProperties = bootstrapCoreProperties;
this.bootstrapConfigProperties = bootstrapConfigProperties;
}
}

@ -18,9 +18,9 @@
package cn.hippo4j.core.springboot.starter.refresher.event;
/**
* Hippo-4j core dynamic refresh event order.
* Hippo-4j config dynamic refresh event order.
*/
public interface Hippo4jCoreDynamicRefreshEventOrder {
public interface Hippo4jConfigDynamicRefreshEventOrder {
int WEB_EXECUTOR_LISTENER = 0;

@ -20,7 +20,7 @@ package cn.hippo4j.core.springboot.starter.refresher.event;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.message.dto.NotifyConfigDTO;
@ -31,18 +31,18 @@ import org.springframework.core.annotation.Order;
import java.util.List;
import java.util.Map;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDynamicRefreshEventOrder.PLATFORMS_LISTENER;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEventOrder.PLATFORMS_LISTENER;
/**
* Platforms refresh listener.
*/
@Order(PLATFORMS_LISTENER)
public class PlatformsRefreshListener implements ApplicationListener<Hippo4jCoreDynamicRefreshEvent> {
public class PlatformsRefreshListener implements ApplicationListener<Hippo4jConfigDynamicRefreshEvent> {
@Override
public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapCoreProperties bindableCoreProperties = threadPoolDynamicRefreshEvent.getBootstrapCoreProperties();
List<ExecutorProperties> executors = bindableCoreProperties.getExecutors();
public void onApplicationEvent(Hippo4jConfigDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapConfigProperties bindableConfigProperties = threadPoolDynamicRefreshEvent.getBootstrapConfigProperties();
List<ExecutorProperties> executors = bindableConfigProperties.getExecutors();
for (ExecutorProperties executorProperties : executors) {
String threadPoolId = executorProperties.getThreadPoolId();
DynamicThreadPoolWrapper wrapper = GlobalThreadPoolManage.getExecutorService(threadPoolId);

@ -22,7 +22,7 @@ import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.WebThreadPoolProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
@ -30,18 +30,18 @@ import org.springframework.core.annotation.Order;
import java.util.Objects;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jCoreDynamicRefreshEventOrder.WEB_EXECUTOR_LISTENER;
import static cn.hippo4j.core.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEventOrder.WEB_EXECUTOR_LISTENER;
/**
* Web executor refresh listener.
*/
@Slf4j
@Order(WEB_EXECUTOR_LISTENER)
public class WebExecutorRefreshListener implements ApplicationListener<Hippo4jCoreDynamicRefreshEvent> {
public class WebExecutorRefreshListener implements ApplicationListener<Hippo4jConfigDynamicRefreshEvent> {
@Override
public void onApplicationEvent(Hippo4jCoreDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapCoreProperties bindableCoreProperties = threadPoolDynamicRefreshEvent.getBootstrapCoreProperties();
public void onApplicationEvent(Hippo4jConfigDynamicRefreshEvent threadPoolDynamicRefreshEvent) {
BootstrapConfigProperties bindableCoreProperties = threadPoolDynamicRefreshEvent.getBootstrapConfigProperties();
boolean isNullFlag = bindableCoreProperties.getJetty() == null
&& bindableCoreProperties.getUndertow() == null
&& bindableCoreProperties.getTomcat() == null;
@ -65,7 +65,7 @@ public class WebExecutorRefreshListener implements ApplicationListener<Hippo4jCo
}
}
private ThreadPoolParameterInfo buildWebPoolParameter(BootstrapCoreProperties bindableCoreProperties) {
private ThreadPoolParameterInfo buildWebPoolParameter(BootstrapConfigProperties bindableCoreProperties) {
ThreadPoolParameterInfo threadPoolParameterInfo = null;
WebThreadPoolProperties webThreadPoolProperties = null;
if (bindableCoreProperties.getTomcat() != null) {

@ -19,7 +19,7 @@ package cn.hippo4j.core.springboot.starter.support;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.core.springboot.starter.config.AdapterExecutorProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -38,14 +38,14 @@ import static cn.hippo4j.common.constant.Constants.IDENTIFY_SLICER_SYMBOL;
@AllArgsConstructor
public class DynamicThreadPoolAdapterRegister implements ApplicationRunner {
private final BootstrapCoreProperties bootstrapCoreProperties;
private final BootstrapConfigProperties bootstrapConfigProperties;
public static final Map<String, AdapterExecutorProperties> ADAPTER_EXECUTORS_MAP = Maps.newConcurrentMap();
@Override
public void run(ApplicationArguments args) throws Exception {
List<AdapterExecutorProperties> adapterExecutors;
if (CollectionUtil.isEmpty(adapterExecutors = bootstrapCoreProperties.getAdapterExecutors())) {
if (CollectionUtil.isEmpty(adapterExecutors = bootstrapConfigProperties.getAdapterExecutors())) {
return;
}
for (AdapterExecutorProperties each : adapterExecutors) {

@ -28,7 +28,7 @@ import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.*;
import cn.hippo4j.core.executor.support.adpter.DynamicThreadPoolAdapterChoose;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.core.springboot.starter.config.DynamicThreadPoolNotifyProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.toolkit.inet.DynamicThreadPoolAnnotationUtil;
@ -52,7 +52,7 @@ import java.util.concurrent.TimeUnit;
@AllArgsConstructor
public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
private final BootstrapCoreProperties bootstrapCoreProperties;
private final BootstrapConfigProperties bootstrapConfigProperties;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
@ -110,8 +110,8 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
String threadPoolId = dynamicThreadPoolWrapper.getThreadPoolId();
ThreadPoolExecutor newDynamicPoolExecutor = dynamicThreadPoolWrapper.getExecutor();
ExecutorProperties executorProperties = null;
if (null != bootstrapCoreProperties.getExecutors()) {
executorProperties = bootstrapCoreProperties.getExecutors()
if (null != bootstrapConfigProperties.getExecutors()) {
executorProperties = bootstrapConfigProperties.getExecutors()
.stream()
.filter(each -> Objects.equals(threadPoolId, each.getThreadPoolId()))
.findFirst()
@ -142,15 +142,15 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
if (dynamicThreadPoolWrapper.getExecutor() instanceof AbstractDynamicExecutorSupport) {
DynamicThreadPoolNotifyProperties notify = Optional.ofNullable(executorProperties).map(ExecutorProperties::getNotify).orElse(null);
boolean isAlarm = Optional.ofNullable(executorProperties.getAlarm())
.orElseGet(() -> bootstrapCoreProperties.getAlarm() != null ? bootstrapCoreProperties.getAlarm() : true);
.orElseGet(() -> bootstrapConfigProperties.getAlarm() != null ? bootstrapConfigProperties.getAlarm() : true);
int activeAlarm = Optional.ofNullable(executorProperties.getActiveAlarm())
.orElseGet(() -> bootstrapCoreProperties.getActiveAlarm() != null ? bootstrapCoreProperties.getActiveAlarm() : 80);
.orElseGet(() -> bootstrapConfigProperties.getActiveAlarm() != null ? bootstrapConfigProperties.getActiveAlarm() : 80);
int capacityAlarm = Optional.ofNullable(executorProperties.getCapacityAlarm())
.orElseGet(() -> bootstrapCoreProperties.getCapacityAlarm() != null ? bootstrapCoreProperties.getCapacityAlarm() : 80);
.orElseGet(() -> bootstrapConfigProperties.getCapacityAlarm() != null ? bootstrapConfigProperties.getCapacityAlarm() : 80);
int interval = Optional.ofNullable(notify)
.map(each -> each.getInterval()).orElseGet(() -> bootstrapCoreProperties.getAlarmInterval() != null ? bootstrapCoreProperties.getAlarmInterval() : 5);
.map(each -> each.getInterval()).orElseGet(() -> bootstrapConfigProperties.getAlarmInterval() != null ? bootstrapConfigProperties.getAlarmInterval() : 5);
String receive = Optional.ofNullable(notify)
.map(each -> each.getReceives()).orElseGet(() -> StringUtil.isNotEmpty(bootstrapCoreProperties.getReceives()) ? bootstrapCoreProperties.getReceives() : "");
.map(each -> each.getReceives()).orElseGet(() -> StringUtil.isNotEmpty(bootstrapConfigProperties.getReceives()) ? bootstrapConfigProperties.getReceives() : "");
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm(isAlarm, activeAlarm, capacityAlarm);
threadPoolNotifyAlarm.setInterval(interval);
threadPoolNotifyAlarm.setReceives(receive);

Loading…
Cancel
Save