Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check the required fields of polaris when the config mode starts #1470

Merged
merged 10 commits into from
Oct 11, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import cn.hippo4j.threadpool.dynamic.api.BootstrapPropertiesInterface;
import lombok.AllArgsConstructor;
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.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
Expand All @@ -39,6 +40,26 @@ public class BeforeCheckConfiguration {
private final String bootstrapPropertiesClassName = "cn.hippo4j.springboot.starter.config.BootstrapProperties";
private final String bootstrapConfigPropertiesClassName = "cn.hippo4j.threadpool.dynamic.mode.config.properties.BootstrapConfigProperties";

private static final String POLARIS_NAMESPACE = "${spring.dynamic.thread-pool.polaris.namespace}";
mazengrun marked this conversation as resolved.
Show resolved Hide resolved

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
public BeforeCheckConfiguration.BeforeCheck dynamicThreadPoolBeforeCheckBean(@Autowired(required = false) BootstrapPropertiesInterface properties,
ConfigurableEnvironment environment) {
Expand Down Expand Up @@ -144,6 +165,26 @@ public BeforeCheckConfiguration.BeforeCheck dynamicThreadPoolBeforeCheckBean(@Au
}
}

if (StringUtil.isBlank(polarisNamespace)) {
throw new ConfigEmptyException(
"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.");
}
if (StringUtil.isBlank(polarisFileGroup)) {
throw new ConfigEmptyException(
"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.");
}
if (StringUtil.isBlank(polarisFileName)) {
throw new ConfigEmptyException(
"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.");
}
if (StringUtil.isBlank(polarisFileType)) {
throw new ConfigEmptyException(
"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.");
}
break;
}
default:
Expand Down