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:fix agent 2023/2022 could not statrt by double registry #198

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -1,7 +1,9 @@
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.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.enabled=false
spring.main.allow-bean-definition-overriding=true
spring.cloud.nacos.discovery.enabled=false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo的nacos开关都设置为true,方便测试开启的场景

spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
spring.main.allow-circular-references=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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=false
spring.cloud.nacos.discovery.enabled=false
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 @@ -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
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 @@ -33,7 +33,9 @@ public class RegisterBeanInterceptor implements Interceptor {
private final Set<String> primaryBeanNames = new HashSet<>();

public RegisterBeanInterceptor() {
// primaryBeanNames.add("metadataTransferAutoConfiguratio");
primaryBeanNames.add("polarisAutoServiceRegistration");
primaryBeanNames.add("polarisRegistration");
primaryBeanNames.add("polarisServiceRegistry");
}

@Override
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,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 @@ -41,4 +41,8 @@ spring.cloud.polaris.stat.enabled=false
spring.cloud.polaris.stat.port=0
# path for polaris stat
spring.cloud.polaris.stat.path=/metrics
logging.level.root=INFO
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
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