From c47ce4ceb391eb8d824a5372e3696f1c08bff8c7 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Fri, 5 Aug 2022 23:08:11 +0800 Subject: [PATCH] Dynamic thread pool monitoring module refactoring --- .../config/controller/ConfigController.java | 8 +-- .../hippo4j-core-spring-boot-starter/pom.xml | 14 +---- .../config/BootstrapCoreProperties.java | 2 - ...ynamicThreadPoolCoreAutoConfiguration.java | 4 +- .../config/MonitorHandlerConfiguration.java | 63 ------------------- .../config/condition/EsMonitorCondition.java | 37 ----------- .../config/condition/LogMonitorCondition.java | 37 ----------- .../condition/PrometheusMonitorCondition.java | 37 ----------- .../pom.xml | 51 +++++++++++++++ .../es/EsMonitorAutoConfiguration.java | 35 +++++++++++ .../main/resources/META-INF/spring.factories | 1 + .../pom.xml | 51 +++++++++++++++ .../log/LogMonitorAutoConfiguration.java | 35 +++++++++++ .../main/resources/META-INF/spring.factories | 1 + .../pom.xml | 51 +++++++++++++++ .../PrometheusMonitorAutoConfiguration.java} | 20 +++--- .../main/resources/META-INF/spring.factories | 1 + .../pom.xml | 18 ++++++ .../hippo4j-spring-boot-starter/pom.xml | 8 +-- .../starter/config/BootstrapProperties.java | 2 - .../DynamicThreadPoolAutoConfiguration.java | 2 - hippo4j-spring-boot/pom.xml | 1 + 22 files changed, 259 insertions(+), 220 deletions(-) delete mode 100644 hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/MonitorHandlerConfiguration.java delete mode 100644 hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/EsMonitorCondition.java delete mode 100644 hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/LogMonitorCondition.java delete mode 100644 hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/PrometheusMonitorCondition.java create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/pom.xml create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/resources/META-INF/spring.factories create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/pom.xml create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/java/cn/hippo4j/springboot/starter/monitor/log/LogMonitorAutoConfiguration.java create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/resources/META-INF/spring.factories create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/pom.xml rename hippo4j-spring-boot/{hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/MonitorHandlerConfiguration.java => hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/java/cn/hippo4j/springboot/starter/monitor/prometheus/PrometheusMonitorAutoConfiguration.java} (63%) create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/resources/META-INF/spring.factories create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/pom.xml diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java index 05ebc159..d3a40e85 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java @@ -54,10 +54,10 @@ public class ConfigController { @GetMapping public Result detailConfigInfo( - @RequestParam("tpId") String tpId, - @RequestParam("itemId") String itemId, - @RequestParam("namespace") String namespace, - @RequestParam(value = "instanceId", required = false) String instanceId) { + @RequestParam("tpId") String tpId, + @RequestParam("itemId") String itemId, + @RequestParam("namespace") String namespace, + @RequestParam(value = "instanceId", required = false) String instanceId) { ConfigAllInfo configAllInfo = configService.findConfigRecentInfo(tpId, itemId, namespace, instanceId); return Results.success(configAllInfo); } diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/pom.xml b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/pom.xml index 7056e02a..f91fbd6f 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/pom.xml @@ -74,19 +74,7 @@ cn.hippo4j - hippo4j-monitor-log - ${revision} - - - - cn.hippo4j - hippo4j-monitor-prometheus - ${revision} - - - - cn.hippo4j - hippo4j-monitor-es + hippo4j-monitor-base ${revision} diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java index 8f6a9e50..eddc95be 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/BootstrapCoreProperties.java @@ -19,7 +19,6 @@ package cn.hippo4j.core.springboot.starter.config; import cn.hippo4j.core.config.BootstrapPropertiesInterface; import cn.hippo4j.core.springboot.starter.parser.ConfigFileTypeEnum; -import com.example.monitor.base.DynamicThreadPoolMonitor; import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -57,7 +56,6 @@ public class BootstrapCoreProperties implements BootstrapPropertiesInterface { /** * Type of collection thread pool running data. eg: log,prometheus. Multiple can be used at the same time. - * Custom SPI support {@link DynamicThreadPoolMonitor}. */ private String collectType; diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java index c616c9c2..aca64a74 100644 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java @@ -58,9 +58,7 @@ import org.springframework.core.annotation.Order; @ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true") @Import({ ConfigHandlerConfiguration.EmbeddedNacos.class, ConfigHandlerConfiguration.EmbeddedNacosCloud.class, - ConfigHandlerConfiguration.EmbeddedApollo.class, ConfigHandlerConfiguration.EmbeddedZookeeper.class, - MonitorHandlerConfiguration.EmbeddedLogMonitor.class, MonitorHandlerConfiguration.EmbeddedPrometheusMonitor.class, - MonitorHandlerConfiguration.EmbeddedEsMonitor.class + ConfigHandlerConfiguration.EmbeddedApollo.class, ConfigHandlerConfiguration.EmbeddedZookeeper.class }) public class DynamicThreadPoolCoreAutoConfiguration { diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/MonitorHandlerConfiguration.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/MonitorHandlerConfiguration.java deleted file mode 100644 index 09ab75db..00000000 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/MonitorHandlerConfiguration.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.hippo4j.core.springboot.starter.config; - -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; -import cn.hippo4j.core.springboot.starter.config.condition.EsMonitorCondition; -import cn.hippo4j.core.springboot.starter.config.condition.LogMonitorCondition; -import cn.hippo4j.core.springboot.starter.config.condition.PrometheusMonitorCondition; -import cn.hippo4j.monitor.es.EsMonitorHandler; -import cn.hippo4j.monitor.log.LogMonitorHandler; -import cn.hippo4j.monitor.prometheus.PrometheusMonitorHandler; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; - -/** - * Monitor handler configuration. - */ -@Configuration(proxyBeanMethods = false) -public class MonitorHandlerConfiguration { - - @Conditional(LogMonitorCondition.class) - static class EmbeddedLogMonitor { - - @Bean - public LogMonitorHandler logMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new LogMonitorHandler(threadPoolRunStateHandler); - } - } - - @Conditional(PrometheusMonitorCondition.class) - static class EmbeddedPrometheusMonitor { - - @Bean - public PrometheusMonitorHandler prometheusMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new PrometheusMonitorHandler(threadPoolRunStateHandler); - } - } - - @Conditional(EsMonitorCondition.class) - static class EmbeddedEsMonitor { - - @Bean - public EsMonitorHandler EsMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new EsMonitorHandler(threadPoolRunStateHandler); - } - } -} diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/EsMonitorCondition.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/EsMonitorCondition.java deleted file mode 100644 index ee791f44..00000000 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/EsMonitorCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.hippo4j.core.springboot.starter.config.condition; - -import cn.hippo4j.common.toolkit.StringUtil; -import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties; -import com.example.monitor.base.MonitorTypeEnum; -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; - -/** - * Prometheus monitor condition. - */ -public class EsMonitorCondition implements Condition { - - @Override - public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { - String collectType = context.getEnvironment().getProperty(BootstrapCoreProperties.PREFIX + ".collect-type", ""); - return StringUtil.isNotEmpty(collectType) && collectType.contains(MonitorTypeEnum.ES.name().toLowerCase()) ? true : false; - } -} diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/LogMonitorCondition.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/LogMonitorCondition.java deleted file mode 100644 index d3a8e4f8..00000000 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/LogMonitorCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.hippo4j.core.springboot.starter.config.condition; - -import cn.hippo4j.common.toolkit.StringUtil; -import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties; -import com.example.monitor.base.MonitorTypeEnum; -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; - -/** - * Log monitor condition. - */ -public class LogMonitorCondition implements Condition { - - @Override - public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { - String collectType = context.getEnvironment().getProperty(BootstrapCoreProperties.PREFIX + ".collect-type", ""); - return StringUtil.isNotEmpty(collectType) && collectType.contains(MonitorTypeEnum.LOG.name().toLowerCase()) ? true : false; - } -} diff --git a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/PrometheusMonitorCondition.java b/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/PrometheusMonitorCondition.java deleted file mode 100644 index dc21554c..00000000 --- a/hippo4j-spring-boot/hippo4j-core-spring-boot-starter/src/main/java/cn/hippo4j/core/springboot/starter/config/condition/PrometheusMonitorCondition.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cn.hippo4j.core.springboot.starter.config.condition; - -import cn.hippo4j.common.toolkit.StringUtil; -import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties; -import com.example.monitor.base.MonitorTypeEnum; -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; - -/** - * Prometheus monitor condition. - */ -public class PrometheusMonitorCondition implements Condition { - - @Override - public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { - String collectType = context.getEnvironment().getProperty(BootstrapCoreProperties.PREFIX + ".collect-type", ""); - return StringUtil.isNotEmpty(collectType) && collectType.contains(MonitorTypeEnum.PROMETHEUS.name().toLowerCase()) ? true : false; - } -} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/pom.xml new file mode 100644 index 00000000..a93ea809 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-spring-boot-starter-monitor + ${revision} + + hippo4j-spring-boot-starter-monitor-es + + + + cn.hippo4j + hippo4j-monitor-es + ${revision} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + chen.ma + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + + jar + + + + + + + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java new file mode 100644 index 00000000..25a94b13 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.springboot.starter.monitor.es; + +import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; +import cn.hippo4j.monitor.es.EsMonitorHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Es monitor auto configuration. + */ +@Configuration +public class EsMonitorAutoConfiguration { + + @Bean + public EsMonitorHandler esMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { + return new EsMonitorHandler(threadPoolRunStateHandler); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..325fc0aa --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-es/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.es.EsMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/pom.xml new file mode 100644 index 00000000..3fec2bba --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-spring-boot-starter-monitor + ${revision} + + hippo4j-spring-boot-starter-monitor-log + + + + cn.hippo4j + hippo4j-monitor-log + ${revision} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + chen.ma + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + + jar + + + + + + + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/java/cn/hippo4j/springboot/starter/monitor/log/LogMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/java/cn/hippo4j/springboot/starter/monitor/log/LogMonitorAutoConfiguration.java new file mode 100644 index 00000000..6b4cd63f --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/java/cn/hippo4j/springboot/starter/monitor/log/LogMonitorAutoConfiguration.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.springboot.starter.monitor.log; + +import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; +import cn.hippo4j.monitor.log.LogMonitorHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Log monitor auto configuration. + */ +@Configuration +public class LogMonitorAutoConfiguration { + + @Bean + public LogMonitorHandler logMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { + return new LogMonitorHandler(threadPoolRunStateHandler); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..d386fdc6 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-log/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.log.LogMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/pom.xml new file mode 100644 index 00000000..b9d3e87c --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-spring-boot-starter-monitor + ${revision} + + hippo4j-spring-boot-starter-monitor-prometheus + + + + cn.hippo4j + hippo4j-monitor-prometheus + ${revision} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + chen.ma + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + + jar + + + + + + + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/MonitorHandlerConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/java/cn/hippo4j/springboot/starter/monitor/prometheus/PrometheusMonitorAutoConfiguration.java similarity index 63% rename from hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/MonitorHandlerConfiguration.java rename to hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/java/cn/hippo4j/springboot/starter/monitor/prometheus/PrometheusMonitorAutoConfiguration.java index ab556baa..5aa26020 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/MonitorHandlerConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/java/cn/hippo4j/springboot/starter/monitor/prometheus/PrometheusMonitorAutoConfiguration.java @@ -15,27 +15,21 @@ * limitations under the License. */ -package cn.hippo4j.springboot.starter.config; +package cn.hippo4j.springboot.starter.monitor.prometheus; import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.monitor.prometheus.PrometheusMonitorHandler; -import cn.hippo4j.springboot.starter.config.condition.PrometheusMonitorCondition; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; /** - * Monitor handler configuration. + * Prometheus monitor auto configuration. */ -@Configuration(proxyBeanMethods = false) -public class MonitorHandlerConfiguration { +@Configuration +public class PrometheusMonitorAutoConfiguration { - @Conditional(PrometheusMonitorCondition.class) - static class EmbeddedPrometheusMonitor { - - @Bean - public PrometheusMonitorHandler prometheusMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new PrometheusMonitorHandler(threadPoolRunStateHandler); - } + @Bean + public PrometheusMonitorHandler prometheusMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { + return new PrometheusMonitorHandler(threadPoolRunStateHandler); } } diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..91f26a3e --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-prometheus/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.prometheus.PrometheusMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/pom.xml new file mode 100644 index 00000000..97cda63f --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-spring-boot + ${revision} + + hippo4j-spring-boot-starter-monitor + pom + + + hippo4j-spring-boot-starter-monitor-es + hippo4j-spring-boot-starter-monitor-log + hippo4j-spring-boot-starter-monitor-prometheus + + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml index 8996ff47..4705a239 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml @@ -99,13 +99,7 @@ cn.hippo4j - hippo4j-monitor-prometheus - ${revision} - - - - cn.hippo4j - hippo4j-monitor-es + hippo4j-monitor-base ${revision} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/BootstrapProperties.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/BootstrapProperties.java index 73d6c0b9..1da444e9 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/BootstrapProperties.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/BootstrapProperties.java @@ -18,7 +18,6 @@ package cn.hippo4j.springboot.starter.config; import cn.hippo4j.core.config.BootstrapPropertiesInterface; -import com.example.monitor.base.DynamicThreadPoolMonitor; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -90,7 +89,6 @@ public class BootstrapProperties implements BootstrapPropertiesInterface { /** * Type of collection thread pool running data. eg: server,prometheus. Multiple can be used at the same time. - * Custom SPI support {@link DynamicThreadPoolMonitor}. */ private String collectType; diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index 9b3550ca..58ec9f9e 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -53,7 +53,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; @@ -70,7 +69,6 @@ import org.springframework.core.env.ConfigurableEnvironment; @EnableConfigurationProperties(BootstrapProperties.class) @ConditionalOnProperty(prefix = BootstrapProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true") @ImportAutoConfiguration({HttpClientConfiguration.class, NettyClientConfiguration.class, DiscoveryConfiguration.class, MessageConfiguration.class, UtilAutoConfiguration.class}) -@Import(MonitorHandlerConfiguration.EmbeddedPrometheusMonitor.class) public class DynamicThreadPoolAutoConfiguration { private final BootstrapProperties properties; diff --git a/hippo4j-spring-boot/pom.xml b/hippo4j-spring-boot/pom.xml index 1324b241..b3cfb92b 100644 --- a/hippo4j-spring-boot/pom.xml +++ b/hippo4j-spring-boot/pom.xml @@ -14,5 +14,6 @@ hippo4j-core-spring-boot-starter hippo4j-spring-boot-starter hippo4j-spring-boot-starter-adapter + hippo4j-spring-boot-starter-monitor