|
|
@ -23,6 +23,7 @@ import cn.hippo4j.core.config.ConfigEmptyException;
|
|
|
|
import cn.hippo4j.threadpool.dynamic.api.BootstrapPropertiesInterface;
|
|
|
|
import cn.hippo4j.threadpool.dynamic.api.BootstrapPropertiesInterface;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.env.ConfigurableEnvironment;
|
|
|
|
import org.springframework.core.env.ConfigurableEnvironment;
|
|
|
@ -39,6 +40,26 @@ public class BeforeCheckConfiguration {
|
|
|
|
private final String bootstrapPropertiesClassName = "cn.hippo4j.springboot.starter.config.BootstrapProperties";
|
|
|
|
private final String bootstrapPropertiesClassName = "cn.hippo4j.springboot.starter.config.BootstrapProperties";
|
|
|
|
private final String bootstrapConfigPropertiesClassName = "cn.hippo4j.threadpool.dynamic.mode.config.properties.BootstrapConfigProperties";
|
|
|
|
private final String bootstrapConfigPropertiesClassName = "cn.hippo4j.threadpool.dynamic.mode.config.properties.BootstrapConfigProperties";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String POLARIS_NAMESPACE = "${spring.dynamic.thread-pool.polaris.namespace}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String POLARIS_FILE_GROUP = "${spring.dynamic.thread-pool.polaris.file.group}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String POLARIS_FILE_NAME = "${spring.dynamic.thread-pool.polaris.file.name}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String POLARIS_FILE_TYPE = "${spring.dynamic.thread-pool.polaris.file.type}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value(POLARIS_NAMESPACE)
|
|
|
|
|
|
|
|
private String polarisNamespace;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value(POLARIS_FILE_GROUP)
|
|
|
|
|
|
|
|
private String polarisFileGroup;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value(POLARIS_FILE_NAME)
|
|
|
|
|
|
|
|
private String polarisFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value(POLARIS_FILE_TYPE)
|
|
|
|
|
|
|
|
private String polarisFileType;
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public BeforeCheckConfiguration.BeforeCheck dynamicThreadPoolBeforeCheckBean(@Autowired(required = false) BootstrapPropertiesInterface properties,
|
|
|
|
public BeforeCheckConfiguration.BeforeCheck dynamicThreadPoolBeforeCheckBean(@Autowired(required = false) BootstrapPropertiesInterface properties,
|
|
|
|
ConfigurableEnvironment environment) {
|
|
|
|
ConfigurableEnvironment environment) {
|
|
|
@ -144,40 +165,26 @@ public class BeforeCheckConfiguration {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> polaris = properties.getPolaris();
|
|
|
|
if (StringUtil.isBlank(polarisNamespace)) {
|
|
|
|
if (MapUtil.isNotEmpty(polaris)) {
|
|
|
|
|
|
|
|
String namespace = polaris.get("namespace").toString();
|
|
|
|
|
|
|
|
if (StringUtil.isBlank(namespace)) {
|
|
|
|
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris namespace is empty.",
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris namespace is empty.",
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.namespace] configuration is empty or an empty string.");
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.namespace] configuration is empty or an empty string.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (polaris.get("file") instanceof Map) {
|
|
|
|
if (StringUtil.isBlank(polarisFileGroup)) {
|
|
|
|
Map<String, String> polarisFile = (Map<String, String>)polaris.get("file");
|
|
|
|
|
|
|
|
String fileGroup = polarisFile.get("group");
|
|
|
|
|
|
|
|
if (StringUtil.isBlank(fileGroup)) {
|
|
|
|
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file group is empty.",
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file group is empty.",
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.group] configuration is empty or an empty string.");
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.group] configuration is empty or an empty string.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String fileName = polarisFile.get("name");
|
|
|
|
if (StringUtil.isBlank(polarisFileName)) {
|
|
|
|
if (StringUtil.isBlank(fileName)) {
|
|
|
|
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file name is empty.",
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file name is empty.",
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.name] configuration is empty or an empty string.");
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.name] configuration is empty or an empty string.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String fileType = polarisFile.get("type");
|
|
|
|
if (StringUtil.isBlank(polarisFileType)) {
|
|
|
|
if (StringUtil.isBlank(fileType)) {
|
|
|
|
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file type is empty.",
|
|
|
|
"Web server maybe fail to start. The dynamic thread pool polaris file type is empty.",
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.type] configuration is empty or an empty string.");
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.type] configuration is empty or an empty string.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new ConfigEmptyException(
|
|
|
|
|
|
|
|
"Web server maybe fail to start. Lack of the dynamic thread pool polaris file configuration.",
|
|
|
|
|
|
|
|
"Please check whether the [spring.dynamic.thread-pool.polaris.file.*] configuration is complete.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|