Refactor dynamic thread pool registration variable naming

pull/916/head
chen.ma 2 years ago
parent a9cd485502
commit 2f4c8bedbe

@ -38,7 +38,7 @@ public class DynamicThreadPoolRegisterWrapper {
/**
* Dynamic thread-pool register parameter
*/
private DynamicThreadPoolRegisterParameter dynamicThreadPoolRegisterParameter;
private DynamicThreadPoolRegisterParameter parameter;
// Hippo4j server ----------------------------------------------------------------------
@ -65,12 +65,12 @@ public class DynamicThreadPoolRegisterWrapper {
/**
* Dynamic thread-pool server notify parameter
*/
private DynamicThreadPoolRegisterServerNotifyParameter dynamicThreadPoolRegisterServerNotifyParameter;
private DynamicThreadPoolRegisterServerNotifyParameter serverNotify;
// Hippo4j core ----------------------------------------------------------------------
/**
* Dynamic thread-pool core notify parameter
* Dynamic thread-pool config notify parameter
*/
private DynamicThreadPoolRegisterCoreNotifyParameter dynamicThreadPoolRegisterCoreNotifyParameter;
private DynamicThreadPoolRegisterCoreNotifyParameter configNotify;
}

@ -68,9 +68,9 @@ public class RegisterDynamicThreadPoolTest {
DynamicThreadPoolRegisterWrapper registerWrapper = DynamicThreadPoolRegisterWrapper.builder()
.updateIfExists(true)
.notifyUpdateIfExists(true)
.dynamicThreadPoolRegisterParameter(parameterInfo)
.dynamicThreadPoolRegisterCoreNotifyParameter(coreNotifyParameter)
.dynamicThreadPoolRegisterServerNotifyParameter(serverNotifyParameter)
.parameter(parameterInfo)
.configNotify(coreNotifyParameter)
.serverNotify(serverNotifyParameter)
.build();
ThreadPoolExecutor dynamicThreadPool = GlobalThreadPoolManage.dynamicRegister(registerWrapper);
log.info("Dynamic registration thread pool parameter details: {}", JSONUtil.toJSONString(dynamicThreadPool));

@ -151,7 +151,7 @@ public class ConfigServiceImpl implements ConfigService {
ConfigServiceImpl configService = ApplicationContextHolder.getBean(this.getClass());
configService.updateConfigInfo(null, false, configAllInfo);
}
DynamicThreadPoolRegisterServerNotifyParameter serverNotifyParameter = registerWrapper.getDynamicThreadPoolRegisterServerNotifyParameter();
DynamicThreadPoolRegisterServerNotifyParameter serverNotifyParameter = registerWrapper.getServerNotify();
if (serverNotifyParameter != null) {
ArrayList<String> notifyTypes = new ArrayList<>();
Collections.addAll(notifyTypes, "CONFIG", "ALARM");
@ -177,7 +177,7 @@ public class ConfigServiceImpl implements ConfigService {
}
private ConfigAllInfo parseConfigAllInfo(DynamicThreadPoolRegisterWrapper registerWrapper) {
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getDynamicThreadPoolRegisterParameter();
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getParameter();
ConfigAllInfo configAllInfo = JSONUtil.parseObject(JSONUtil.toJSONString(registerParameter), ConfigAllInfo.class);
configAllInfo.setTenantId(registerWrapper.getTenantId());
configAllInfo.setItemId(registerWrapper.getItemId());

@ -39,29 +39,26 @@ public class DynamicThreadPoolConfigService extends AbstractDynamicThreadPoolSer
@Override
public ThreadPoolExecutor registerDynamicThreadPool(DynamicThreadPoolRegisterWrapper registerWrapper) {
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getDynamicThreadPoolRegisterParameter();
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getParameter();
String threadPoolId = registerParameter.getThreadPoolId();
ThreadPoolExecutor dynamicThreadPoolExecutor = buildDynamicThreadPoolExecutor(registerParameter);
DynamicThreadPoolWrapper dynamicThreadPoolWrapper = DynamicThreadPoolWrapper.builder()
.threadPoolId(threadPoolId)
.executor(dynamicThreadPoolExecutor)
.build();
// Register pool.
GlobalThreadPoolManage.registerPool(threadPoolId, dynamicThreadPoolWrapper);
ExecutorProperties executorProperties = buildExecutorProperties(registerWrapper);
// Register properties.
GlobalCoreThreadPoolManage.register(threadPoolId, executorProperties);
DynamicThreadPoolRegisterCoreNotifyParameter notifyParameter = registerWrapper.getDynamicThreadPoolRegisterCoreNotifyParameter();
DynamicThreadPoolRegisterCoreNotifyParameter notifyParameter = registerWrapper.getConfigNotify();
ThreadPoolNotifyAlarm notifyAlarm = new ThreadPoolNotifyAlarm(true, registerParameter.getActiveAlarm(), registerParameter.getCapacityAlarm());
notifyAlarm.setReceives(notifyParameter.getReceives());
notifyAlarm.setInterval(notifyParameter.getInterval());
// Register notify.
GlobalNotifyAlarmManage.put(threadPoolId, notifyAlarm);
return dynamicThreadPoolExecutor;
}
private ExecutorProperties buildExecutorProperties(DynamicThreadPoolRegisterWrapper registerWrapper) {
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getDynamicThreadPoolRegisterParameter();
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getParameter();
ExecutorProperties executorProperties = ExecutorProperties.builder()
.corePoolSize(registerParameter.getCorePoolSize())
.maximumPoolSize(registerParameter.getMaximumPoolSize())

@ -73,7 +73,7 @@ public class DynamicThreadPoolConfigService extends AbstractDynamicThreadPoolSer
}
private ThreadPoolExecutor registerExecutor(DynamicThreadPoolRegisterWrapper registerWrapper) {
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getDynamicThreadPoolRegisterParameter();
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getParameter();
checkThreadPoolParameter(registerParameter);
String threadPoolId = registerParameter.getThreadPoolId();
try {
@ -98,11 +98,11 @@ public class DynamicThreadPoolConfigService extends AbstractDynamicThreadPoolSer
}
private void subscribeConfig(DynamicThreadPoolRegisterWrapper registerWrapper) {
dynamicThreadPoolSubscribeConfig.subscribeConfig(registerWrapper.getDynamicThreadPoolRegisterParameter().getThreadPoolId());
dynamicThreadPoolSubscribeConfig.subscribeConfig(registerWrapper.getParameter().getThreadPoolId());
}
private void putNotifyAlarmConfig(DynamicThreadPoolRegisterWrapper registerWrapper) {
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getDynamicThreadPoolRegisterParameter();
DynamicThreadPoolRegisterParameter registerParameter = registerWrapper.getParameter();
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm(
BooleanUtil.toBoolean(String.valueOf(registerParameter.getIsAlarm())),
registerParameter.getActiveAlarm(),

@ -156,7 +156,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
.rejectedPolicyType(RejectedPolicyTypeEnum.getRejectedPolicyTypeEnumByName(executor.getRejectedExecutionHandler().getClass().getSimpleName()))
.build();
DynamicThreadPoolRegisterWrapper registerWrapper = DynamicThreadPoolRegisterWrapper.builder()
.dynamicThreadPoolRegisterParameter(parameterInfo)
.parameter(parameterInfo)
.build();
GlobalThreadPoolManage.dynamicRegister(registerWrapper);
}

Loading…
Cancel
Save