|
|
|
@ -1,16 +1,18 @@
|
|
|
|
|
<div align=center>
|
|
|
|
|
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/Dynamic-Thread-Pool-Main.jpeg" />
|
|
|
|
|
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/Dynamic-Thread-Pool-Main.jpeg" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p align="center">
|
|
|
|
|
<strong> :fire: 动态线程池(DTP)系统,包含 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-server">Server</a> 端及 SpringBoot Client 端需引入的 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-spring-boot-starter">Starter</a>.</strong>
|
|
|
|
|
<strong> :fire: 动态线程池(DTP)系统,包含 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-server">Server</a> 端及 SpringBoot Client 端需引入的 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-spring-boot-starter">Starter</a>.</strong>
|
|
|
|
|
</p>
|
|
|
|
|
<p align="center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/Author-龙台-blue.svg" />
|
|
|
|
|
|
|
|
|
|
<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg4NDU0Mjk5OQ==&mid=100007311&idx=1&sn=d325c1a509d6ee89469a1134ac0a8cf5&chksm=4fb7c6f778c04fe111e9cf52723675b8e8cbbbf9e848741a5d9c20620ff6c778b6613e021a34&scene=18#wechat_redirect">
|
|
|
|
|
<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg4NDU0Mjk5OQ==&mid=100007373&idx=1&sn=3b375f97a576820e3e540810e720aeb0&chksm=4fb7c6b578c04fa35fab488d8dd6ddd12cfd0ef70290f3b285261fba0750785ea2725a50d508&scene=18#wechat_redirect">
|
|
|
|
|
<img src="https://img.shields.io/badge/公众号-龙台 blog-yellow.svg" />
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
@ -25,8 +27,8 @@
|
|
|
|
|
<img src="https://img.shields.io/badge/JDK-1.8+-green?logo=appveyor" />
|
|
|
|
|
|
|
|
|
|
<img src="https://tokei.rs/b1/github/acmenlt/dynamic-threadpool?category=lines" />
|
|
|
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/release-v0.2.0-violet.svg" />
|
|
|
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/version-v0.3.0-DeepSkyBlue.svg" />
|
|
|
|
|
|
|
|
|
|
<img src="https://img.shields.io/github/stars/acmenlt/dynamic-threadpool.svg" />
|
|
|
|
|
|
|
|
|
@ -40,7 +42,8 @@
|
|
|
|
|
|
|
|
|
|
[美团线程池文章](https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html) 介绍中,因为业务对线程池参数没有合理配置,触发过几起生产事故,进而引发了一系列思考。最终决定封装线程池动态参数调整,扩展线程池监控以及消息报警等功能
|
|
|
|
|
|
|
|
|
|
笔者不是一个喜欢重复造轮子的 Coder,因为美团没有开源动态线程池系统,所以选择造一个轻量级的轮子
|
|
|
|
|
笔者不喜欢重复造轮子,因为美团并没有开源动态线程池系统,所以选择造一个轻量级的轮子
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
@ -101,7 +104,7 @@ DTP 系统很好解决了这个问题,它将业务中所有线程池统一管
|
|
|
|
|
"ignore": "tenantId、itemId、tpId 代表唯一线程池,请不要修改",
|
|
|
|
|
"tenantId": "common",
|
|
|
|
|
"itemId": "message-center",
|
|
|
|
|
"tpId": "custom-pool",
|
|
|
|
|
"tpId": "message-produce",
|
|
|
|
|
"coreSize": 10,
|
|
|
|
|
"maxSize": 15,
|
|
|
|
|
"queueType": 9,
|
|
|
|
@ -120,18 +123,64 @@ DTP 系统很好解决了这个问题,它将业务中所有线程池统一管
|
|
|
|
|
接口调用成功后,观察 dynamic-threadpool-example 控制台日志输出,日志输出包括不限于此信息即为成功
|
|
|
|
|
|
|
|
|
|
```tex
|
|
|
|
|
[🔥 CUSTOM-POOL] Changed thread pool. coreSize :: [11=>10], maxSize :: [15=>15], queueType :: [9=>9]
|
|
|
|
|
[🔥 MESSAGE-PRODUCE] Changed thread pool. coreSize :: [11=>10], maxSize :: [15=>15], queueType :: [9=>9]
|
|
|
|
|
capacity :: [100=>100], keepAliveTime :: [10000=>10000], rejectedType :: [7=>7]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
现阶段仅集成钉钉消息推送,后续会持续接入企业微信、邮箱、飞书、短信等通知渠道
|
|
|
|
|
|
|
|
|
|
<table>
|
|
|
|
|
<tr>
|
|
|
|
|
<td align="center" style="width: 200px;">
|
|
|
|
|
<a href="https://github.com/acmenlt">
|
|
|
|
|
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211013122816688.png" style="width: 400px;"><br>
|
|
|
|
|
<sub>配置变更</sub>
|
|
|
|
|
</a><br>
|
|
|
|
|
</td>
|
|
|
|
|
<td align="center" style="width: 200px;">
|
|
|
|
|
<a href="https://github.com/acmenlt">
|
|
|
|
|
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211013113649068.png" style="width: 400px;"><br>
|
|
|
|
|
<sub>告警发送</sub>
|
|
|
|
|
</a><br>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
项目代码功能还在持续开发,初定发布 1.0.0 RELEASE 完成以下功能。部署了 Server 服务,只需要引入 Starter 模块到业务系统中,即可完成动态修改、监控、报警等特性,敬请期待
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
## 查看源码能收获什么?
|
|
|
|
|
|
|
|
|
|
DTP 项目还没有发布 Release 版本,小伙伴可以阅读框架源码,查看框架中好的设计理念或者编码技巧
|
|
|
|
|
|
|
|
|
|
在项目开发过程中,借鉴了 Nacos、Eureka、Seata、ShardingSphere 等中间件项目的优雅设计
|
|
|
|
|
|
|
|
|
|
- 配置“实时”刷新:参考 Nacos 1.x 配置中心的长轮询模型,Server 端修改线程池配置,Client 端“实时”刷新
|
|
|
|
|
- Client 实例集群注册 Server:参考 Eureka 1.x 节点注册、续约、下线等设计,完成 Server 端查看 Client 端的应用实例情况,以此实现线程池运行状态的实时查看
|
|
|
|
|
- ShardingSphere 对 SPI 机制的封装,自定义加载、创建、注册等逻辑,自定义 ServiceLoader 异常信息
|
|
|
|
|
- ......
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
从框架本身的编码来说,可能对大家有帮助的技术点
|
|
|
|
|
|
|
|
|
|
- 设计模式的应用:SPI 设计、模版方法模式、Builder 模式、工厂模式、策略模式、责任链模式等
|
|
|
|
|
- Spring 后置处理器(BeanPostProcessor),注册 Client 端线程池以及订阅 Server 端配置变更
|
|
|
|
|
- 线程池监控报警,触发报警的维度:线程池活跃度、阻塞队列容量、拒绝策略执行等
|
|
|
|
|
- ......
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 最后
|
|
|
|
|
|
|
|
|
|
笔者是个有代码洁癖的程序员,DTP 项目中的代码开发完全遵守阿里巴巴代码规约,也推荐大家使用
|
|
|
|
|
笔者是个有代码洁癖的程序员,项目中的代码开发完全遵守阿里巴巴代码规约,也推荐大家使用,培养好的编码习惯
|
|
|
|
|
|
|
|
|
|
如果小伙伴看到这里,觉得项目功能规划、代码设计还不错的话,辛苦点个 🚀 Star ,方便后续查看,祝好。
|
|
|
|
|