* fix: #10002

* fix: #10002

* feat: remove debug

* feat: format

* feat: format
pull/1018/head
BigXin0109 2 years ago committed by GitHub
parent 5f9f26df39
commit 305a2edcf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,11 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>1.5.1.RELEASE</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.boot</groupId>-->
<!-- <artifactId>nacos-config-spring-boot-starter</artifactId>-->
<!-- <version>0.1.4</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>

@ -0,0 +1,66 @@
#debug=true
server.port=8089
server.servlet.context-path=/example
management.security.enabled=false
management.context-path=/actuator
spring.profiles.active=dev
spring.application.name=hippo4j-config-nacos-spring-boot-1x-starter-example
## nacos spring-boot
nacos.config.server-addr=127.0.0.1:8848
nacos.config.ext-config[0].data-id=hippo4j-nacos.yaml
nacos.config.ext-config[0].group=DEFAULT_GROUP
nacos.config.ext-config[0].auto-refresh=true
spring.dynamic.thread-pool.enable=true
spring.dynamic.thread-pool.banner=true
spring.dynamic.thread-pool.check-state-interval=5
spring.dynamic.thread-pool.monitor.enable=true
spring.dynamic.thread-pool.monitor.collect-types=micrometer
spring.dynamic.thread-pool.monitor.thread-pool-types=dynamic,web
spring.dynamic.thread-pool.monitor.initial-delay=10000
spring.dynamic.thread-pool.monitor.collect-interval=5000
spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT
spring.dynamic.thread-pool.notify-platforms[0].token=ac0426a5-c712-474c-9bff-72b8b8f5caff
spring.dynamic.thread-pool.notify-platforms[1].platform=DING
spring.dynamic.thread-pool.notify-platforms[1].token=56417ebba6a27ca352f0de77a2ae9da66d01f39610b5ee8a6033c60ef9071c55
spring.dynamic.thread-pool.notify-platforms[2].platform=LARK
spring.dynamic.thread-pool.notify-platforms[2].token=2cbf2808-3839-4c26-a04d-fd201dd51f9e
spring.dynamic.thread-pool.nacos.data-id=hippo4j-nacos.yaml
spring.dynamic.thread-pool.nacos.group=DEFAULT_GROUP
spring.dynamic.thread-pool.config-file-type=yaml
spring.dynamic.thread-pool.executors[0].thread-pool-id=message-consume
spring.dynamic.thread-pool.executors[0].thread-name-prefix=message-consume
spring.dynamic.thread-pool.executors[0].core-pool-size=2
spring.dynamic.thread-pool.executors[0].maximum-pool-size=4
spring.dynamic.thread-pool.executors[0].queue-capacity=1024
spring.dynamic.thread-pool.executors[0].blocking-queue=ResizableCapacityLinkedBlockingQueue
spring.dynamic.thread-pool.executors[0].execute-time-out=800
spring.dynamic.thread-pool.executors[0].rejected-handler=AbortPolicy
spring.dynamic.thread-pool.executors[0].keep-alive-time=6691
spring.dynamic.thread-pool.executors[0].allow-core-thread-time-out=true
spring.dynamic.thread-pool.executors[0].alarm=true
spring.dynamic.thread-pool.executors[0].active-alarm=80
spring.dynamic.thread-pool.executors[0].capacity-alarm=80
spring.dynamic.thread-pool.executors[0].notify.interval=8
spring.dynamic.thread-pool.executors[0].notify.receives=chen.ma
spring.dynamic.thread-pool.executors[1].thread-pool-id=message-produce
spring.dynamic.thread-pool.executors[1].thread-name-prefix=message-produce
spring.dynamic.thread-pool.executors[1].core-pool-size=2
spring.dynamic.thread-pool.executors[1].maximum-pool-size=4
spring.dynamic.thread-pool.executors[1].queue-capacity=1024
spring.dynamic.thread-pool.executors[1].blocking-queue=ResizableCapacityLinkedBlockingQueue
spring.dynamic.thread-pool.executors[1].execute-time-out=800
spring.dynamic.thread-pool.executors[1].rejected-handler=AbortPolicy
spring.dynamic.thread-pool.executors[1].keep-alive-time=6691
spring.dynamic.thread-pool.executors[1].allow-core-thread-time-out=true
spring.dynamic.thread-pool.executors[1].alarm=true
spring.dynamic.thread-pool.executors[1].active-alarm=80
spring.dynamic.thread-pool.executors[1].capacity-alarm=80
spring.dynamic.thread-pool.executors[1].notify.interval=8
spring.dynamic.thread-pool.executors[1].notify.receives=chen.ma

@ -8,6 +8,7 @@ management.context-path=/actuator
spring.profiles.active=dev
spring.application.name=hippo4j-config-nacos-spring-boot-1x-starter-example
# nacos spring-cloud
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.ext-config[0].data-id=hippo4j-nacos.yaml
spring.cloud.nacos.config.ext-config[0].group=DEFAULT_GROUP

@ -17,15 +17,21 @@
package cn.hippo4j.config.springboot.starter.config;
import cn.hippo4j.config.springboot.starter.refresher.*;
import com.alibaba.cloud.nacos.NacosConfigManager;
import cn.hippo4j.config.springboot.starter.refresher.ApolloRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.BootstrapConfigPropertiesBinderAdapt;
import cn.hippo4j.config.springboot.starter.refresher.ConsulRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.DefaultBootstrapConfigPropertiesBinderAdapt;
import cn.hippo4j.config.springboot.starter.refresher.EtcdRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.NacosCloudRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.NacosRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.PolarisRefresherHandler;
import cn.hippo4j.config.springboot.starter.refresher.ZookeeperRefresherHandler;
import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.nacos.api.config.ConfigService;
import com.tencent.polaris.configuration.api.core.ConfigFileService;
import io.etcd.jetcd.Client;
import lombok.RequiredArgsConstructor;
import org.apache.curator.framework.CuratorFramework;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
@ -42,6 +48,8 @@ public class ConfigHandlerConfiguration {
private static final String NACOS_CONFIG_MANAGER_KEY = "com.alibaba.cloud.nacos.NacosConfigManager";
private static final String NACOS_INJECTED_BEAN_NAME = "com.alibaba.nacos.spring.beans.factory.annotation.AnnotationNacosInjectedBeanPostProcessor";
private static final String NACOS_DATA_ID_KEY = "nacos.data-id";
private static final String APOLLO_NAMESPACE_KEY = "apollo.namespace";
@ -61,18 +69,18 @@ public class ConfigHandlerConfiguration {
}
@RequiredArgsConstructor
@ConditionalOnClass(ConfigService.class)
@ConditionalOnClass(value = ConfigService.class, name = NACOS_INJECTED_BEAN_NAME)
@ConditionalOnMissingClass(NACOS_CONFIG_MANAGER_KEY)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacos {
@Bean
public NacosRefresherHandler nacosRefresherHandler(NacosConfigProperties nacosConfigProperties) {
return new NacosRefresherHandler(nacosConfigProperties);
public NacosRefresherHandler nacosRefresherHandler() {
return new NacosRefresherHandler();
}
}
@ConditionalOnClass(NacosConfigManager.class)
@ConditionalOnClass(NacosConfigProperties.class)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, name = NACOS_DATA_ID_KEY)
static class EmbeddedNacosCloud {

@ -18,7 +18,8 @@
package cn.hippo4j.config.springboot.starter.refresher;
import cn.hippo4j.common.config.ApplicationContextHolder;
import com.alibaba.cloud.nacos.NacosConfigManager;
import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.SneakyThrows;
@ -37,17 +38,17 @@ public class NacosCloudRefresherHandler extends AbstractConfigThreadPoolDynamicR
static final String GROUP = "group";
private final NacosConfigManager nacosConfigManager;
private final ConfigService configService;
public NacosCloudRefresherHandler() {
nacosConfigManager = ApplicationContextHolder.getBean(NacosConfigManager.class);
configService = ApplicationContextHolder.getBean(NacosConfigProperties.class).configServiceInstance();
}
@SneakyThrows(NacosException.class)
@Override
public void initRegisterListener() {
Map<String, String> nacosConfig = bootstrapConfigProperties.getNacos();
nacosConfigManager.getConfigService().addListener(nacosConfig.get(DATA_ID),
configService.addListener(nacosConfig.get(DATA_ID),
nacosConfig.get(GROUP), new Listener() {
@Override

@ -17,7 +17,6 @@
package cn.hippo4j.config.springboot.starter.refresher;
import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
@ -41,8 +40,8 @@ public class NacosRefresherHandler extends AbstractConfigThreadPoolDynamicRefres
@NacosInjected
private ConfigService configService;
public NacosRefresherHandler(NacosConfigProperties nacosConfigProperties) {
this.configService = nacosConfigProperties.configServiceInstance();
public NacosRefresherHandler() {
super();
}
@SneakyThrows(NacosException.class)

@ -17,9 +17,11 @@
package cn.hippo4j.springboot.starter.monitor.local.log;
import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.monitor.local.log.AdapterThreadPoolLocalLogMonitorHandler;
import cn.hippo4j.monitor.local.log.DynamicThreadPoolLocalLogMonitorHandler;
import cn.hippo4j.monitor.local.log.WebThreadPoolLocalLogMonitorHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -38,6 +40,7 @@ public class LocalLogMonitorAutoConfiguration {
}
@Bean
@ConditionalOnBean(WebThreadPoolService.class)
@ConditionalOnExpression("'${spring.dynamic.thread-pool.monitor.thread-pool-types:}'.contains('web')")
public WebThreadPoolLocalLogMonitorHandler webThreadPoolLocalLogMonitorHandler() {
return new WebThreadPoolLocalLogMonitorHandler();

@ -17,9 +17,11 @@
package cn.hippo4j.springboot.starter.monitor.micrometer;
import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.monitor.micrometer.AdapterThreadPoolMicrometerMonitorHandler;
import cn.hippo4j.monitor.micrometer.DynamicThreadPoolMicrometerMonitorHandler;
import cn.hippo4j.monitor.micrometer.WebThreadPoolMicrometerMonitorHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -38,6 +40,7 @@ public class MicrometerMonitorAutoConfiguration {
}
@Bean
@ConditionalOnBean(WebThreadPoolService.class)
@ConditionalOnExpression("'${spring.dynamic.thread-pool.monitor.thread-pool-types:}'.contains('web')")
public WebThreadPoolMicrometerMonitorHandler webThreadPoolMicrometerMonitorHandler() {
return new WebThreadPoolMicrometerMonitorHandler();

Loading…
Cancel
Save