From 8b01139ad00585cd441ee6f995610f7d4a61dcab Mon Sep 17 00:00:00 2001 From: lepdou Date: Mon, 11 Apr 2022 20:23:23 +0800 Subject: [PATCH] fix discovery weight param not set to register request bug --- CHANGELOG.md | 18 ++---------------- .../polaris/PolarisDiscoveryProperties.java | 6 +++--- .../registry/PolarisServiceRegistry.java | 1 + ...ditional-spring-configuration-metadata.json | 2 +- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed5af758..cb85172f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,5 @@ # Change Log --- -- [the server address only support one ip](https://github.com/Tencent/spring-cloud-tencent/pull/36) -- [feature: get service list by given namespace](https://github.com/Tencent/spring-cloud-tencent/pull/38) -- [feat:Support multi-discovery server.](https://github.com/Tencent/spring-cloud-tencent/pull/42) -- [fix:fix [Deserialization of Untrusted Data in logback]](https://github.com/Tencent/spring-cloud-tencent/pull/44/files) -- [feat:support customize registered ip address.](https://github.com/Tencent/spring-cloud-tencent/pull/47) -- [fix:fix import default log implement error](https://github.com/Tencent/spring-cloud-tencent/pull/53) -- [send heartbeat if healthcheck url not configured](https://github.com/Tencent/spring-cloud-tencent/pull/54) -- [feat:optimize project structure and checkstyle](https://github.com/Tencent/spring-cloud-tencent/pull/56) -- [feat:divide storage and transfer of metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/63) -- [feat:support polaris config center.](https://github.com/Tencent/spring-cloud-tencent/pull/69) -- [feat:optimize metadata module.](https://github.com/Tencent/spring-cloud-tencent/pull/70) -- [feat: optimize pom dependency and demo](https://github.com/Tencent/spring-cloud-tencent/pull/71) -- [feat:upgrade polaris version to 1.3.0.](https://github.com/Tencent/spring-cloud-tencent/pull/72) -- [feat:rollback init polaris-context to application phase](https://github.com/Tencent/spring-cloud-tencent/pull/73) -- [feat:tencent-commons add spring-cloud-starter dependency](https://github.com/Tencent/spring-cloud-tencent/pull/76) -- [fix:fix fetching wrong PEER_SERVICE in SCG filter.](https://github.com/Tencent/spring-cloud-tencent/pull/83) +- [feat:fix discovery weight param not set to register request bug](https://github.com/Tencent/spring-cloud-tencent/pull/103) + diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java index 35f397217..351ab62f3 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java @@ -56,7 +56,7 @@ public class PolarisDiscoveryProperties { * Load balance weight. */ @Value("${spring.cloud.polaris.discovery.weight:#{100}}") - private float weight; + private int weight; /** * Version number. @@ -134,11 +134,11 @@ public class PolarisDiscoveryProperties { this.namespace = namespace; } - public float getWeight() { + public int getWeight() { return weight; } - public void setWeight(float weight) { + public void setWeight(int weight) { this.weight = weight; } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java index 7e72a075d..b947db594 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java @@ -95,6 +95,7 @@ public class PolarisServiceRegistry implements ServiceRegistry { instanceRegisterRequest.setService(registration.getServiceId()); instanceRegisterRequest.setHost(registration.getHost()); instanceRegisterRequest.setPort(registration.getPort()); + instanceRegisterRequest.setWeight(polarisDiscoveryProperties.getWeight()); instanceRegisterRequest.setToken(polarisDiscoveryProperties.getToken()); if (null != heartbeatExecutor) { instanceRegisterRequest.setTtl(ttl); diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 89021b3d2..6608a3b97 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -50,7 +50,7 @@ }, { "name": "spring.cloud.polaris.weight", - "type": "java.lang.String", + "type": "java.lang.Integer", "defaultValue": 100, "description": "the weight of polaris instance , use to load-balance." }