update:优化线程池

This commit is contained in:
tiansh
2024-01-26 09:13:42 +08:00
parent bfa41ac049
commit 369b88ffb3
4 changed files with 21 additions and 11 deletions
+7 -3
View File
@@ -39,11 +39,14 @@
[Core版](https://hellohao.cn):开源版的基础上增加`Backblaze(B2)` 并且可`同个对象存储商家`可开多个存储源(可添加至90+存储源)
### 更新日志 `20240111`
### 更新日志 `20240124`
- 新增支持对接WebDAV存储源
- 修复本地存储源上传失败的情况
- 修复某些存储源目录创建不正确的问题
- 优化页面部分提示
- 修复潜在的一些安全隐患
### 主要功能
@@ -151,6 +154,8 @@
更多部署教程参考程序[相关文档](http://doc.hellohao.cn)
更强大的功能可[购买Core版](http://tbed.hellohao.cn/pay)程序
### 启动项目
> 访问你的前端域名即可
@@ -186,7 +191,7 @@
![Hellohao图像托管](https://hellohao.cn/newassets/img/twechat.png)
[//]: # (![Hellohao图像托管](https://upload.cc/i1/2022/03/28/Vnp0bT.png))
[//]: # "![Hellohao图像托管](https://upload.cc/i1/2022/03/28/Vnp0bT.png)"
### 运行环境
@@ -233,4 +238,3 @@ Hellohao图像托管已申请[**中国国家版权局计算机软件著作权**]
**如需程序定制或其他业务,请与我们取得联系**
[Hellohao图像托管官网](http://hellohao.cn)
@@ -16,9 +16,9 @@ public class PoolConfig {
@Bean(name = "taskExecutor")
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(properties.getCorePoolSize());
executor.setMaxPoolSize(properties.getMaxPoolSize());
executor.setQueueCapacity(properties.getQueueCapacity());
executor.setCorePoolSize(properties.getCorePoolSize()); //设置核心线程数
executor.setMaxPoolSize(properties.getMaxPoolSize()); //设置最大线程数
executor.setQueueCapacity(properties.getQueueCapacity()); //设置队列容量
executor.setThreadNamePrefix(properties.getThreadNamePrefix());
executor.setKeepAliveSeconds(properties.getKeepAliveTime());
executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown());
@@ -42,7 +42,7 @@ public class PoolConfig {
private int corePoolSize = 5;
private int maxPoolSize = 50;
private int keepAliveTime = 15;
private int queueCapacity = 6;
private int queueCapacity = 10;
private String threadNamePrefix = "Tbed-Thread";
private boolean allowCoreThreadTimeout = false;
private boolean waitForTasksToCompleteOnShutdown = false;
@@ -11,6 +11,8 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -26,12 +28,11 @@ import java.util.*;
* @date 2021/10/28 16:38
*/
@Service
@EnableAsync
public class ClientService {
private static Logger logger = LoggerFactory.getLogger(ClientService.class);
@Autowired
ConfdataService confdataService;
@Autowired
SysConfigService sysConfigService;
@Autowired private ConfdataService confdataService;
@Autowired private SysConfigService sysConfigService;
@Autowired private UserMapper userMapper;
@Autowired private KeysMapper keysMapper;
@Autowired private UploadConfigMapper uploadConfigMapper;
@@ -40,6 +41,7 @@ public class ClientService {
@Autowired private GetSource getSource;
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
@Async("taskExecutor")
public Msg uploadImg(
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
Msg msg = new Msg();
@@ -18,6 +18,8 @@ import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@@ -33,6 +35,7 @@ import java.util.concurrent.CompletableFuture;
* @date 2020/1/9 15:46
*/
@Service
@EnableAsync
public class UploadServicel {
private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
@Autowired
@@ -48,6 +51,7 @@ public class UploadServicel {
@Autowired deleImages deleimages;
@Autowired ImgViolationJudgeServiceImpl imgViolationJudgeService;
@Async("taskExecutor")
public Msg uploadForLoc(
HttpServletRequest request,
File file,