feat(config): thread pool config
参数调整
This commit is contained in:
parent
cd70e660a8
commit
31817f6934
@ -1,5 +1,6 @@
|
||||
package cn.axzo.tyr.server.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -13,14 +14,27 @@ import java.util.concurrent.TimeUnit;
|
||||
* @date 2023/10/14 15:23
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class ExecutorConfig {
|
||||
|
||||
/**
|
||||
* 权限定制线程池
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ExecutorService serviceExecutor() {
|
||||
public ExecutorService authExecutor() {
|
||||
new ThreadPoolExecutor.CallerRunsPolicy();
|
||||
int coreSize = Runtime.getRuntime()
|
||||
.availableProcessors() < 4 ? Runtime.getRuntime().availableProcessors() * 4
|
||||
: Runtime.getRuntime().availableProcessors();
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(coreSize, coreSize * 2, 60, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<>(1 << 8), r -> new Thread(r, "TYR-SERVICE-EXECUTOR"));
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(coreSize, coreSize * 4, 60, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<>(1), r -> new Thread(r, "TYR-AUTH-EXECUTOR"), new ThreadPoolExecutor.CallerRunsPolicy() {
|
||||
@Override
|
||||
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
|
||||
log.warn("auth executor rejected , use caller runs");
|
||||
super.rejectedExecution(r, executor);
|
||||
}
|
||||
});
|
||||
executor.prestartCoreThread();
|
||||
return executor;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
private final RoleService roleService;
|
||||
private final RoleUserService roleUserService;
|
||||
private final ServicePkgClient servicePkgClient;
|
||||
@Qualifier("serviceExecutor")
|
||||
@Qualifier("authExecutor")
|
||||
private final Executor executor;
|
||||
private final ProductFeatureRelationService productFeatureRelationService;
|
||||
private final PermissionPointService permissionPointService;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user