Skip to content

Commit

Permalink
fix:agent2022 config not work
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikliu committed Jun 18, 2024
1 parent f3c8196 commit b72f549
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
server.port=65002
spring.application.name=service-consumer-2022
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.enabled=false
spring.cloud.nacos.config.enabled=false
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.discovery.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=uu3T2L9q
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.main.allow-bean-definition-overriding=true
spring.main.allow-circular-references=true
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
server.port=65001
spring.application.name=service-provider-2022
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=false
spring.cloud.nacos.discovery.enabled=false
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.discovery.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
spring.cloud.nacos.password=uu3T2L9q
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.main.allow-bean-definition-overriding=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
server.port=65002
spring.application.name=service-consumer-hoxton
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.enabled=false
spring.cloud.nacos.config.enabled=false
server.port=65001
spring.application.name=service-provider-hoxton
spring.cloud.nacos.config.server-addr=111.230.121.115:8848
spring.cloud.nacos.discovery.server-addr=111.230.121.115:8848
spring.cloud.nacos.config.enabled=true
spring.cloud.nacos.discovery.enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=uu3T2L9q
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
spring.main.allow-bean-definition-overriding=true
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down Expand Up @@ -411,6 +409,10 @@
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-lossless-plugin</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ 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());
Object polarisCircuitBreakerBootstrapConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisCircuitBreakerBootstrapConfiguration.class, "polarisCircuitBreakerBootstrapConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisCircuitBreakerBootstrapConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisCircuitBreakerBootstrapConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisCircuitBreakerBootstrapConfiguration.class).getBeanDefinition());
}

@Override
Expand All @@ -40,6 +44,26 @@ public void onApplicationStartup(Object configurationParser, Constructor<?> conf
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisCircuitBreakerEndpointAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisCircuitBreakerEndpointAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisCircuitBreakerEndpointAutoConfiguration.class).getBeanDefinition());
if (null != ClassUtils.getClazz("reactor.core.publisher.Mono", Thread.currentThread().getContextClassLoader())
&& null != ClassUtils.getClazz("reactor.core.publisher.Flux", Thread.currentThread()
.getContextClassLoader())) {
Object reactivePolarisCircuitBreakerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, ReactivePolarisCircuitBreakerAutoConfiguration.class, "reactivePolarisCircuitBreakerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, reactivePolarisCircuitBreakerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("reactivePolarisCircuitBreakerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
ReactivePolarisCircuitBreakerAutoConfiguration.class).getBeanDefinition());
}
if (null != ClassUtils.getClazz("feign.Feign", Thread.currentThread().getContextClassLoader())
&& null != ClassUtils.getClazz("org.springframework.cloud.openfeign.FeignClientFactoryBean", Thread.currentThread()
.getContextClassLoader())) {
Object polarisCircuitBreakerFeignClientAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisCircuitBreakerFeignClientAutoConfiguration.class, "polarisCircuitBreakerFeignClientAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisCircuitBreakerFeignClientAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisCircuitBreakerFeignClientAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisCircuitBreakerFeignClientAutoConfiguration.class).getBeanDefinition());
}
Object polarisCircuitBreakerAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisCircuitBreakerAutoConfiguration.class, "polarisCircuitBreakerAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisCircuitBreakerAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisCircuitBreakerAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisCircuitBreakerAutoConfiguration.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 @@ -53,6 +53,10 @@ 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());
Object polarisConfigBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisConfigBootstrapAutoConfiguration.class, "polarisConfigBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisConfigBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisConfigBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisConfigBootstrapAutoConfiguration.class).getBeanDefinition());
}

@Override
Expand All @@ -65,10 +69,6 @@ public void onApplicationStartup(Object configurationParser, Constructor<?> conf
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContractProperties, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContractProperties", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContractProperties.class).getBeanDefinition());
Object polarisConfigBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisConfigBootstrapAutoConfiguration.class, "polarisConfigBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisConfigBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisConfigBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisConfigBootstrapAutoConfiguration.class).getBeanDefinition());
Object polarisConfigAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisConfigAutoConfiguration.class, "polarisConfigAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisConfigAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisConfigAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ public String getModule() {
@Override
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());
}

@Override
public void onBootstrapStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {
Object metadataTransferAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, MetadataTransferAutoConfiguration.class, "metadataTransferAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, metadataTransferAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("metadataTransferAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
MetadataTransferAutoConfiguration.class).getBeanDefinition());
}

@Override
public void onBootstrapStartup(Object configurationParser, Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public Map<String, List<String>> getClassNameForType() {
@Override
public void onBootstrapStartup(Object configurationParser,
Constructor<?> configClassCreator, Method processConfigurationClass, BeanDefinitionRegistry registry, Environment environment) {

Object polarisContextBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisContextBootstrapAutoConfiguration.class, "polarisContextBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContextBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContextBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContextBootstrapAutoConfiguration.class).getBeanDefinition());
LOGGER.info("[PolarisJavaAgent] success to inject bootstrap bean definitions for module {}", getModule());
}

Expand All @@ -76,10 +79,7 @@ public void onApplicationStartup(Object configurationParser,
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContextPostConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContextPostConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContextPostConfiguration.class).getBeanDefinition());
Object polarisContextBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, PolarisContextBootstrapAutoConfiguration.class, "polarisContextBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, polarisContextBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("polarisContextBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
PolarisContextBootstrapAutoConfiguration.class).getBeanDefinition());

LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@
import com.tencent.cloud.common.metadata.config.MetadataLocalProperties;
import com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration;
import com.tencent.cloud.polaris.DiscoveryPropertiesBootstrapAutoConfiguration;
import com.tencent.cloud.polaris.contract.config.PolarisContractPropertiesAutoConfiguration;
import com.tencent.cloud.polaris.discovery.PolarisDiscoveryAutoConfiguration;
import com.tencent.cloud.polaris.discovery.PolarisDiscoveryClientConfiguration;
import com.tencent.cloud.polaris.discovery.reactive.PolarisReactiveDiscoveryClientConfiguration;
import com.tencent.cloud.polaris.router.config.RouterConfigModifierAutoConfiguration;
import com.tencent.cloud.polaris.router.config.properties.PolarisMetadataRouterProperties;
import com.tencent.cloud.polaris.router.config.properties.PolarisNearByRouterProperties;
import com.tencent.cloud.polaris.router.config.properties.PolarisRuleBasedRouterProperties;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import com.tencent.polaris.api.config.Configuration;
import com.tencent.cloud.polaris.endpoint.PolarisDiscoveryEndpointAutoConfiguration;
Expand Down Expand Up @@ -65,7 +70,10 @@ 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());

Object discoveryPropertiesBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, DiscoveryPropertiesBootstrapAutoConfiguration.class, "discoveryPropertiesBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, discoveryPropertiesBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("discoveryPropertiesBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
DiscoveryPropertiesBootstrapAutoConfiguration.class).getBeanDefinition());
}

@Override
Expand Down Expand Up @@ -98,10 +106,6 @@ public void onApplicationStartup(Object configurationParser, Constructor<?> conf
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, discoveryPropertiesAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("discoveryPropertiesAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
DiscoveryPropertiesAutoConfiguration.class).getBeanDefinition());
Object discoveryPropertiesBootstrapAutoConfiguration = ReflectionUtils.invokeConstructor(configClassCreator, DiscoveryPropertiesBootstrapAutoConfiguration.class, "discoveryPropertiesBootstrapAutoConfiguration");
ReflectionUtils.invokeMethod(processConfigurationClass, configurationParser, discoveryPropertiesBootstrapAutoConfiguration, Constant.DEFAULT_EXCLUSION_FILTER);
registry.registerBeanDefinition("discoveryPropertiesBootstrapAutoConfiguration", BeanDefinitionBuilder.genericBeanDefinition(
DiscoveryPropertiesBootstrapAutoConfiguration.class).getBeanDefinition());
LOGGER.info("[PolarisJavaAgent] success to inject application bean definitions for module {}", getModule());
}
}
Expand Down
Loading

0 comments on commit b72f549

Please sign in to comment.