hippo4j-core 添加 web 容器线程池修改. (#141)

pull/142/head
chen.ma 3 years ago
parent e5a83a0cfb
commit 06822f07f6

@ -57,6 +57,22 @@ public class BootstrapCoreProperties implements BootstrapPropertiesInterface {
*/ */
private Map<String, String> apollo; private Map<String, String> apollo;
/**
* Tomcat thread pool config.
*/
private WebThreadPoolProperties tomcat;
/**
* Undertow thread pool config.
*/
private WebThreadPoolProperties undertow;
/**
* Jetty thread pool config.
* KeepAliveTime is not supported temporarily.
*/
private WebThreadPoolProperties jetty;
/** /**
* Notify platforms. * Notify platforms.
*/ */

@ -10,6 +10,7 @@ import cn.hippo4j.common.notify.platform.DingSendMessageHandler;
import cn.hippo4j.common.notify.platform.LarkSendMessageHandler; import cn.hippo4j.common.notify.platform.LarkSendMessageHandler;
import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler; import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler;
import cn.hippo4j.core.config.UtilAutoConfiguration; import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.config.WebThreadPoolConfiguration;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler; import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
import cn.hippo4j.core.starter.notify.CoreNotifyConfigBuilder; import cn.hippo4j.core.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.core.starter.refresher.ApolloRefresherHandler; import cn.hippo4j.core.starter.refresher.ApolloRefresherHandler;
@ -36,7 +37,7 @@ import org.springframework.core.annotation.Order;
@Configuration @Configuration
@AllArgsConstructor @AllArgsConstructor
@EnableConfigurationProperties(BootstrapCoreProperties.class) @EnableConfigurationProperties(BootstrapCoreProperties.class)
@ImportAutoConfiguration({UtilAutoConfiguration.class}) @ImportAutoConfiguration({UtilAutoConfiguration.class, WebThreadPoolConfiguration.class})
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true") @ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
public class DynamicThreadPoolCoreAutoConfiguration { public class DynamicThreadPoolCoreAutoConfiguration {
@ -117,5 +118,4 @@ public class DynamicThreadPoolCoreAutoConfiguration {
return new ApolloRefresherHandler(threadPoolNotifyAlarmHandler, bootstrapCoreProperties); return new ApolloRefresherHandler(threadPoolNotifyAlarmHandler, bootstrapCoreProperties);
} }
} }

@ -0,0 +1,29 @@
package cn.hippo4j.core.starter.config;
import lombok.Data;
/**
* Web thread pool properties.
*
* @author chen.ma
* @date 2022/3/11 19:23
*/
@Data
public class WebThreadPoolProperties {
/**
* Core pool size
*/
private Integer corePoolSize;
/**
* Maximum pool size
*/
private Integer maximumPoolSize;
/**
* Keep alive time
*/
private Integer keepAliveTime;
}

@ -11,6 +11,10 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -33,9 +37,8 @@ public class BootstrapCorePropertiesBinderAdapt {
* @return * @return
*/ */
public static BootstrapCoreProperties bootstrapCorePropertiesBinder(Map<Object, Object> configInfo, BootstrapCoreProperties bootstrapCoreProperties) { public static BootstrapCoreProperties bootstrapCorePropertiesBinder(Map<Object, Object> configInfo, BootstrapCoreProperties bootstrapCoreProperties) {
BootstrapCoreProperties bindableCoreProperties = adapt(configInfo); BootstrapCoreProperties bindableCoreProperties = null;
; try {
/*try {
ConfigurationPropertySource sources = new MapConfigurationPropertySource(configInfo); ConfigurationPropertySource sources = new MapConfigurationPropertySource(configInfo);
Binder binder = new Binder(sources); Binder binder = new Binder(sources);
bindableCoreProperties = binder.bind(PREFIX, Bindable.ofInstance(bootstrapCoreProperties)).get(); bindableCoreProperties = binder.bind(PREFIX, Bindable.ofInstance(bootstrapCoreProperties)).get();
@ -45,7 +48,7 @@ public class BootstrapCorePropertiesBinderAdapt {
} catch (ClassNotFoundException notEx) { } catch (ClassNotFoundException notEx) {
bindableCoreProperties = adapt(configInfo); bindableCoreProperties = adapt(configInfo);
} }
}*/ }
return bindableCoreProperties; return bindableCoreProperties;
} }

Loading…
Cancel
Save