diff --git a/spring-cloud-alibaba-docs/src/main/asciidoc-zh/governance.adoc b/spring-cloud-alibaba-docs/src/main/asciidoc-zh/governance.adoc index 869e03fdc..111bc53f7 100644 --- a/spring-cloud-alibaba-docs/src/main/asciidoc-zh/governance.adoc +++ b/spring-cloud-alibaba-docs/src/main/asciidoc-zh/governance.adoc @@ -99,7 +99,7 @@ spring: 2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例) 如果没有配置,使用ribbon默认的负载均衡算法ZoneAvoidanceRule ---- -spring.cloud.governance.routeing.rule=RandomRule +spring.cloud.governance.routing.rule=RandomRule ---- 在引入Istio配置转换模块的前提下,标签路由模块支持对以下几种请求的元信息做路由 diff --git a/spring-cloud-alibaba-docs/src/main/asciidoc/governance.adoc b/spring-cloud-alibaba-docs/src/main/asciidoc/governance.adoc index 3ce439a8a..7a24b41f5 100644 --- a/spring-cloud-alibaba-docs/src/main/asciidoc/governance.adoc +++ b/spring-cloud-alibaba-docs/src/main/asciidoc/governance.adoc @@ -90,7 +90,7 @@ If you use Spring Cloud Alibaba Governance Label Routing in your project, You ne 2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example) If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule. ---- -spring.cloud.governance.routeing.rule=RandomRule +spring.cloud.governance.routing.rule=RandomRule ---- With the introduction of Istio Resource Transform module, the label routing module supports routing of the following types of request meta-information: diff --git a/spring-cloud-alibaba-examples/governance-example/label-routing-example/consumer-example/src/main/resources/application.properties b/spring-cloud-alibaba-examples/governance-example/label-routing-example/consumer-example/src/main/resources/application.properties index 17eab0834..3406705a9 100644 --- a/spring-cloud-alibaba-examples/governance-example/label-routing-example/consumer-example/src/main/resources/application.properties +++ b/spring-cloud-alibaba-examples/governance-example/label-routing-example/consumer-example/src/main/resources/application.properties @@ -5,4 +5,4 @@ spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.fail-fast=true spring.cloud.nacos.username=nacos spring.cloud.nacos.password=nacos -#spring.cloud.governance.router.rule=RandomRule +#spring.cloud.governance.routing.rule=RandomRule diff --git a/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme-zh.md b/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme-zh.md index d33afdf96..1847e81ad 100644 --- a/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme-zh.md +++ b/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme-zh.md @@ -32,7 +32,7 @@ 2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例) 如果没有配置,使用ribbon默认的负载均衡算法ZoneAvoidanceRule ```yaml -spring.cloud.governance.routeing.rule=RandomRule +spring.cloud.governance.routing.rule=RandomRule ``` ### 应用启动 diff --git a/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme.md b/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme.md index 82b4da353..4359ed9f8 100644 --- a/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme.md +++ b/spring-cloud-alibaba-examples/governance-example/label-routing-example/readme.md @@ -34,7 +34,7 @@ In the future, more components such as RestTemplate, Spring Cloud LoadBalancer a 2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example) If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule. ```yaml -spring.cloud.governance.routeing.rule=RandomRule +spring.cloud.governance.routing.rule=RandomRule ``` ### Application Start diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-governance-routing/src/main/java/com/alibaba/cloud/routing/RoutingProperties.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-governance-routing/src/main/java/com/alibaba/cloud/routing/RoutingProperties.java index a953d133c..4f9bacf0c 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-governance-routing/src/main/java/com/alibaba/cloud/routing/RoutingProperties.java +++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-governance-routing/src/main/java/com/alibaba/cloud/routing/RoutingProperties.java @@ -16,6 +16,11 @@ package com.alibaba.cloud.routing; +import javax.annotation.PostConstruct; + +import com.alibaba.cloud.commons.lang.StringUtils; +import com.alibaba.cloud.routing.util.LoadBalanceUtil; + import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -28,13 +33,20 @@ public class RoutingProperties { /** * Properties prefix. */ - public static final String PROPERTY_PREFIX = "spring.cloud.governance.router"; + public static final String PROPERTY_PREFIX = "spring.cloud.governance.routing"; /** * Load Balance Rule. */ private String rule; + @PostConstruct + public void init() { + if (StringUtils.isEmpty(rule)) { + rule = LoadBalanceUtil.ZONE_AVOIDANCE_RULE; + } + } + public String getRule() { return rule; } diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-xds-adapter/src/main/java/com/alibaba/cloud/governance/istio/PilotExchanger.java b/spring-cloud-alibaba-starters/spring-cloud-starter-xds-adapter/src/main/java/com/alibaba/cloud/governance/istio/PilotExchanger.java index cbae12b9b..04c260e40 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-starter-xds-adapter/src/main/java/com/alibaba/cloud/governance/istio/PilotExchanger.java +++ b/spring-cloud-alibaba-starters/spring-cloud-starter-xds-adapter/src/main/java/com/alibaba/cloud/governance/istio/PilotExchanger.java @@ -56,7 +56,7 @@ public class PilotExchanger { return; } Set resourceName = ldsProtocol.getResourceNames(); - if (CollectionUtils.isEmpty(resourceName)) { + if (!CollectionUtils.isEmpty(resourceName)) { rdsProtocol.observeResource(resourceName, this::observeRoutes); }