|
|
|
@ -68,7 +68,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BootstrapCoreProperties bindableCoreProperties = BootstrapCorePropertiesBinderAdapt.bootstrapCorePropertiesBinder(configInfo, bootstrapCoreProperties);
|
|
|
|
|
|
|
|
|
|
// web pool
|
|
|
|
|
refreshWebExecutor(bindableCoreProperties);
|
|
|
|
|
// platforms
|
|
|
|
@ -87,7 +86,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
executorProperties.getNotify().getCapacityAlarm(),
|
|
|
|
|
executorProperties.getNotify().getActiveAlarm()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval());
|
|
|
|
|
threadPoolNotifyAlarm.setReceives(executorProperties.receives());
|
|
|
|
|
GlobalNotifyAlarmManage.put(executorProperties.getThreadPoolId(), threadPoolNotifyAlarm);
|
|
|
|
@ -106,7 +104,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
if (isNullFlag) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
PoolParameterInfo nowParameter = buildWebPoolParameter(bindableCoreProperties);
|
|
|
|
|
if (nowParameter != null) {
|
|
|
|
@ -116,7 +113,7 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
PoolParameter beforeParameter = webThreadPoolService.getWebThreadPoolParameter();
|
|
|
|
|
if (!Objects.equals(beforeParameter.getCoreSize(), nowParameter.getCoreSize())
|
|
|
|
|
|| !Objects.equals(beforeParameter.getMaxSize(), nowParameter.getMaxSize())
|
|
|
|
|
|| !Objects.equals(beforeParameter.getMaxSize(), nowParameter.getMaxSize())) {
|
|
|
|
|
|| !Objects.equals(beforeParameter.getKeepAliveTime(), nowParameter.getKeepAliveTime())) {
|
|
|
|
|
webThreadPoolService.updateWebThreadPool(nowParameter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -140,7 +137,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
CoreNotifyConfigBuilder configBuilder = ApplicationContextHolder.getBean(CoreNotifyConfigBuilder.class);
|
|
|
|
|
Map<String, List<NotifyConfigDTO>> notifyConfig = configBuilder.buildSingleNotifyConfig(executor);
|
|
|
|
|
sendMessageService.putPlatform(notifyConfig);
|
|
|
|
|
|
|
|
|
|
wrapper.setInitFlag(Boolean.TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -158,29 +154,11 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
if (!checkConsistency(threadPoolId, properties)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// refresh executor pool
|
|
|
|
|
dynamicRefreshPool(threadPoolId, properties);
|
|
|
|
|
|
|
|
|
|
// old properties
|
|
|
|
|
ExecutorProperties beforeProperties = GlobalCoreThreadPoolManage.getProperties(properties.getThreadPoolId());
|
|
|
|
|
ChangeParameterNotifyRequest changeRequest = new ChangeParameterNotifyRequest();
|
|
|
|
|
changeRequest.setBeforeCorePoolSize(beforeProperties.getCorePoolSize());
|
|
|
|
|
changeRequest.setBeforeMaximumPoolSize(beforeProperties.getMaximumPoolSize());
|
|
|
|
|
changeRequest.setBeforeAllowsCoreThreadTimeOut(beforeProperties.getAllowCoreThreadTimeOut());
|
|
|
|
|
changeRequest.setBeforeKeepAliveTime(beforeProperties.getKeepAliveTime());
|
|
|
|
|
changeRequest.setBlockingQueueName(beforeProperties.getBlockingQueue());
|
|
|
|
|
changeRequest.setBeforeQueueCapacity(beforeProperties.getQueueCapacity());
|
|
|
|
|
changeRequest.setBeforeRejectedName(beforeProperties.getRejectedHandler());
|
|
|
|
|
changeRequest.setBeforeExecuteTimeOut(beforeProperties.getExecuteTimeOut());
|
|
|
|
|
changeRequest.setThreadPoolId(beforeProperties.getThreadPoolId());
|
|
|
|
|
|
|
|
|
|
changeRequest.setNowCorePoolSize(properties.getCorePoolSize());
|
|
|
|
|
changeRequest.setNowMaximumPoolSize(properties.getMaximumPoolSize());
|
|
|
|
|
changeRequest.setNowAllowsCoreThreadTimeOut(properties.getAllowCoreThreadTimeOut());
|
|
|
|
|
changeRequest.setNowKeepAliveTime(properties.getKeepAliveTime());
|
|
|
|
|
changeRequest.setNowQueueCapacity(properties.getQueueCapacity());
|
|
|
|
|
changeRequest.setNowRejectedName(properties.getRejectedHandler());
|
|
|
|
|
changeRequest.setNowExecuteTimeOut(properties.getExecuteTimeOut());
|
|
|
|
|
|
|
|
|
|
// refresh executor properties
|
|
|
|
|
GlobalCoreThreadPoolManage.refresh(threadPoolId, properties);
|
|
|
|
|
log.info(
|
|
|
|
|
"[{}] Changed thread pool. " +
|
|
|
|
@ -204,13 +182,41 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
threadPoolNotifyAlarmHandler.sendPoolConfigChange(changeRequest);
|
|
|
|
|
threadPoolNotifyAlarmHandler.sendPoolConfigChange(newChangeRequest(beforeProperties, properties));
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
log.error("Failed to send change notice. Message :: {}", ex.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct ChangeParameterNotifyRequest instance
|
|
|
|
|
*
|
|
|
|
|
* @param beforeProperties old properties
|
|
|
|
|
* @param properties new properties
|
|
|
|
|
* @return instance
|
|
|
|
|
*/
|
|
|
|
|
private ChangeParameterNotifyRequest newChangeRequest(ExecutorProperties beforeProperties, ExecutorProperties properties) {
|
|
|
|
|
ChangeParameterNotifyRequest changeRequest = new ChangeParameterNotifyRequest();
|
|
|
|
|
changeRequest.setBeforeCorePoolSize(beforeProperties.getCorePoolSize());
|
|
|
|
|
changeRequest.setBeforeMaximumPoolSize(beforeProperties.getMaximumPoolSize());
|
|
|
|
|
changeRequest.setBeforeAllowsCoreThreadTimeOut(beforeProperties.getAllowCoreThreadTimeOut());
|
|
|
|
|
changeRequest.setBeforeKeepAliveTime(beforeProperties.getKeepAliveTime());
|
|
|
|
|
changeRequest.setBlockingQueueName(beforeProperties.getBlockingQueue());
|
|
|
|
|
changeRequest.setBeforeQueueCapacity(beforeProperties.getQueueCapacity());
|
|
|
|
|
changeRequest.setBeforeRejectedName(beforeProperties.getRejectedHandler());
|
|
|
|
|
changeRequest.setBeforeExecuteTimeOut(beforeProperties.getExecuteTimeOut());
|
|
|
|
|
changeRequest.setThreadPoolId(beforeProperties.getThreadPoolId());
|
|
|
|
|
changeRequest.setNowCorePoolSize(properties.getCorePoolSize());
|
|
|
|
|
changeRequest.setNowMaximumPoolSize(properties.getMaximumPoolSize());
|
|
|
|
|
changeRequest.setNowAllowsCoreThreadTimeOut(properties.getAllowCoreThreadTimeOut());
|
|
|
|
|
changeRequest.setNowKeepAliveTime(properties.getKeepAliveTime());
|
|
|
|
|
changeRequest.setNowQueueCapacity(properties.getQueueCapacity());
|
|
|
|
|
changeRequest.setNowRejectedName(properties.getRejectedHandler());
|
|
|
|
|
changeRequest.setNowExecuteTimeOut(properties.getExecuteTimeOut());
|
|
|
|
|
return changeRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check consistency.
|
|
|
|
|
*
|
|
|
|
@ -232,7 +238,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
!Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity())
|
|
|
|
|
&& Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -244,26 +249,21 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
*/
|
|
|
|
|
private void dynamicRefreshPool(String threadPoolId, ExecutorProperties properties) {
|
|
|
|
|
ExecutorProperties beforeProperties = GlobalCoreThreadPoolManage.getProperties(properties.getThreadPoolId());
|
|
|
|
|
|
|
|
|
|
ThreadPoolExecutor executor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor();
|
|
|
|
|
if (!Objects.equals(beforeProperties.getCorePoolSize(), properties.getCorePoolSize())) {
|
|
|
|
|
executor.setCorePoolSize(properties.getCorePoolSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getMaximumPoolSize(), properties.getMaximumPoolSize())) {
|
|
|
|
|
executor.setMaximumPoolSize(properties.getMaximumPoolSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getCorePoolSize(), properties.getCorePoolSize())) {
|
|
|
|
|
executor.setCorePoolSize(properties.getCorePoolSize());
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.equals(beforeProperties.getAllowCoreThreadTimeOut(), properties.getAllowCoreThreadTimeOut())) {
|
|
|
|
|
executor.allowCoreThreadTimeOut(properties.getAllowCoreThreadTimeOut());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getExecuteTimeOut(), properties.getExecuteTimeOut())) {
|
|
|
|
|
if (executor instanceof AbstractDynamicExecutorSupport) {
|
|
|
|
|
((DynamicThreadPoolExecutor) executor).setExecuteTimeOut(properties.getExecuteTimeOut());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getRejectedHandler(), properties.getRejectedHandler())) {
|
|
|
|
|
RejectedExecutionHandler rejectedExecutionHandler = RejectedTypeEnum.createPolicy(properties.getRejectedHandler());
|
|
|
|
|
if (executor instanceof AbstractDynamicExecutorSupport) {
|
|
|
|
@ -272,14 +272,11 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
AtomicLong rejectCount = dynamicExecutor.getRejectCount();
|
|
|
|
|
rejectedExecutionHandler = RejectedProxyUtil.createProxy(rejectedExecutionHandler, threadPoolId, rejectCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
executor.setRejectedExecutionHandler(rejectedExecutionHandler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getKeepAliveTime(), properties.getKeepAliveTime())) {
|
|
|
|
|
executor.setKeepAliveTime(properties.getKeepAliveTime(), TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity())
|
|
|
|
|
&& Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName())) {
|
|
|
|
|
if (executor.getQueue() instanceof ResizableCapacityLinkedBlockIngQueue) {
|
|
|
|
@ -307,15 +304,12 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
|
|
|
|
|
} else if (bindableCoreProperties.getJetty() != null) {
|
|
|
|
|
poolProperties = bindableCoreProperties.getJetty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (poolProperties != null) {
|
|
|
|
|
parameterInfo = new PoolParameterInfo();
|
|
|
|
|
parameterInfo.setCoreSize(poolProperties.getCorePoolSize());
|
|
|
|
|
parameterInfo.setMaxSize(poolProperties.getMaximumPoolSize());
|
|
|
|
|
parameterInfo.setKeepAliveTime(poolProperties.getKeepAliveTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parameterInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|