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

fix:change application.propertirtes #199

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ server.port=65002
spring.application.name=service-consumer-2022
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true

spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
spring.cloud.nacos.discovery.fail-fast=true

feign.sentinel.enabled=true

spring.cloud.sentinel.transport.dashboard=localhost:8080
spring.cloud.sentinel.eager=true

spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
spring.cloud.sentinel.datasource.ds1.file.data-type=json
spring.cloud.sentinel.datasource.ds1.file.rule-type=flow

spring.cloud.sentinel.datasource.ds2.file.file=classpath: degraderule.json
spring.cloud.sentinel.datasource.ds2.file.data-type=json
spring.cloud.sentinel.datasource.ds2.file.rule-type=degrade
spring.cloud.loadbalancer.nacos.enabled=true
# use feign client in GraalVM environment need to set below config
spring.cloud.refresh.enabled=false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#server.port=65002
#spring.application.name=service-consumer-2023
#management.endpoints.web.exposure.include=*
#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#spring.cloud.nacos.config.server-addr=127.0.0.1:8848
#spring.cloud.nacos.discovery.fail-fast=true
#spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.config.enabled=true
#spring.cloud.nacos.username=nacos
#spring.cloud.nacos.password=nacos
#
#feign.sentinel.enabled=true
#
#spring.cloud.sentinel.transport.dashboard=localhost:8080
#spring.cloud.sentinel.eager=true
#
#spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
#spring.cloud.sentinel.datasource.ds1.file.data-type=json
#spring.cloud.sentinel.datasource.ds1.file.rule-type=flow
#
#spring.cloud.sentinel.datasource.ds2.file.file=classpath: degraderule.json
#spring.cloud.sentinel.datasource.ds2.file.data-type=json
#spring.cloud.sentinel.datasource.ds2.file.rule-type=degrade
#spring.cloud.loadbalancer.nacos.enabled=true
## use feign client in GraalVM environment need to set below config
#spring.cloud.refresh.enabled=false
#spring.main.allow-circular-references=true

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server.port=65002
spring.application.name=service-consumer-2023
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

spring.cloud.loadbalancer.nacos.enabled=true
# use feign client in GraalVM environment need to set below config
spring.cloud.refresh.enabled=false
spring.main.allow-circular-references=true

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
#spring.cloud.nacos.discovery.ip-type=IPv4
#only register IPv6 instance
#spring.cloud.nacos.discovery.ip-type=IPv6

spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.main.allow-circular-references=true

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#server.port=65001
#spring.application.name=service-provider-2022
#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#spring.cloud.nacos.config.server-addr=127.0.0.1:8848
#spring.cloud.nacos.config.enabled=true
#spring.cloud.nacos.discovery.enabled=true
##spring.cloud.nacos.discovery.instance-enabled=true
##only register IPv4 instance
##spring.cloud.nacos.discovery.ip-type=IPv4
##only register IPv6 instance
##spring.cloud.nacos.discovery.ip-type=IPv6
#
#spring.cloud.nacos.username=nacos
#spring.cloud.nacos.password=nacos
#
#management.endpoints.web.exposure.include=*
#management.endpoint.health.show-details=always
#spring.main.allow-circular-references=true

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ spring.application.name=service-consumer-hoxton
server.port=18083
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true

spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

feign.sentinel.enabled=true

spring.cloud.sentinel.transport.dashboard=localhost:8080
spring.cloud.sentinel.eager=true

spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
spring.cloud.sentinel.datasource.ds1.file.data-type=json
spring.cloud.sentinel.datasource.ds1.file.rule-type=flow

spring.cloud.sentinel.datasource.ds2.file.file=classpath: degraderule.json
spring.cloud.sentinel.datasource.ds2.file.data-type=json
spring.cloud.sentinel.datasource.ds2.file.rule-type=degrade
spring.cloud.loadbalancer.nacos.enabled=true
# use feign client in GraalVM environment need to set below config
spring.cloud.refresh.enabled=false
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
server.port=0
spring.application.name=service-provider-hoxton
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
#spring.cloud.nacos.discovery.instance-enabled=true
#only register IPv4 instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@ public void onApplicationStartup(Object configurationParser, Constructor<?> conf
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, applicationContextAwareUtils, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("applicationContextAwareUtils", BeanDefinitionBuilder.genericBeanDefinition(
ApplicationContextAwareUtils.class).getBeanDefinition());
if (null != ClassUtils.getClazz("feign.RequestInterceptor",
Thread.currentThread().getContextClassLoader())) {
Object feignAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, FeignAutoConfiguration.class, "feignAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, feignAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("feignAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
FeignAutoConfiguration.class).getBeanDefinition());
}
Object routerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, RouterAutoConfiguration.class, "routerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, routerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("routerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
RouterAutoConfiguration.class).getBeanDefinition());

LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ public String getModule() {

@Override
public void onBootstrapStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject bootstrap bean definitions for module {}", getModule());
}


@Override
@SuppressWarnings("unchecked")
public void onApplicationStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
if (null != ClassUtils.getClazz("feign.RequestInterceptor",
Thread.currentThread().getContextClassLoader())) {
Object feignAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, FeignAutoConfiguration.class, "feignAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, feignAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("feignAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
FeignAutoConfiguration.class).getBeanDefinition());
}
Object routerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, RouterAutoConfiguration.class, "routerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, routerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("routerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
RouterAutoConfiguration.class).getBeanDefinition());
Object polarisNearByRouterProperties = ReflectionUtils.invokeConstructor(configClassCreator, PolarisNearByRouterProperties.class, "polarisNearByRouterProperties");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisNearByRouterProperties, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisNearByRouterProperties", BeanDefinitionBuilder.genericBeanDefinition(
Expand All @@ -78,13 +97,5 @@ public void onBootstrapStartup(Object configurationParser, Constructor<?> config
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContractPropertiesAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContractPropertiesAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContractPropertiesAutoConfiguration.class).getBeanDefinition());
LOGGER.info("[PolarisJavaAgent] success to inject bootstrap bean definitions for module {}", getModule());
}


@Override
@SuppressWarnings("unchecked")
public void onApplicationStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
for (BeanInjector beanInjector : beanInjectors) {
if (!(beanInjector instanceof CommonBeanInjector)) {
if (!(beanInjector instanceof RouterBeanInjector)) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
Expand All @@ -140,7 +140,7 @@ public void before(Object target, Object[] args) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) ReflectionUtils.getObjectByFieldName(target, "registry");
Environment environment = (Environment) ReflectionUtils.getObjectByFieldName(target, "environment");
for (BeanInjector beanInjector : beanInjectors) {
if (beanInjector instanceof CommonBeanInjector) {
if (beanInjector instanceof RouterBeanInjector) {
LOGGER.info("[PolarisJavaAgent] start to inject application bean definitions in module {}", beanInjector.getModule());
beanInjector.onApplicationStartup(target, constructor, processConfigurationClass, registry, environment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ logging.level.root=INFO
# switch for nacos discovery enable
spring.cloud.nacos.discovery.enabled=false
# switch for nacos config enable
spring.cloud.nacos.config.enabled=false
spring.cloud.nacos.config.enabled=false
# switch for lossless enable
spring.cloud.polaris.lossless.enabled=true
spring.cloud.polaris.lossless.port=28080
spring.cloud.polaris.lossless.delayRegisterInterval=30000
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static List<PropertiesPropertySource> loadPropertiesSource() {
} catch (IOException e) {
throw new IllegalStateException("fail to load config from " + configPath, e);
}
properties.setProperty("spring.cloud.nacos.config.enabled", "false");
properties.setProperty("spring.cloud.nacos.discovery.enabled", "false");
propertySources.add(new PropertiesPropertySource("__polaris_agent_spring_cloud_tencent__", properties));
propertySources.add(new PropertiesPropertySource("__default_polaris_agent_spring_cloud_tencent__", defaultProperties));
return propertySources;
Expand Down