|
|
@ -23,36 +23,37 @@ import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterCoreNoti
|
|
|
|
import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterServerNotifyParameter;
|
|
|
|
import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterServerNotifyParameter;
|
|
|
|
import cn.hippo4j.common.toolkit.JSONUtil;
|
|
|
|
import cn.hippo4j.common.toolkit.JSONUtil;
|
|
|
|
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
|
|
|
|
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.executor.support.QueueTypeEnum;
|
|
|
|
|
|
|
|
import cn.hippo4j.core.executor.support.RejectedTypeEnum;
|
|
|
|
import cn.hippo4j.message.enums.NotifyPlatformEnum;
|
|
|
|
import cn.hippo4j.message.enums.NotifyPlatformEnum;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Register dynamic thread-pool test.
|
|
|
|
* Register dynamic thread-pool test.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Component
|
|
|
|
|
|
|
|
public class RegisterDynamicThreadPoolTest {
|
|
|
|
public class RegisterDynamicThreadPoolTest {
|
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
public static ThreadPoolExecutor registerDynamicThreadPool(String threadPoolId) {
|
|
|
|
public void registerDynamicThreadPool() {
|
|
|
|
DynamicThreadPoolRegisterParameter parameterInfo = DynamicThreadPoolRegisterParameter.builder()
|
|
|
|
String threadPoolId = "register-dynamic-thread-pool";
|
|
|
|
.corePoolSize(3)
|
|
|
|
DynamicThreadPoolRegisterParameter parameterInfo = new DynamicThreadPoolRegisterParameter();
|
|
|
|
.maximumPoolSize(10)
|
|
|
|
parameterInfo.setThreadPoolId(threadPoolId);
|
|
|
|
.queueType(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.type)
|
|
|
|
parameterInfo.setThreadNamePrefix(threadPoolId);
|
|
|
|
.capacity(110)
|
|
|
|
parameterInfo.setCorePoolSize(3);
|
|
|
|
// TimeUnit.SECONDS
|
|
|
|
parameterInfo.setMaximumPoolSize(14);
|
|
|
|
.keepAliveTime(100L)
|
|
|
|
parameterInfo.setQueueType(9);
|
|
|
|
// TimeUnit.MILLISECONDS
|
|
|
|
parameterInfo.setCapacity(110);
|
|
|
|
.executeTimeOut(800L)
|
|
|
|
parameterInfo.setKeepAliveTime(110L);
|
|
|
|
.rejectedType(RejectedTypeEnum.ABORT_POLICY.type)
|
|
|
|
parameterInfo.setRejectedType(2);
|
|
|
|
.isAlarm(true)
|
|
|
|
parameterInfo.setIsAlarm(0);
|
|
|
|
.capacityAlarm(80)
|
|
|
|
parameterInfo.setCapacityAlarm(90);
|
|
|
|
.activeAlarm(80)
|
|
|
|
parameterInfo.setActiveAlarm(90);
|
|
|
|
.threadPoolId(threadPoolId)
|
|
|
|
parameterInfo.setAllowCoreThreadTimeOut(Boolean.TRUE);
|
|
|
|
.threadNamePrefix(threadPoolId)
|
|
|
|
|
|
|
|
.allowCoreThreadTimeOut(true)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
// Core mode and server mode, you can choose one of them.
|
|
|
|
// Core mode and server mode, you can choose one of them.
|
|
|
|
DynamicThreadPoolRegisterCoreNotifyParameter coreNotifyParameter = DynamicThreadPoolRegisterCoreNotifyParameter.builder()
|
|
|
|
DynamicThreadPoolRegisterCoreNotifyParameter coreNotifyParameter = DynamicThreadPoolRegisterCoreNotifyParameter.builder()
|
|
|
|
.activeAlarm(80)
|
|
|
|
.activeAlarm(80)
|
|
|
@ -74,5 +75,6 @@ public class RegisterDynamicThreadPoolTest {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
ThreadPoolExecutor dynamicThreadPool = GlobalThreadPoolManage.dynamicRegister(registerWrapper);
|
|
|
|
ThreadPoolExecutor dynamicThreadPool = GlobalThreadPoolManage.dynamicRegister(registerWrapper);
|
|
|
|
log.info("Dynamic registration thread pool parameter details: {}", JSONUtil.toJSONString(dynamicThreadPool));
|
|
|
|
log.info("Dynamic registration thread pool parameter details: {}", JSONUtil.toJSONString(dynamicThreadPool));
|
|
|
|
|
|
|
|
return dynamicThreadPool;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|