diff --git a/hippo4j-monitor/hippo4j-monitor-base/pom.xml b/hippo4j-monitor/hippo4j-monitor-base/pom.xml index 3b22714a..f5485ee1 100644 --- a/hippo4j-monitor/hippo4j-monitor-base/pom.xml +++ b/hippo4j-monitor/hippo4j-monitor-base/pom.xml @@ -13,6 +13,17 @@ cn.hippo4j hippo4j-core + ${revision} + + + cn.hippo4j + hippo4j-adapter-web + ${revision} + + + cn.hippo4j + hippo4j-adapter-base + ${revision} diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractAdapterThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractAdapterThreadPoolMonitor.java new file mode 100644 index 00000000..adf1ca1c --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractAdapterThreadPoolMonitor.java @@ -0,0 +1,43 @@ +/* + * 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.monitor.base; + +import cn.hippo4j.adapter.base.ThreadPoolAdapter; +import cn.hippo4j.adapter.base.ThreadPoolAdapterState; +import cn.hippo4j.common.config.ApplicationContextHolder; + +import java.util.Map; + +/** + * Abstract adapter thread-pool monitor. + */ +public abstract class AbstractAdapterThreadPoolMonitor implements AdapterThreadPoolMonitor { + + /** + * Execute collection thread pool running data. + * + * @param threadPoolAdapterState thread-pool adapter state + */ + protected abstract void execute(ThreadPoolAdapterState threadPoolAdapterState); + + @Override + public void collect() { + Map threadPoolAdapterMap = ApplicationContextHolder.getBeansOfType(ThreadPoolAdapter.class); + threadPoolAdapterMap.forEach((beanName, bean) -> bean.getThreadPoolStates().forEach(each -> execute(each))); + } +} diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractDynamicThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractDynamicThreadPoolMonitor.java index b3944cc4..81943cbd 100644 --- a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractDynamicThreadPoolMonitor.java +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractDynamicThreadPoolMonitor.java @@ -20,24 +20,24 @@ package cn.hippo4j.monitor.base; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage; import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; -import lombok.RequiredArgsConstructor; +import javax.annotation.Resource; import java.util.List; /** * Abstract dynamic thread-pool monitor. */ -@RequiredArgsConstructor public abstract class AbstractDynamicThreadPoolMonitor implements DynamicThreadPoolMonitor { - private final ThreadPoolRunStateHandler threadPoolRunStateHandler; + @Resource + private ThreadPoolRunStateHandler threadPoolRunStateHandler; /** * Execute collection thread pool running data. * - * @param poolRunStateInfo + * @param dynamicThreadPoolRunStateInfo dynamic thread-pool run state info */ - protected abstract void execute(ThreadPoolRunStateInfo poolRunStateInfo); + protected abstract void execute(ThreadPoolRunStateInfo dynamicThreadPoolRunStateInfo); @Override public void collect() { diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractWebThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractWebThreadPoolMonitor.java new file mode 100644 index 00000000..ad0cb2da --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AbstractWebThreadPoolMonitor.java @@ -0,0 +1,45 @@ +/* + * 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.monitor.base; + +import cn.hippo4j.adapter.web.WebThreadPoolService; +import cn.hippo4j.common.model.ThreadPoolRunStateInfo; + +import javax.annotation.Resource; + +/** + * Abstract web thread-pool monitor. + */ +public abstract class AbstractWebThreadPoolMonitor implements WebThreadPoolMonitor { + + @Resource + private WebThreadPoolService webThreadPoolService; + + /** + * Execute collection thread pool running data. + * + * @param webThreadPoolRunStateInfo web thread-pool run state info + */ + protected abstract void execute(ThreadPoolRunStateInfo webThreadPoolRunStateInfo); + + @Override + public void collect() { + ThreadPoolRunStateInfo webThreadPoolRunStateInfo = webThreadPoolService.getWebRunStateInfo(); + execute(webThreadPoolRunStateInfo); + } +} diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AdapterThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AdapterThreadPoolMonitor.java new file mode 100644 index 00000000..cebdc7e2 --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/AdapterThreadPoolMonitor.java @@ -0,0 +1,25 @@ +/* + * 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.monitor.base; + +/** + * Adapter thread-pool monitor. + */ +public interface AdapterThreadPoolMonitor extends ThreadPoolMonitor { + +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorConfiguration.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/MonitorThreadPoolTypeEnum.java similarity index 57% rename from hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorConfiguration.java rename to hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/MonitorThreadPoolTypeEnum.java index a5014a5c..1aabdec4 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorConfiguration.java +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/MonitorThreadPoolTypeEnum.java @@ -15,21 +15,25 @@ * limitations under the License. */ -package cn.hippo4j.springboot.starter.monitor.micrometer; - -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; -import cn.hippo4j.monitor.micrometer.MicrometerMonitorHandler; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; +package cn.hippo4j.monitor.base; /** - * Micrometer monitor configuration. + * Monitor thread-pool type enum. */ -@Configuration -public class MicrometerMonitorConfiguration { +public enum MonitorThreadPoolTypeEnum { + + /** + * Dynamic thread-pool + */ + DYNAMIC, + + /** + * Web thread-pool + */ + WEB, - @Bean - public MicrometerMonitorHandler micrometerMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new MicrometerMonitorHandler(threadPoolRunStateHandler); - } + /** + * Adapter thread-pool + */ + ADAPTER } diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/ThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/ThreadPoolMonitor.java index 81159992..b8f54211 100644 --- a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/ThreadPoolMonitor.java +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/ThreadPoolMonitor.java @@ -18,19 +18,19 @@ package cn.hippo4j.monitor.base; /** - * Thread-pool monitor. + * Thread-pool runtime monitor. */ public interface ThreadPoolMonitor { /** - * Get type. + * Get thread-pool monitoring type. * - * @return + * @return monitoring type */ String getType(); /** - * Collect data. + * Collect thread-pool runtime data. */ void collect(); } diff --git a/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/WebThreadPoolMonitor.java b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/WebThreadPoolMonitor.java new file mode 100644 index 00000000..333c0dbd --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-base/src/main/java/cn/hippo4j/monitor/base/WebThreadPoolMonitor.java @@ -0,0 +1,25 @@ +/* + * 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.monitor.base; + +/** + * Web thread-pool monitor. + */ +public interface WebThreadPoolMonitor extends ThreadPoolMonitor { + +} diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/AdapterThreadPoolElasticSearchMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/AdapterThreadPoolElasticSearchMonitorHandler.java new file mode 100644 index 00000000..d20140c8 --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/AdapterThreadPoolElasticSearchMonitorHandler.java @@ -0,0 +1,40 @@ +/* + * 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.monitor.elasticsearch; + +import cn.hippo4j.common.model.ThreadPoolRunStateInfo; +import cn.hippo4j.monitor.base.AbstractDynamicThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; +import lombok.extern.slf4j.Slf4j; + +/** + * Adapter thread-pool elastic-search monitor handler. + */ +@Slf4j +public class AdapterThreadPoolElasticSearchMonitorHandler extends AbstractDynamicThreadPoolMonitor { + + @Override + protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { + // TODO + } + + @Override + public String getType() { + return MonitorTypeEnum.ELASTICSEARCH.name().toLowerCase(); + } +} diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/DynamicThreadPoolElasticSearchMonitorHandler.java similarity index 87% rename from hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java rename to hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/DynamicThreadPoolElasticSearchMonitorHandler.java index 505712c4..36101cb8 100644 --- a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/DynamicThreadPoolElasticSearchMonitorHandler.java @@ -15,26 +15,25 @@ * limitations under the License. */ -package cn.hippo4j.monitor.es; +package cn.hippo4j.monitor.elasticsearch; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; import cn.hippo4j.common.toolkit.BeanUtil; import cn.hippo4j.common.toolkit.FileUtil; import cn.hippo4j.common.toolkit.JSONUtil; -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; -import cn.hippo4j.monitor.es.model.EsThreadPoolRunStateInfo; import cn.hippo4j.monitor.base.AbstractDynamicThreadPoolMonitor; import cn.hippo4j.monitor.base.MonitorTypeEnum; +import cn.hippo4j.monitor.elasticsearch.model.ElasticSearchThreadPoolRunStateInfo; import lombok.extern.slf4j.Slf4j; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; import org.springframework.core.env.Environment; @@ -47,20 +46,16 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; /** - * Elastic-search monitor handler. + * Dynamic thread-pool elastic-search monitor handler. */ @Slf4j -public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { - - public EsMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - super(threadPoolRunStateHandler); - } +public class DynamicThreadPoolElasticSearchMonitorHandler extends AbstractDynamicThreadPoolMonitor { private AtomicBoolean isIndexExist = null; @Override protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { - EsThreadPoolRunStateInfo esThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, EsThreadPoolRunStateInfo.class); + ElasticSearchThreadPoolRunStateInfo esThreadPoolRunStateInfo = BeanUtil.convert(poolRunStateInfo, ElasticSearchThreadPoolRunStateInfo.class); Environment environment = ApplicationContextHolder.getInstance().getEnvironment(); String indexName = environment.getProperty("es.thread-pool-state.index.name", "thread-pool-state"); String applicationName = environment.getProperty("spring.application.name", "application"); @@ -75,8 +70,8 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { this.log2Es(esThreadPoolRunStateInfo, indexName); } - public void log2Es(EsThreadPoolRunStateInfo esThreadPoolRunStateInfo, String indexName) { - RestHighLevelClient client = EsClientHolder.getClient(); + public void log2Es(ElasticSearchThreadPoolRunStateInfo esThreadPoolRunStateInfo, String indexName) { + RestHighLevelClient client = ElasticSearchClientHolder.getClient(); try { IndexRequest request = new IndexRequest(indexName, "_doc"); request.id(esThreadPoolRunStateInfo.getId()); @@ -99,7 +94,7 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { boolean exists = false; GetIndexRequest request = new GetIndexRequest(index); try { - RestHighLevelClient client = EsClientHolder.getClient(); + RestHighLevelClient client = ElasticSearchClientHolder.getClient(); exists = client.indices().exists(request, RequestOptions.DEFAULT); } catch (IOException e) { log.error("check es index fail"); @@ -110,7 +105,7 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { } public void createIndex(String index, String type, String mapping, Integer shards, Integer replicas, String alias) { - RestHighLevelClient client = EsClientHolder.getClient(); + RestHighLevelClient client = ElasticSearchClientHolder.getClient(); boolean acknowledged = false; CreateIndexRequest request = new CreateIndexRequest(index); if (StringUtils.hasText(mapping)) { diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/ElasticSearchClientHolder.java similarity index 97% rename from hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java rename to hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/ElasticSearchClientHolder.java index c8cfc61d..f30bbdc6 100644 --- a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/ElasticSearchClientHolder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package cn.hippo4j.monitor.es; +package cn.hippo4j.monitor.elasticsearch; import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.common.toolkit.StringUtil; @@ -37,7 +37,7 @@ import java.util.List; * Elastic-search client holder. */ @Slf4j -public class EsClientHolder { +public class ElasticSearchClientHolder { private static String host; diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/WebThreadPoolElasticSearchMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/WebThreadPoolElasticSearchMonitorHandler.java new file mode 100644 index 00000000..83bdcfe8 --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/WebThreadPoolElasticSearchMonitorHandler.java @@ -0,0 +1,40 @@ +/* + * 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.monitor.elasticsearch; + +import cn.hippo4j.common.model.ThreadPoolRunStateInfo; +import cn.hippo4j.monitor.base.AbstractDynamicThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; +import lombok.extern.slf4j.Slf4j; + +/** + * Web thread-pool elastic-search monitor handler. + */ +@Slf4j +public class WebThreadPoolElasticSearchMonitorHandler extends AbstractDynamicThreadPoolMonitor { + + @Override + protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { + // TODO + } + + @Override + public String getType() { + return MonitorTypeEnum.ELASTICSEARCH.name().toLowerCase(); + } +} diff --git a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/model/ElasticSearchThreadPoolRunStateInfo.java similarity index 88% rename from hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java rename to hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/model/ElasticSearchThreadPoolRunStateInfo.java index e4cdcae3..cc4da6e1 100644 --- a/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java +++ b/hippo4j-monitor/hippo4j-monitor-elasticsearch/src/main/java/cn/hippo4j/monitor/elasticsearch/model/ElasticSearchThreadPoolRunStateInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package cn.hippo4j.monitor.es.model; +package cn.hippo4j.monitor.elasticsearch.model; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; import lombok.Getter; @@ -26,7 +26,7 @@ import lombok.Setter; */ @Getter @Setter -public class EsThreadPoolRunStateInfo extends ThreadPoolRunStateInfo { +public class ElasticSearchThreadPoolRunStateInfo extends ThreadPoolRunStateInfo { private String Id; diff --git a/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/AdapterThreadPoolLocalLogMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/AdapterThreadPoolLocalLogMonitorHandler.java new file mode 100644 index 00000000..b7a8113c --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/AdapterThreadPoolLocalLogMonitorHandler.java @@ -0,0 +1,41 @@ +/* + * 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.monitor.local.log; + +import cn.hippo4j.adapter.base.ThreadPoolAdapterState; +import cn.hippo4j.common.toolkit.JSONUtil; +import cn.hippo4j.monitor.base.AbstractAdapterThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; +import lombok.extern.slf4j.Slf4j; + +/** + * Adapter thread-pool local log monitor handler. + */ +@Slf4j +public class AdapterThreadPoolLocalLogMonitorHandler extends AbstractAdapterThreadPoolMonitor { + + @Override + protected void execute(ThreadPoolAdapterState threadPoolAdapterState) { + log.info("{}", JSONUtil.toJSONString(threadPoolAdapterState)); + } + + @Override + public String getType() { + return MonitorTypeEnum.LOG.name().toLowerCase(); + } +} diff --git a/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/LocalLogMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/DynamicThreadPoolLocalLogMonitorHandler.java similarity index 81% rename from hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/LocalLogMonitorHandler.java rename to hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/DynamicThreadPoolLocalLogMonitorHandler.java index 83c7b28e..71e6ea19 100644 --- a/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/LocalLogMonitorHandler.java +++ b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/DynamicThreadPoolLocalLogMonitorHandler.java @@ -19,20 +19,15 @@ package cn.hippo4j.monitor.local.log; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; import cn.hippo4j.common.toolkit.JSONUtil; -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.monitor.base.AbstractDynamicThreadPoolMonitor; import cn.hippo4j.monitor.base.MonitorTypeEnum; import lombok.extern.slf4j.Slf4j; /** - * Local log monitor handler. + * Dynamic thread-pool local log monitor handler. */ @Slf4j -public class LocalLogMonitorHandler extends AbstractDynamicThreadPoolMonitor { - - public LocalLogMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - super(threadPoolRunStateHandler); - } +public class DynamicThreadPoolLocalLogMonitorHandler extends AbstractDynamicThreadPoolMonitor { @Override protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { diff --git a/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/WebThreadPoolLocalLogMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/WebThreadPoolLocalLogMonitorHandler.java new file mode 100644 index 00000000..4141eab1 --- /dev/null +++ b/hippo4j-monitor/hippo4j-monitor-local-log/src/main/java/cn/hippo4j/monitor/local/log/WebThreadPoolLocalLogMonitorHandler.java @@ -0,0 +1,41 @@ +/* + * 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.monitor.local.log; + +import cn.hippo4j.common.model.ThreadPoolRunStateInfo; +import cn.hippo4j.common.toolkit.JSONUtil; +import cn.hippo4j.monitor.base.AbstractWebThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; +import lombok.extern.slf4j.Slf4j; + +/** + * Web thread-pool local log monitor handler. + */ +@Slf4j +public class WebThreadPoolLocalLogMonitorHandler extends AbstractWebThreadPoolMonitor { + + @Override + protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { + log.info("{}", JSONUtil.toJSONString(poolRunStateInfo)); + } + + @Override + public String getType() { + return MonitorTypeEnum.LOG.name().toLowerCase(); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorConfiguration.java b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java similarity index 58% rename from hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorConfiguration.java rename to hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java index 65517a34..9134e189 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorConfiguration.java +++ b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/AdapterThreadPoolMicrometerMonitorHandler.java @@ -15,21 +15,24 @@ * limitations under the License. */ -package cn.hippo4j.springboot.starter.monitor.local.log; +package cn.hippo4j.monitor.micrometer; -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; -import cn.hippo4j.monitor.local.log.LocalLogMonitorHandler; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; +import cn.hippo4j.adapter.base.ThreadPoolAdapterState; +import cn.hippo4j.monitor.base.AbstractAdapterThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; /** - * Local log monitor configuration. + * Adapter thread-pool micrometer monitor handler. */ -@Configuration -public class LocalLogMonitorConfiguration { +public class AdapterThreadPoolMicrometerMonitorHandler extends AbstractAdapterThreadPoolMonitor { - @Bean - public LocalLogMonitorHandler localLogMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new LocalLogMonitorHandler(threadPoolRunStateHandler); + @Override + protected void execute(ThreadPoolAdapterState threadPoolAdapterState) { + + } + + @Override + public String getType() { + return MonitorTypeEnum.MICROMETER.name().toLowerCase(); } } diff --git a/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/MicrometerMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/DynamicThreadPoolMicrometerMonitorHandler.java similarity index 92% rename from hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/MicrometerMonitorHandler.java rename to hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/DynamicThreadPoolMicrometerMonitorHandler.java index 844685b7..5b2cc068 100644 --- a/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/MicrometerMonitorHandler.java +++ b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/DynamicThreadPoolMicrometerMonitorHandler.java @@ -21,7 +21,6 @@ import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; import cn.hippo4j.common.toolkit.BeanUtil; import cn.hippo4j.common.toolkit.CollectionUtil; -import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; import cn.hippo4j.monitor.base.AbstractDynamicThreadPoolMonitor; import cn.hippo4j.monitor.base.MonitorTypeEnum; import io.micrometer.core.instrument.Metrics; @@ -32,9 +31,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** - * Micrometer monitor handler. + * Dynamic thread-pool micrometer monitor handler. */ -public class MicrometerMonitorHandler extends AbstractDynamicThreadPoolMonitor { +public class DynamicThreadPoolMicrometerMonitorHandler extends AbstractDynamicThreadPoolMonitor { private final static String METRIC_NAME_PREFIX = "dynamic.thread-pool"; @@ -44,10 +43,6 @@ public class MicrometerMonitorHandler extends AbstractDynamicThreadPoolMonitor { private final Map RUN_STATE_CACHE = new ConcurrentHashMap<>(); - public MicrometerMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - super(threadPoolRunStateHandler); - } - @Override protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { ThreadPoolRunStateInfo stateInfo = RUN_STATE_CACHE.get(poolRunStateInfo.getTpId()); diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/WebThreadPoolMicrometerMonitorHandler.java similarity index 59% rename from hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java rename to hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/WebThreadPoolMicrometerMonitorHandler.java index 010fd673..01681e1e 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/es/EsMonitorAutoConfiguration.java +++ b/hippo4j-monitor/hippo4j-monitor-micrometer/src/main/java/cn/hippo4j/monitor/micrometer/WebThreadPoolMicrometerMonitorHandler.java @@ -15,21 +15,24 @@ * limitations under the License. */ -package cn.hippo4j.springboot.starter.monitor.es; +package cn.hippo4j.monitor.micrometer; -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; +import cn.hippo4j.common.model.ThreadPoolRunStateInfo; +import cn.hippo4j.monitor.base.AbstractWebThreadPoolMonitor; +import cn.hippo4j.monitor.base.MonitorTypeEnum; /** - * Elastic-search monitor auto configuration. + * Web thread-pool micrometer monitor handler. */ -@Configuration -public class EsMonitorAutoConfiguration { +public class WebThreadPoolMicrometerMonitorHandler extends AbstractWebThreadPoolMonitor { - @Bean - public EsMonitorHandler esMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) { - return new EsMonitorHandler(threadPoolRunStateHandler); + @Override + protected void execute(ThreadPoolRunStateInfo webThreadPoolRunStateInfo) { + + } + + @Override + public String getType() { + return MonitorTypeEnum.MICROMETER.name().toLowerCase(); } } diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java index 46d7c0c7..ebcd1c5b 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/BootstrapConfigProperties.java @@ -46,24 +46,33 @@ public class BootstrapConfigProperties implements BootstrapPropertiesInterface { */ private Boolean banner = Boolean.TRUE; + /** + * Thread pool monitoring related configuration. + */ + private MonitorProperties monitor; + /*** - * Collect thread pool runtime indicators. + * Latest use {@link MonitorProperties#getEnable()} */ + @Deprecated private Boolean collect = Boolean.TRUE; /** - * Type of collection thread pool running data. eg: log,micrometer. Multiple can be used at the same time. + * Latest use {@link MonitorProperties#getCollectTypes()} */ + @Deprecated private String collectType; /** - * Delay starting data acquisition task. unit: ms + * Latest use {@link MonitorProperties#getInitialDelay()} */ + @Deprecated private Long initialDelay = 10000L; /** - * Collect interval. unit: ms + * Latest use {@link MonitorProperties#getCollectInterval()} */ + @Deprecated private Long collectInterval = 5000L; /** diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java index 783a2680..8f59c72b 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java @@ -37,8 +37,8 @@ import cn.hippo4j.message.service.AlarmControlHandler; import cn.hippo4j.message.service.Hippo4jBaseSendMessageService; import cn.hippo4j.message.service.Hippo4jSendMessageService; import cn.hippo4j.springboot.starter.adapter.web.WebAdapterConfiguration; -import cn.hippo4j.springboot.starter.monitor.local.log.LocalLogMonitorConfiguration; -import cn.hippo4j.springboot.starter.monitor.micrometer.MicrometerMonitorConfiguration; +import cn.hippo4j.springboot.starter.monitor.local.log.LocalLogMonitorAutoConfiguration; +import cn.hippo4j.springboot.starter.monitor.micrometer.MicrometerMonitorAutoConfiguration; import lombok.AllArgsConstructor; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -60,7 +60,7 @@ import org.springframework.core.annotation.Order; @ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true") @EnableConfigurationProperties(BootstrapConfigProperties.class) @Import(ConfigHandlerConfiguration.class) -@ImportAutoConfiguration({WebAdapterConfiguration.class, UtilAutoConfiguration.class, MessageConfiguration.class, LocalLogMonitorConfiguration.class, MicrometerMonitorConfiguration.class}) +@ImportAutoConfiguration({WebAdapterConfiguration.class, UtilAutoConfiguration.class, MessageConfiguration.class}) public class DynamicThreadPoolAutoConfiguration { private final BootstrapConfigProperties bootstrapConfigProperties; diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/MonitorProperties.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/MonitorProperties.java new file mode 100644 index 00000000..818ead1c --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/MonitorProperties.java @@ -0,0 +1,53 @@ +/* + * 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.config.springboot.starter.config; + +import cn.hippo4j.monitor.base.MonitorThreadPoolTypeEnum; +import lombok.Data; + +/** + * Thread pool monitoring properties. + */ +@Data +public class MonitorProperties { + + /** + * Collect thread pool runtime indicators. + */ + private Boolean enable = Boolean.TRUE; + + /** + * Type of collection thread pool running data. eg: log,micrometer. Multiple can be used at the same time. + */ + private String collectTypes; + + /** + * Monitor the type of thread pool. eg: dynamic,web,adapter. Can be configured arbitrarily, default dynamic. + */ + private String threadPoolTypes = MonitorThreadPoolTypeEnum.DYNAMIC.toString().toLowerCase(); + + /** + * Delay starting data acquisition task. unit: ms + */ + private Long initialDelay = 10000L; + + /** + * Collect interval. unit: ms + */ + private Long collectInterval = 5000L; +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/elasticsearch/ElasticSearchMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/elasticsearch/ElasticSearchMonitorAutoConfiguration.java new file mode 100644 index 00000000..3f38440f --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/java/cn/hippo4j/springboot/starter/monitor/elasticsearch/ElasticSearchMonitorAutoConfiguration.java @@ -0,0 +1,46 @@ +/* + * 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.elasticsearch; + +import cn.hippo4j.monitor.elasticsearch.AdapterThreadPoolElasticSearchMonitorHandler; +import cn.hippo4j.monitor.elasticsearch.DynamicThreadPoolElasticSearchMonitorHandler; +import cn.hippo4j.monitor.elasticsearch.WebThreadPoolElasticSearchMonitorHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Elastic-search monitor auto configuration. + */ +@Configuration +public class ElasticSearchMonitorAutoConfiguration { + + @Bean + public DynamicThreadPoolElasticSearchMonitorHandler dynamicThreadPoolElasticSearchMonitorHandler() { + return new DynamicThreadPoolElasticSearchMonitorHandler(); + } + + @Bean + public WebThreadPoolElasticSearchMonitorHandler webThreadPoolElasticSearchMonitorHandler() { + return new WebThreadPoolElasticSearchMonitorHandler(); + } + + @Bean + public AdapterThreadPoolElasticSearchMonitorHandler adapterThreadPoolElasticSearchMonitorHandler() { + return new AdapterThreadPoolElasticSearchMonitorHandler(); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring.factories index 325fc0aa..3239d90b 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring.factories +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.es.EsMonitorAutoConfiguration +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.elasticsearch.ElasticSearchMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java new file mode 100644 index 00000000..f02d7ad8 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/java/cn/hippo4j/springboot/starter/monitor/local/log/LocalLogMonitorAutoConfiguration.java @@ -0,0 +1,46 @@ +/* + * 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.local.log; + +import cn.hippo4j.monitor.local.log.AdapterThreadPoolLocalLogMonitorHandler; +import cn.hippo4j.monitor.local.log.DynamicThreadPoolLocalLogMonitorHandler; +import cn.hippo4j.monitor.local.log.WebThreadPoolLocalLogMonitorHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Local log monitor auto configuration. + */ +@Configuration +public class LocalLogMonitorAutoConfiguration { + + @Bean + public DynamicThreadPoolLocalLogMonitorHandler dynamicThreadPoolLocalLogMonitorHandler() { + return new DynamicThreadPoolLocalLogMonitorHandler(); + } + + @Bean + public WebThreadPoolLocalLogMonitorHandler webThreadPoolLocalLogMonitorHandler() { + return new WebThreadPoolLocalLogMonitorHandler(); + } + + @Bean + public AdapterThreadPoolLocalLogMonitorHandler adapterThreadPoolLocalLogMonitorHandler() { + return new AdapterThreadPoolLocalLogMonitorHandler(); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..b1af5e04 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.local.log.LocalLogMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java new file mode 100644 index 00000000..d6dd3a44 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/java/cn/hippo4j/springboot/starter/monitor/micrometer/MicrometerMonitorAutoConfiguration.java @@ -0,0 +1,46 @@ +/* + * 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.micrometer; + +import cn.hippo4j.monitor.micrometer.AdapterThreadPoolMicrometerMonitorHandler; +import cn.hippo4j.monitor.micrometer.DynamicThreadPoolMicrometerMonitorHandler; +import cn.hippo4j.monitor.micrometer.WebThreadPoolMicrometerMonitorHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Micrometer monitor auto configuration. + */ +@Configuration +public class MicrometerMonitorAutoConfiguration { + + @Bean + public DynamicThreadPoolMicrometerMonitorHandler dynamicThreadPoolMicrometerMonitorHandler() { + return new DynamicThreadPoolMicrometerMonitorHandler(); + } + + @Bean + public WebThreadPoolMicrometerMonitorHandler webThreadPoolMicrometerMonitorHandler() { + return new WebThreadPoolMicrometerMonitorHandler(); + } + + @Bean + public AdapterThreadPoolMicrometerMonitorHandler adapterThreadPoolMicrometerMonitorHandler() { + return new AdapterThreadPoolMicrometerMonitorHandler(); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..6e626350 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.micrometer.MicrometerMonitorAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml index 0aaf46c7..70131d65 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/pom.xml @@ -8,41 +8,34 @@ ${revision} hippo4j-spring-boot-starter - Thread pool dynamic parameter adjustment, alarming, status viewing and monitoring functions org.springframework.boot spring-boot-starter - org.springframework.boot spring-boot-starter-web - cn.hippo4j hippo4j-core - cn.hippo4j hippo4j-common ${revision} - org.springframework.boot spring-boot-configuration-processor true - org.projectlombok lombok - com.aliyun alibaba-dingtalk-service-sdk @@ -55,79 +48,41 @@ - org.springframework.boot spring-boot-starter-tomcat compile true - org.springframework.boot spring-boot-starter-jetty compile true - org.springframework.boot spring-boot-starter-undertow compile true - cn.hippo4j hippo4j-adapter-base - io.netty netty-all - cn.hippo4j hippo4j-spring-boot-starter-adapter-web ${revision} - cn.hippo4j hippo4j-monitor-base ${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 - - - - - -