Pārlūkot izejas kodu

feat:

1. 修改线上环境线程池配置;
tags/24111501^0
WendyYang pirms 1 mēnesi
vecāks
revīzija
25768282a0
7 mainītis faili ar 38 papildinājumiem un 5 dzēšanām
  1. +7
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalExceptionHandler.java
  2. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/basic/AbstractRegionCacheHelper.java
  3. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java
  4. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java
  5. +6
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java
  6. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/user/helper/impl/MhUnitCacheImpl.java
  7. +5
    -4
      hz-pm-api/src/main/resources/application-prod.yml

+ 7
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalExceptionHandler.java Parādīt failu

@@ -5,6 +5,7 @@ import com.ningdatech.basic.enumeration.Status;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.ApiResponse;
import com.ningdatech.basic.util.CollUtils;
import com.wflow.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpStatus;
@@ -84,4 +85,10 @@ public class GlobalExceptionHandler {
return ApiResponse.of(ERROR_CODE, e.getMessage());
}

@ResponseBody
@ExceptionHandler(value = BusinessException.class)
public ApiResponse<Void> catchException(BusinessException e) {
return ApiResponse.of(ERROR_CODE, e.getMessage());
}

}

+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/basic/AbstractRegionCacheHelper.java Parādīt failu

@@ -1,5 +1,6 @@
package com.hz.pm.api.common.helper.basic;

import cn.hutool.core.date.StopWatch;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.collect.Lists;
@@ -68,7 +69,11 @@ public abstract class AbstractRegionCacheHelper implements InitializingBean {
return RegionConverter.toRegionDTO(region);
});
// 初始化所有区域数据到缓存
StopWatch watch = new StopWatch();
watch.start();
initRegionCache();
watch.stop();
log.info("初始化区域缓存耗时:{} ms", watch.getTotalTimeMillis());
}

public String getParentCodeRoot() {


+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java Parādīt failu

@@ -2,6 +2,7 @@ package com.hz.pm.api.meta.helper.basic;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.date.StopWatch;
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
@@ -66,10 +67,14 @@ public abstract class AbstractDictionaryCache implements InitializingBean, Dicti
}

private void initAllDicts() {
StopWatch watch = new StopWatch();
watch.start();
List<String> dictTypes = Arrays.stream(DictTypeEnum.values())
.map(DictTypeEnum::getKey)
.collect(Collectors.toList());
dictCache.getAll(dictTypes);
watch.stop();
log.info("初始化字典数据耗时:{} ms", watch.getTotalTimeMillis());
}

}

+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java Parādīt failu

@@ -2,6 +2,7 @@ package com.hz.pm.api.meta.helper.basic;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.NumberUtil;
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -102,10 +103,14 @@ public abstract class AbstractTagsCache implements InitializingBean, TagCache {
}

public void initAllTags() {
StopWatch watch = new StopWatch();
watch.start();
List<String> allLevels = Arrays.stream(NumberUtil.range(1, MAX_LEVEL))
.mapToObj(String::valueOf)
.collect(Collectors.toList());
tagsCache.getAll(allLevels);
watch.stop();
log.info("初始化标签树耗时:{} ms", watch.getTotalTimeMillis());
}

protected List<TagTreeDTO> getChildren(String tagCode, List<TagTreeDTO> list) {


+ 6
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java Parādīt failu

@@ -1,5 +1,6 @@
package com.hz.pm.api.projectdeclared.utils;

import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -45,12 +46,16 @@ public class ProjectIdCodeCacheUtil {

@PostConstruct
public void initProjectIdCodeCache() {
StopWatch watch = new StopWatch();
watch.start();
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class)
.select(Project::getProjectCode, Project::getId, Project::getCreateOn, Project::getNewest);
for (Project project : projectService.list(query)) {
put(project.getId(), project, false);
}
log.info("初始化项目ID编码缓存:{}", CACHE.size());
watch.stop();
log.info("初始化项目ID编码缓存耗时:{} ms", watch.getTotalTimeMillis());
log.info("初始化项目ID编码缓存:{} 个", CACHE.size());
}

//==================================================================================================================


+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/user/helper/impl/MhUnitCacheImpl.java Parādīt failu

@@ -3,6 +3,7 @@ package com.hz.pm.api.user.helper.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.lang.Assert;
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -96,7 +97,11 @@ public class MhUnitCacheImpl implements MhUnitCache, InitializingBean {
}
});
// 初始化所有单位
StopWatch watch = new StopWatch();
watch.start();
cache.getAll(Collections.singletonList(ALL));
watch.stop();
log.info("初始化单位缓存耗时:{} ms", watch.getTotalTimeMillis());
}

@Override


+ 5
- 4
hz-pm-api/src/main/resources/application-prod.yml Parādīt failu

@@ -96,6 +96,7 @@ nd:
log:
enabled: true
type: DB
keep-days: 365
# 文件存储
file:
storage-type: ALI_OSS
@@ -235,20 +236,20 @@ thread-pool-util:
keep-alive-seconds: 120
thread-name-prefix: request-executor-
scheduler:
core-pool-size: 4
core-pool-size: 3
thread-name-prefix: scheduler-executor-

# 工作流线程池配置
wflow-thread-pool-util:
scheduler:
core-pool-size: 4
core-pool-size: 3
thread-name-prefix: wflow-thread-scheduler-
executor:
core-pool-size: 4
core-pool-size: 3
thread-name-prefix: wflow-thread-executor-
queue-capacity: 300
keep-alive-seconds: 120
max-pool-size: 8
max-pool-size: 6
random-invite:
thread-pool-properties:
core-pool-size: 3


Notiek ielāde…
Atcelt
Saglabāt