Code formatting optimization

pull/197/head
chen.ma 3 years ago
parent 92a98ebb50
commit 0393b86f55

@ -68,7 +68,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
} }
BootstrapCoreProperties bindableCoreProperties = BootstrapCorePropertiesBinderAdapt.bootstrapCorePropertiesBinder(configInfo, bootstrapCoreProperties); BootstrapCoreProperties bindableCoreProperties = BootstrapCorePropertiesBinderAdapt.bootstrapCorePropertiesBinder(configInfo, bootstrapCoreProperties);
// web pool // web pool
refreshWebExecutor(bindableCoreProperties); refreshWebExecutor(bindableCoreProperties);
// platforms // platforms
@ -87,7 +86,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
executorProperties.getNotify().getCapacityAlarm(), executorProperties.getNotify().getCapacityAlarm(),
executorProperties.getNotify().getActiveAlarm() executorProperties.getNotify().getActiveAlarm()
); );
threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval()); threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval());
threadPoolNotifyAlarm.setReceives(executorProperties.receives()); threadPoolNotifyAlarm.setReceives(executorProperties.receives());
GlobalNotifyAlarmManage.put(executorProperties.getThreadPoolId(), threadPoolNotifyAlarm); GlobalNotifyAlarmManage.put(executorProperties.getThreadPoolId(), threadPoolNotifyAlarm);
@ -106,7 +104,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
if (isNullFlag) { if (isNullFlag) {
return; return;
} }
try { try {
PoolParameterInfo nowParameter = buildWebPoolParameter(bindableCoreProperties); PoolParameterInfo nowParameter = buildWebPoolParameter(bindableCoreProperties);
if (nowParameter != null) { if (nowParameter != null) {
@ -140,7 +137,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
CoreNotifyConfigBuilder configBuilder = ApplicationContextHolder.getBean(CoreNotifyConfigBuilder.class); CoreNotifyConfigBuilder configBuilder = ApplicationContextHolder.getBean(CoreNotifyConfigBuilder.class);
Map<String, List<NotifyConfigDTO>> notifyConfig = configBuilder.buildSingleNotifyConfig(executor); Map<String, List<NotifyConfigDTO>> notifyConfig = configBuilder.buildSingleNotifyConfig(executor);
sendMessageService.putPlatform(notifyConfig); sendMessageService.putPlatform(notifyConfig);
wrapper.setInitFlag(Boolean.TRUE); wrapper.setInitFlag(Boolean.TRUE);
} }
} }
@ -186,7 +182,7 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
); );
try { try {
threadPoolNotifyAlarmHandler.sendPoolConfigChange(newChangeRequest(beforeProperties,properties)); threadPoolNotifyAlarmHandler.sendPoolConfigChange(newChangeRequest(beforeProperties, properties));
} catch (Throwable ex) { } catch (Throwable ex) {
log.error("Failed to send change notice. Message :: {}", ex.getMessage()); log.error("Failed to send change notice. Message :: {}", ex.getMessage());
} }
@ -194,7 +190,7 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
} }
/** /**
* construct ChangeParameterNotifyRequest instance * Construct ChangeParameterNotifyRequest instance
* *
* @param beforeProperties old properties * @param beforeProperties old properties
* @param properties new properties * @param properties new properties
@ -242,7 +238,6 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
!Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity()) !Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity())
&& Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName()) && Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName())
); );
return result; return result;
} }
@ -254,27 +249,21 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
*/ */
private void dynamicRefreshPool(String threadPoolId, ExecutorProperties properties) { private void dynamicRefreshPool(String threadPoolId, ExecutorProperties properties) {
ExecutorProperties beforeProperties = GlobalCoreThreadPoolManage.getProperties(properties.getThreadPoolId()); ExecutorProperties beforeProperties = GlobalCoreThreadPoolManage.getProperties(properties.getThreadPoolId());
ThreadPoolExecutor executor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor(); ThreadPoolExecutor executor = GlobalThreadPoolManage.getExecutorService(threadPoolId).getExecutor();
if (!Objects.equals(beforeProperties.getMaximumPoolSize(), properties.getMaximumPoolSize())) { if (!Objects.equals(beforeProperties.getMaximumPoolSize(), properties.getMaximumPoolSize())) {
executor.setMaximumPoolSize(properties.getMaximumPoolSize()); executor.setMaximumPoolSize(properties.getMaximumPoolSize());
} }
if (!Objects.equals(beforeProperties.getCorePoolSize(), properties.getCorePoolSize())) { if (!Objects.equals(beforeProperties.getCorePoolSize(), properties.getCorePoolSize())) {
executor.setCorePoolSize(properties.getCorePoolSize()); executor.setCorePoolSize(properties.getCorePoolSize());
} }
if (!Objects.equals(beforeProperties.getAllowCoreThreadTimeOut(), properties.getAllowCoreThreadTimeOut())) { if (!Objects.equals(beforeProperties.getAllowCoreThreadTimeOut(), properties.getAllowCoreThreadTimeOut())) {
executor.allowCoreThreadTimeOut(properties.getAllowCoreThreadTimeOut()); executor.allowCoreThreadTimeOut(properties.getAllowCoreThreadTimeOut());
} }
if (!Objects.equals(beforeProperties.getExecuteTimeOut(), properties.getExecuteTimeOut())) { if (!Objects.equals(beforeProperties.getExecuteTimeOut(), properties.getExecuteTimeOut())) {
if (executor instanceof AbstractDynamicExecutorSupport) { if (executor instanceof AbstractDynamicExecutorSupport) {
((DynamicThreadPoolExecutor) executor).setExecuteTimeOut(properties.getExecuteTimeOut()); ((DynamicThreadPoolExecutor) executor).setExecuteTimeOut(properties.getExecuteTimeOut());
} }
} }
if (!Objects.equals(beforeProperties.getRejectedHandler(), properties.getRejectedHandler())) { if (!Objects.equals(beforeProperties.getRejectedHandler(), properties.getRejectedHandler())) {
RejectedExecutionHandler rejectedExecutionHandler = RejectedTypeEnum.createPolicy(properties.getRejectedHandler()); RejectedExecutionHandler rejectedExecutionHandler = RejectedTypeEnum.createPolicy(properties.getRejectedHandler());
if (executor instanceof AbstractDynamicExecutorSupport) { if (executor instanceof AbstractDynamicExecutorSupport) {
@ -283,14 +272,11 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
AtomicLong rejectCount = dynamicExecutor.getRejectCount(); AtomicLong rejectCount = dynamicExecutor.getRejectCount();
rejectedExecutionHandler = RejectedProxyUtil.createProxy(rejectedExecutionHandler, threadPoolId, rejectCount); rejectedExecutionHandler = RejectedProxyUtil.createProxy(rejectedExecutionHandler, threadPoolId, rejectCount);
} }
executor.setRejectedExecutionHandler(rejectedExecutionHandler); executor.setRejectedExecutionHandler(rejectedExecutionHandler);
} }
if (!Objects.equals(beforeProperties.getKeepAliveTime(), properties.getKeepAliveTime())) { if (!Objects.equals(beforeProperties.getKeepAliveTime(), properties.getKeepAliveTime())) {
executor.setKeepAliveTime(properties.getKeepAliveTime(), TimeUnit.SECONDS); executor.setKeepAliveTime(properties.getKeepAliveTime(), TimeUnit.SECONDS);
} }
if (!Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity()) if (!Objects.equals(beforeProperties.getQueueCapacity(), properties.getQueueCapacity())
&& Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName())) { && Objects.equals(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE.name, executor.getQueue().getClass().getSimpleName())) {
if (executor.getQueue() instanceof ResizableCapacityLinkedBlockIngQueue) { if (executor.getQueue() instanceof ResizableCapacityLinkedBlockIngQueue) {
@ -318,15 +304,12 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
} else if (bindableCoreProperties.getJetty() != null) { } else if (bindableCoreProperties.getJetty() != null) {
poolProperties = bindableCoreProperties.getJetty(); poolProperties = bindableCoreProperties.getJetty();
} }
if (poolProperties != null) { if (poolProperties != null) {
parameterInfo = new PoolParameterInfo(); parameterInfo = new PoolParameterInfo();
parameterInfo.setCoreSize(poolProperties.getCorePoolSize()); parameterInfo.setCoreSize(poolProperties.getCorePoolSize());
parameterInfo.setMaxSize(poolProperties.getMaximumPoolSize()); parameterInfo.setMaxSize(poolProperties.getMaximumPoolSize());
parameterInfo.setKeepAliveTime(poolProperties.getKeepAliveTime()); parameterInfo.setKeepAliveTime(poolProperties.getKeepAliveTime());
} }
return parameterInfo; return parameterInfo;
} }
} }

Loading…
Cancel
Save