update labelRouting to routing (#3077)

* update labelRouting to routing
pull/3082/head
HHoflittlefish777 2 years ago committed by GitHub
parent dbe8452833
commit 6b6a804258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,12 +20,12 @@ import java.util.ArrayList;
import java.util.List;
import com.alibaba.cloud.commons.governance.event.RoutingDataChangedEvent;
import com.alibaba.cloud.commons.governance.labelrouting.LabelRouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.MatchService;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.labelrouting.rule.HeaderRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.UrlRule;
import com.alibaba.cloud.commons.governance.routing.MatchService;
import com.alibaba.cloud.commons.governance.routing.RoutingRule;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.commons.governance.routing.rule.HeaderRoutingRule;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
import com.alibaba.cloud.commons.governance.routing.rule.UrlRoutingRule;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
@ -85,26 +85,26 @@ public class ConsumerApplication {
@GetMapping("/add")
public void getDataFromControlPlaneTest() {
List<RouteRule> routeRules = new ArrayList<>();
List<Rule> routeRules = new ArrayList<>();
List<MatchService> matchServices = new ArrayList<>();
UnifiedRouteDataStructure unifiedRouteDataStructure = new UnifiedRouteDataStructure();
UnifiedRoutingDataStructure unifiedRouteDataStructure = new UnifiedRoutingDataStructure();
unifiedRouteDataStructure.setTargetService("service-provider");
LabelRouteRule labelRouteData = new LabelRouteRule();
RoutingRule labelRouteData = new RoutingRule();
labelRouteData.setDefaultRouteVersion("v1");
RouteRule routeRule = new HeaderRule();
Rule routeRule = new HeaderRoutingRule();
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
RouteRule routeRule1 = new UrlRule.Parameter();
Rule routeRule1 = new UrlRoutingRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
routeRule1.setKey("id");
routeRule1.setValue("10");
RouteRule routeRule2 = new UrlRule.Path();
Rule routeRule2 = new UrlRoutingRule.PathRoutingRule();
routeRule2.setType("path");
routeRule2.setCondition("=");
routeRule2.setValue("/router-test");
@ -122,7 +122,7 @@ public class ConsumerApplication {
unifiedRouteDataStructure.setLabelRouteRule(labelRouteData);
List<UnifiedRouteDataStructure> unifiedRouteDataStructureList = new ArrayList<>();
List<UnifiedRoutingDataStructure> unifiedRouteDataStructureList = new ArrayList<>();
unifiedRouteDataStructureList.add(unifiedRouteDataStructure);
applicationContext.publishEvent(
new RoutingDataChangedEvent(this, unifiedRouteDataStructureList));
@ -130,26 +130,26 @@ public class ConsumerApplication {
@GetMapping("/update")
public void updateDataFromControlPlaneTest() {
List<RouteRule> routeRules = new ArrayList<>();
List<Rule> routeRules = new ArrayList<>();
List<MatchService> matchServices = new ArrayList<>();
UnifiedRouteDataStructure unifiedRouteDataStructure = new UnifiedRouteDataStructure();
UnifiedRoutingDataStructure unifiedRouteDataStructure = new UnifiedRoutingDataStructure();
unifiedRouteDataStructure.setTargetService("service-provider");
LabelRouteRule labelRouteData = new LabelRouteRule();
RoutingRule labelRouteData = new RoutingRule();
labelRouteData.setDefaultRouteVersion("v1");
RouteRule routeRule = new HeaderRule();
Rule routeRule = new HeaderRoutingRule();
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
RouteRule routeRule1 = new UrlRule.Parameter();
Rule routeRule1 = new UrlRoutingRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
routeRule1.setKey("id");
routeRule1.setValue("10");
RouteRule routeRule2 = new UrlRule.Path();
Rule routeRule2 = new UrlRoutingRule.PathRoutingRule();
routeRule2.setType("path");
routeRule2.setCondition("=");
routeRule2.setValue("/router-test");
@ -167,7 +167,7 @@ public class ConsumerApplication {
unifiedRouteDataStructure.setLabelRouteRule(labelRouteData);
List<UnifiedRouteDataStructure> unifiedRouteDataStructureList = new ArrayList<>();
List<UnifiedRoutingDataStructure> unifiedRouteDataStructureList = new ArrayList<>();
unifiedRouteDataStructureList.add(unifiedRouteDataStructure);
applicationContext.publishEvent(
new RoutingDataChangedEvent(this, unifiedRouteDataStructureList));

@ -18,7 +18,7 @@ package com.alibaba.cloud.commons.governance.event;
import java.util.Collection;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
/**
* @author musi
@ -30,15 +30,15 @@ public class RoutingDataChangedEvent extends GovernanceEvent {
/**
* Configuration for Label Routing.
*/
private final Collection<UnifiedRouteDataStructure> untiedRouterDataStructureList;
private final Collection<UnifiedRoutingDataStructure> untiedRouterDataStructureList;
public RoutingDataChangedEvent(Object source,
Collection<UnifiedRouteDataStructure> untiedRouterDataStructureList) {
Collection<UnifiedRoutingDataStructure> untiedRouterDataStructureList) {
super(source);
this.untiedRouterDataStructureList = untiedRouterDataStructureList;
}
public Collection<UnifiedRouteDataStructure> getUntiedRouterDataStructureList() {
public Collection<UnifiedRoutingDataStructure> getUntiedRouterDataStructureList() {
return untiedRouterDataStructureList;
}

@ -14,12 +14,12 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting;
package com.alibaba.cloud.commons.governance.routing;
import java.util.List;
import java.util.Objects;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
/**
* @author HH
@ -27,7 +27,7 @@ import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
*/
public class MatchService {
private List<RouteRule> ruleList;
private List<Rule> ruleList;
private String version;
@ -43,11 +43,11 @@ public class MatchService {
this.fallbackVersion = fallbackVersion;
}
public List<RouteRule> getRuleList() {
public List<Rule> getRuleList() {
return ruleList;
}
public void setRuleList(List<RouteRule> ruleList) {
public void setRuleList(List<Rule> ruleList) {
this.ruleList = ruleList;
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting;
package com.alibaba.cloud.commons.governance.routing;
import java.util.List;
import java.util.Objects;
@ -23,18 +23,18 @@ import java.util.Objects;
* @author HH
* @since 2.2.10-RC1
*/
public class LabelRouteRule {
public class RoutingRule {
private String defaultRouteVersion;
private String defaultRoutingVersion;
private List<MatchService> matchRouteList;
public String getDefaultRouteVersion() {
return defaultRouteVersion;
return defaultRoutingVersion;
}
public void setDefaultRouteVersion(String defaultRouteVersion) {
this.defaultRouteVersion = defaultRouteVersion;
this.defaultRoutingVersion = defaultRouteVersion;
}
public List<MatchService> getMatchRouteList() {
@ -53,19 +53,19 @@ public class LabelRouteRule {
if (o == null || getClass() != o.getClass()) {
return false;
}
LabelRouteRule that = (LabelRouteRule) o;
return Objects.equals(defaultRouteVersion, that.defaultRouteVersion)
RoutingRule that = (RoutingRule) o;
return Objects.equals(defaultRoutingVersion, that.defaultRoutingVersion)
&& Objects.equals(getMatchRouteList(), that.getMatchRouteList());
}
@Override
public int hashCode() {
return Objects.hash(defaultRouteVersion, getMatchRouteList());
return Objects.hash(defaultRoutingVersion, getMatchRouteList());
}
@Override
public String toString() {
return "LabelRouteData{" + "defaultRouteVersion='" + defaultRouteVersion + '\''
return "LabelRouteData{" + "defaultRouteVersion='" + defaultRoutingVersion + '\''
+ ", matchRouteList=" + matchRouteList + '}';
}

@ -14,24 +14,24 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting;
package com.alibaba.cloud.commons.governance.routing;
/**
* @author HH
* @since 2.2.10-RC1
*/
public class UnifiedRouteDataStructure {
public class UnifiedRoutingDataStructure {
private LabelRouteRule labelRouteRule;
private RoutingRule routingRule;
private String targetService;
public LabelRouteRule getLabelRouteRule() {
return labelRouteRule;
public RoutingRule getLabelRouteRule() {
return routingRule;
}
public void setLabelRouteRule(LabelRouteRule labelRouteRule) {
this.labelRouteRule = labelRouteRule;
public void setLabelRouteRule(RoutingRule labelRouteRule) {
this.routingRule = labelRouteRule;
}
public String getTargetService() {
@ -44,7 +44,7 @@ public class UnifiedRouteDataStructure {
@Override
public String toString() {
return "UntiedRouteDataStructure{" + "labelRouteData=" + labelRouteRule
return "UntiedRoutingDataStructure{" + "RoutingData=" + routingRule
+ ", targetService='" + targetService + '\'' + '}';
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting.rule;
package com.alibaba.cloud.commons.governance.routing.rule;
import java.util.Objects;
@ -22,7 +22,7 @@ import java.util.Objects;
* @author HH
* @since 2.2.10-RC1
*/
public class HeaderRule implements RouteRule {
public class HeaderRoutingRule implements Rule {
private String type;
@ -80,7 +80,7 @@ public class HeaderRule implements RouteRule {
if (o == null || getClass() != o.getClass()) {
return false;
}
HeaderRule that = (HeaderRule) o;
HeaderRoutingRule that = (HeaderRoutingRule) o;
return Objects.equals(getType(), that.getType())
&& Objects.equals(getCondition(), that.getCondition())
&& Objects.equals(getKey(), that.getKey())
@ -94,8 +94,8 @@ public class HeaderRule implements RouteRule {
@Override
public String toString() {
return "HeaderRule{" + "type='" + type + '\'' + ", condition='" + condition + '\''
+ ", key='" + key + '\'' + ", value='" + value + '\'' + '}';
return "HeaderRoutingRule{" + "type='" + type + '\'' + ", condition='" + condition
+ '\'' + ", key='" + key + '\'' + ", value='" + value + '\'' + '}';
}
}

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting.rule;
package com.alibaba.cloud.commons.governance.routing.rule;
/**
* @author HH
* @since 2.2.10-RC1
*/
public interface RouteRule {
public interface Rule {
/**
* get type of rule.

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.commons.governance.labelrouting.rule;
package com.alibaba.cloud.commons.governance.routing.rule;
import java.util.Objects;
@ -22,9 +22,9 @@ import java.util.Objects;
* @author HH
* @since 2.2.10-RC1
*/
public class UrlRule {
public class UrlRoutingRule {
public static class Path implements RouteRule {
public static class PathRoutingRule implements Rule {
private String type;
@ -80,7 +80,7 @@ public class UrlRule {
if (o == null || getClass() != o.getClass()) {
return false;
}
Path path = (Path) o;
PathRoutingRule path = (PathRoutingRule) o;
return Objects.equals(getType(), path.getType())
&& Objects.equals(getCondition(), path.getCondition())
&& Objects.equals(getValue(), path.getValue());
@ -93,13 +93,13 @@ public class UrlRule {
@Override
public String toString() {
return "Path{" + "type='" + type + '\'' + ", condition='" + condition + '\''
+ ", value='" + value + '\'' + '}';
return "PathRoutingRule{" + "type='" + type + '\'' + ", condition='"
+ condition + '\'' + ", value='" + value + '\'' + '}';
}
}
public static class Parameter implements RouteRule {
public static class Parameter implements Rule {
private String type;
@ -171,8 +171,9 @@ public class UrlRule {
@Override
public String toString() {
return "Parameter{" + "type='" + type + '\'' + ", condition='" + condition
+ '\'' + ", key='" + key + '\'' + ", value='" + value + '\'' + '}';
return "ParameterRoutingRule{" + "type='" + type + '\'' + ", condition='"
+ condition + '\'' + ", key='" + key + '\'' + ", value='" + value
+ '\'' + '}';
}
}

@ -22,12 +22,12 @@ import java.util.List;
import java.util.Map;
import com.alibaba.cloud.commons.governance.event.RoutingDataChangedEvent;
import com.alibaba.cloud.commons.governance.labelrouting.LabelRouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.MatchService;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.labelrouting.rule.HeaderRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.UrlRule;
import com.alibaba.cloud.commons.governance.routing.MatchService;
import com.alibaba.cloud.commons.governance.routing.RoutingRule;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.commons.governance.routing.rule.HeaderRoutingRule;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
import com.alibaba.cloud.commons.governance.routing.rule.UrlRoutingRule;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.commons.matcher.StringMatcherType;
import com.alibaba.cloud.governance.istio.constant.IstioConstants;
@ -54,11 +54,11 @@ public class RoutingXdsResolveFilter
if (routeConfigurations == null) {
return false;
}
Map<String, UnifiedRouteDataStructure> untiedRouteDataStructures = new HashMap<>();
Map<String, UnifiedRoutingDataStructure> untiedRouteDataStructures = new HashMap<>();
for (RouteConfiguration routeConfiguration : routeConfigurations) {
List<VirtualHost> virtualHosts = routeConfiguration.getVirtualHostsList();
for (VirtualHost virtualHost : virtualHosts) {
UnifiedRouteDataStructure unifiedRouteDataStructure = new UnifiedRouteDataStructure();
UnifiedRoutingDataStructure unifiedRouteDataStructure = new UnifiedRoutingDataStructure();
String targetService = "";
String[] serviceAndPort = virtualHost.getName().split(":");
if (serviceAndPort.length > 0) {
@ -69,7 +69,7 @@ public class RoutingXdsResolveFilter
}
unifiedRouteDataStructure.setTargetService(targetService);
List<Route> routes = virtualHost.getRoutesList();
LabelRouteRule labelRouteRule = getRouteData(routes);
RoutingRule labelRouteRule = getRouteData(routes);
unifiedRouteDataStructure.setLabelRouteRule(labelRouteRule);
untiedRouteDataStructures.put(
unifiedRouteDataStructure.getTargetService(),
@ -81,9 +81,9 @@ public class RoutingXdsResolveFilter
return true;
}
private LabelRouteRule getRouteData(List<Route> routes) {
private RoutingRule getRouteData(List<Route> routes) {
List<MatchService> matchServices = new ArrayList<>();
LabelRouteRule labelRouteRule = new LabelRouteRule();
RoutingRule labelRouteRule = new RoutingRule();
for (Route route : routes) {
String cluster = route.getRoute().getCluster();
if (StringUtils.isNotEmpty(cluster)) {
@ -122,10 +122,12 @@ public class RoutingXdsResolveFilter
return matchService;
}
private List<RouteRule> match2RouteRules(RouteMatch routeMatch) {
List<RouteRule> routeRules = new ArrayList<>();
private List<Rule> match2RouteRules(
RouteMatch routeMatch) {
List<Rule> routeRules = new ArrayList<>();
for (HeaderMatcher headerMatcher : routeMatch.getHeadersList()) {
HeaderRule headerRule = ConvUtil.headerMatcher2HeaderRule(headerMatcher);
HeaderRoutingRule headerRule = ConvUtil
.headerMatcher2HeaderRule(headerMatcher);
if (headerRule != null) {
routeRules.add(headerRule);
}
@ -133,14 +135,14 @@ public class RoutingXdsResolveFilter
for (QueryParameterMatcher parameterMatcher : routeMatch
.getQueryParametersList()) {
UrlRule.Parameter parameter = ConvUtil
UrlRoutingRule.Parameter parameter = ConvUtil
.parameterMatcher2ParameterRule(parameterMatcher);
if (parameter != null) {
routeRules.add(parameter);
}
}
UrlRule.Path path = new UrlRule.Path();
UrlRoutingRule.PathRoutingRule path = new UrlRoutingRule.PathRoutingRule();
path.setType(PATH);
switch (routeMatch.getPathSpecifierCase()) {
case PREFIX:

@ -16,8 +16,8 @@
package com.alibaba.cloud.governance.istio.util;
import com.alibaba.cloud.commons.governance.labelrouting.rule.HeaderRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.UrlRule;
import com.alibaba.cloud.commons.governance.routing.rule.HeaderRoutingRule;
import com.alibaba.cloud.commons.governance.routing.rule.UrlRoutingRule;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.commons.matcher.IpMatcher;
import com.alibaba.cloud.commons.matcher.StringMatcher;
@ -125,9 +125,9 @@ public final class ConvUtil {
return headerMatcher.getStringMatch();
}
public static UrlRule.Parameter parameterMatcher2ParameterRule(
public static UrlRoutingRule.Parameter parameterMatcher2ParameterRule(
QueryParameterMatcher queryParameterMatcher) {
UrlRule.Parameter parameter = new UrlRule.Parameter();
UrlRoutingRule.Parameter parameter = new UrlRoutingRule.Parameter();
StringMatcher stringMatcher = ConvUtil
.convStringMatcher(queryParameterMatcher.getStringMatch());
if (stringMatcher != null) {
@ -140,11 +140,12 @@ public final class ConvUtil {
return null;
}
public static HeaderRule headerMatcher2HeaderRule(HeaderMatcher headerMatcher) {
public static HeaderRoutingRule headerMatcher2HeaderRule(
HeaderMatcher headerMatcher) {
StringMatcher stringMatcher = ConvUtil
.convStringMatcher(ConvUtil.headerMatch2StringMatch(headerMatcher));
if (stringMatcher != null) {
HeaderRule headerRule = new HeaderRule();
HeaderRoutingRule headerRule = new HeaderRoutingRule();
headerRule.setCondition(stringMatcher.getType().toString());
headerRule.setKey(headerMatcher.getName());
headerRule.setValue(stringMatcher.getMatcher());

@ -27,9 +27,9 @@ import com.alibaba.cloud.governance.auth.AuthenticationAutoConfiguration;
import com.alibaba.cloud.governance.auth.repository.AuthRepository;
import com.alibaba.cloud.governance.istio.protocol.impl.LdsProtocol;
import com.alibaba.cloud.governance.istio.protocol.impl.RdsProtocol;
import com.alibaba.cloud.router.LabelRoutingAutoConfiguration;
import com.alibaba.cloud.router.repository.FilterService;
import com.alibaba.cloud.router.repository.RouteDataRepository;
import com.alibaba.cloud.routing.RoutingAutoConfiguration;
import com.alibaba.cloud.routing.repository.FilterService;
import com.alibaba.cloud.routing.repository.RoutingDataRepository;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.envoyproxy.envoy.config.listener.v3.Listener;
import io.envoyproxy.envoy.config.route.v3.RouteConfiguration;
@ -71,7 +71,7 @@ public class XdsRulesTests {
private AuthRepository authRepository;
@Autowired
private RouteDataRepository routeDataRepository;
private RoutingDataRepository routeDataRepository;
@Autowired
private LdsProtocol ldsProtocol;
@ -133,7 +133,7 @@ public class XdsRulesTests {
@Configuration
@EnableAutoConfiguration
@ImportAutoConfiguration({ XdsAutoConfiguration.class,
AuthenticationAutoConfiguration.class, LabelRoutingAutoConfiguration.class })
AuthenticationAutoConfiguration.class, RoutingAutoConfiguration.class })
public static class TestConfig {
@Bean(name = TARGET_SERVICE + FilterService.FEIGN_CLIENT_BEAN_SPECIFICATION)

@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.List;
import com.alibaba.cloud.commons.governance.event.RoutingDataChangedEvent;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.governance.opensergo.util.ConvUtils;
import com.google.protobuf.InvalidProtocolBufferException;
@ -92,7 +92,7 @@ public class OpenSergoTrafficExchanger implements ApplicationContextAware {
log.debug("OpenSergo client subscribeKey:{} receive message :{}",
subscribeKey, dataList);
try {
Collection<UnifiedRouteDataStructure> rules = openSergoTrafficRouterParser
Collection<UnifiedRoutingDataStructure> rules = openSergoTrafficRouterParser
.resolveLabelRouting(
(List<RouteConfiguration>) dataList);
applicationContext.publishEvent(

@ -22,12 +22,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.cloud.commons.governance.labelrouting.LabelRouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.MatchService;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.labelrouting.rule.HeaderRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.rule.UrlRule;
import com.alibaba.cloud.commons.governance.routing.MatchService;
import com.alibaba.cloud.commons.governance.routing.RoutingRule;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.commons.governance.routing.rule.HeaderRoutingRule;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
import com.alibaba.cloud.commons.governance.routing.rule.UrlRoutingRule;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.commons.matcher.StringMatcher;
import com.alibaba.cloud.commons.matcher.StringMatcherType;
@ -70,17 +70,17 @@ public class OpenSergoTrafficRouterParser {
* @return spring cloud alibaba router rules.
* @throws InvalidProtocolBufferException transform exception.
*/
public Collection<UnifiedRouteDataStructure> resolveLabelRouting(
public Collection<UnifiedRoutingDataStructure> resolveLabelRouting(
List<RouteConfiguration> routeConfigurations)
throws InvalidProtocolBufferException {
if (routeConfigurations == null) {
return new ArrayList<>();
}
Map<String, UnifiedRouteDataStructure> unifiedRouteDataStructures = new HashMap<>();
Map<String, UnifiedRoutingDataStructure> unifiedRouteDataStructures = new HashMap<>();
for (RouteConfiguration routeConfiguration : routeConfigurations) {
List<VirtualHost> virtualHosts = routeConfiguration.getVirtualHostsList();
for (VirtualHost virtualHost : virtualHosts) {
UnifiedRouteDataStructure unifiedRouteDataStructure = new UnifiedRouteDataStructure();
UnifiedRoutingDataStructure unifiedRouteDataStructure = new UnifiedRoutingDataStructure();
String targetService = "";
String[] serviceAndPort = virtualHost.getName().split(":");
if (serviceAndPort.length > 0) {
@ -88,7 +88,7 @@ public class OpenSergoTrafficRouterParser {
}
unifiedRouteDataStructure.setTargetService(targetService);
List<Route> routes = virtualHost.getRoutesList();
LabelRouteRule labelRouteRule = getLabelRouteData(routes);
RoutingRule labelRouteRule = getLabelRouteData(routes);
unifiedRouteDataStructure.setLabelRouteRule(labelRouteRule);
unifiedRouteDataStructures.put(
unifiedRouteDataStructure.getTargetService(),
@ -98,10 +98,10 @@ public class OpenSergoTrafficRouterParser {
return unifiedRouteDataStructures.values();
}
private LabelRouteRule getLabelRouteData(List<Route> routes)
private RoutingRule getLabelRouteData(List<Route> routes)
throws InvalidProtocolBufferException {
List<MatchService> matchServices = new ArrayList<>();
LabelRouteRule labelRouteRule = new LabelRouteRule();
RoutingRule labelRouteRule = new RoutingRule();
for (Route route : routes) {
ClusterSpecifierPlugin clusterSpecifierPlugin = route.getRoute()
.getInlineClusterSpecifierPlugin();
@ -175,10 +175,10 @@ public class OpenSergoTrafficRouterParser {
return version;
}
private List<RouteRule> match2RouteRules(RouteMatch routeMatch) {
List<RouteRule> routeRules = new ArrayList<>();
private List<Rule> match2RouteRules(RouteMatch routeMatch) {
List<Rule> routeRules = new ArrayList<>();
for (HeaderMatcher headerMatcher : routeMatch.getHeadersList()) {
HeaderRule headerRule = headerMatcher2HeaderRule(headerMatcher);
HeaderRoutingRule headerRule = headerMatcher2HeaderRule(headerMatcher);
if (headerRule != null) {
routeRules.add(headerRule);
}
@ -186,14 +186,14 @@ public class OpenSergoTrafficRouterParser {
for (QueryParameterMatcher parameterMatcher : routeMatch
.getQueryParametersList()) {
UrlRule.Parameter parameter = parameterMatcher2ParameterRule(
UrlRoutingRule.Parameter parameter = parameterMatcher2ParameterRule(
parameterMatcher);
if (parameter != null) {
routeRules.add(parameter);
}
}
UrlRule.Path path = new UrlRule.Path();
UrlRoutingRule.PathRoutingRule path = new UrlRoutingRule.PathRoutingRule();
path.setType(PATH);
switch (routeMatch.getPathSpecifierCase()) {
case PREFIX:
@ -222,9 +222,9 @@ public class OpenSergoTrafficRouterParser {
return routeRules;
}
private UrlRule.Parameter parameterMatcher2ParameterRule(
private UrlRoutingRule.Parameter parameterMatcher2ParameterRule(
QueryParameterMatcher queryParameterMatcher) {
UrlRule.Parameter parameter = new UrlRule.Parameter();
UrlRoutingRule.Parameter parameter = new UrlRoutingRule.Parameter();
StringMatcher stringMatcher = ConvUtils
.convStringMatcher(queryParameterMatcher.getStringMatch());
if (stringMatcher != null) {
@ -237,11 +237,11 @@ public class OpenSergoTrafficRouterParser {
return null;
}
private HeaderRule headerMatcher2HeaderRule(HeaderMatcher headerMatcher) {
private HeaderRoutingRule headerMatcher2HeaderRule(HeaderMatcher headerMatcher) {
StringMatcher stringMatcher = ConvUtils
.convStringMatcher(ConvUtils.headerMatch2StringMatch(headerMatcher));
if (stringMatcher != null) {
HeaderRule headerRule = new HeaderRule();
HeaderRoutingRule headerRule = new HeaderRoutingRule();
headerRule.setCondition(stringMatcher.getType().toString());
headerRule.setKey(headerMatcher.getName());
headerRule.setValue(stringMatcher.getMatcher());

@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import io.envoyproxy.envoy.config.route.v3.HeaderMatcher;
import io.envoyproxy.envoy.config.route.v3.Route;
import io.envoyproxy.envoy.config.route.v3.RouteAction;
@ -62,7 +62,7 @@ public class OpenSergoRuleTests {
.setName("service-provider").addVirtualHosts(virtualHost).build();
List<RouteConfiguration> routeConfigurations = new ArrayList<>();
routeConfigurations.add(routeConfiguration);
Collection<UnifiedRouteDataStructure> rules = openSergoTrafficRouterParser
Collection<UnifiedRoutingDataStructure> rules = openSergoTrafficRouterParser
.resolveLabelRouting(routeConfigurations);
Assert.assertEquals(rules.size(), 1);
}

@ -14,11 +14,11 @@
* limitations under the License.
*/
package com.alibaba.cloud.router;
package com.alibaba.cloud.routing;
import com.alibaba.cloud.router.listener.LabelRouteDataListener;
import com.alibaba.cloud.router.repository.FilterService;
import com.alibaba.cloud.router.repository.RouteDataRepository;
import com.alibaba.cloud.routing.listener.RoutingDataListener;
import com.alibaba.cloud.routing.repository.FilterService;
import com.alibaba.cloud.routing.repository.RoutingDataRepository;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -30,18 +30,18 @@ import org.springframework.context.annotation.Configuration;
* @since 2.2.10-RC1
*/
@Configuration(proxyBeanMethods = false)
@AutoConfigureOrder(LabelRoutingAutoConfiguration.LABEL_ROUTING_AUTO_CONFIG_ORDER)
public class LabelRoutingAutoConfiguration {
@AutoConfigureOrder(RoutingAutoConfiguration.ROUTING_AUTO_CONFIG_ORDER)
public class RoutingAutoConfiguration {
/**
* Order of label routing auto config.
*/
public static final int LABEL_ROUTING_AUTO_CONFIG_ORDER = 10;
public static final int ROUTING_AUTO_CONFIG_ORDER = 10;
@Bean
@ConditionalOnMissingBean
public RouteDataRepository routeDataRepository() {
return new RouteDataRepository();
public RoutingDataRepository routingDataRepository() {
return new RoutingDataRepository();
}
@Bean
@ -51,9 +51,9 @@ public class LabelRoutingAutoConfiguration {
}
@Bean
public LabelRouteDataListener labelRouteDataListener(
RouteDataRepository routeDataRepository, FilterService filterService) {
return new LabelRouteDataListener(routeDataRepository, filterService);
public RoutingDataListener routingDataListener(
RoutingDataRepository routingDataRepository, FilterService filterService) {
return new RoutingDataListener(routingDataRepository, filterService);
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router;
package com.alibaba.cloud.routing;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -22,8 +22,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author HH
* @since 2.2.10-RC1
*/
@ConfigurationProperties(prefix = RouterProperties.PROPERTY_PREFIX)
public class RouterProperties {
@ConfigurationProperties(prefix = RoutingProperties.PROPERTY_PREFIX)
public class RoutingProperties {
/**
* Properties prefix.

@ -14,9 +14,9 @@
* limitations under the License.
*/
package com.alibaba.cloud.router;
package com.alibaba.cloud.routing;
import com.alibaba.cloud.router.publish.TargetServiceChangedPublisher;
import com.alibaba.cloud.routing.publish.TargetServiceChangedPublisher;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -28,13 +28,13 @@ import org.springframework.context.annotation.Configuration;
* @since 2.2.10-RC1
*/
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ RouterProperties.class })
public class RouterPropertiesAutoConfiguration {
@EnableConfigurationProperties({ RoutingProperties.class })
public class RoutingPropertiesAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public RouterProperties routerProperties() {
return new RouterProperties();
public RoutingProperties routingProperties() {
return new RoutingProperties();
}
@Bean

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.feign;
package com.alibaba.cloud.routing.feign;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.cloud.router.util.RequestContext;
import com.alibaba.cloud.routing.util.RequestContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.Logger;
@ -30,9 +30,10 @@ import org.slf4j.LoggerFactory;
* @author HH
* @since 2.2.10-RC1
*/
public class FeignInterceptor implements RequestInterceptor {
public class RoutingFeignInterceptor implements RequestInterceptor {
private static final Logger LOG = LoggerFactory.getLogger(FeignInterceptor.class);
private static final Logger LOG = LoggerFactory
.getLogger(RoutingFeignInterceptor.class);
@Override
public void apply(RequestTemplate requestTemplate) {

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.feign;
package com.alibaba.cloud.routing.feign;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
@ -25,12 +25,12 @@ import org.springframework.context.annotation.Configuration;
* @since 2.2.10-RC1
*/
@Configuration(proxyBeanMethods = false)
public class FeignInterceptorAutoConfiguration {
public class RoutingFeignInterceptorAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public FeignInterceptor feignInterceptor() {
return new FeignInterceptor();
public RoutingFeignInterceptor routingFeignInterceptor() {
return new RoutingFeignInterceptor();
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.listener;
package com.alibaba.cloud.routing.listener;
import java.util.Collection;
import java.util.HashSet;
@ -22,9 +22,9 @@ import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.cloud.commons.governance.event.RoutingDataChangedEvent;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.router.repository.FilterService;
import com.alibaba.cloud.router.repository.RouteDataRepository;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.routing.repository.FilterService;
import com.alibaba.cloud.routing.repository.RoutingDataRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,39 +35,37 @@ import org.springframework.context.ApplicationListener;
* @author <a href="liuziming@buaa.edu.cn"></a>
* @since 2.2.10-RC1
*/
public class LabelRouteDataListener
implements ApplicationListener<RoutingDataChangedEvent> {
public class RoutingDataListener implements ApplicationListener<RoutingDataChangedEvent> {
private static final Logger log = LoggerFactory
.getLogger(LabelRouteDataListener.class);
private static final Logger log = LoggerFactory.getLogger(RoutingDataListener.class);
private RouteDataRepository routeDataRepository;
private RoutingDataRepository routingDataRepository;
private FilterService filterService;
public LabelRouteDataListener(RouteDataRepository routeDataRepository,
public RoutingDataListener(RoutingDataRepository routeDataRepository,
FilterService filterService) {
this.routeDataRepository = routeDataRepository;
this.routingDataRepository = routeDataRepository;
this.filterService = filterService;
}
@Override
public void onApplicationEvent(RoutingDataChangedEvent event) {
try {
Collection<UnifiedRouteDataStructure> untiedRouterDataStructureList = event
Collection<UnifiedRoutingDataStructure> unifiedRoutingDataStructureList = event
.getUntiedRouterDataStructureList();
// Filter service.
// todo can cache the result
HashSet<String> definitionFeignService = filterService
.getDefinitionFeignService(untiedRouterDataStructureList.size());
List<UnifiedRouteDataStructure> routeDatalist = untiedRouterDataStructureList
.getDefinitionFeignService(unifiedRoutingDataStructureList.size());
List<UnifiedRoutingDataStructure> routeDatalist = unifiedRoutingDataStructureList
.stream()
.filter(unifiedRouteDataStructure -> definitionFeignService
.contains(unifiedRouteDataStructure.getTargetService()))
.collect(Collectors.toList());
routeDataRepository.updateRouteData(routeDatalist);
routingDataRepository.updateRouteData(routeDatalist);
}
catch (Exception e) {
log.error("Failed to update route data", e);

@ -14,17 +14,17 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.repository;
package com.alibaba.cloud.routing.repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.cloud.commons.governance.labelrouting.LabelRouteRule;
import com.alibaba.cloud.commons.governance.labelrouting.MatchService;
import com.alibaba.cloud.commons.governance.labelrouting.UnifiedRouteDataStructure;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.routing.MatchService;
import com.alibaba.cloud.commons.governance.routing.RoutingRule;
import com.alibaba.cloud.commons.governance.routing.UnifiedRoutingDataStructure;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,12 +34,13 @@ import org.springframework.util.CollectionUtils;
* @author HH
* @since 2.2.10-RC1
*/
public class RouteDataRepository {
public class RoutingDataRepository {
private static final Logger LOG = LoggerFactory.getLogger(RouteDataRepository.class);
private static final Logger LOG = LoggerFactory
.getLogger(RoutingDataRepository.class);
/**
* Key is service name,value is hashmap,which key is single RouteRule key,value is
* Key is service name,value is hashmap,which key is single RoutingRule key,value is
* match service. Use double hash index to parse route rule.
*/
private ConcurrentHashMap<String, HashMap<String, List<MatchService>>> routeCache = new ConcurrentHashMap<>();
@ -47,7 +48,7 @@ public class RouteDataRepository {
/**
* The default version of each service.
*/
private ConcurrentHashMap<String, String> defaultRouteVersion = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, String> defaultRoutingVersion = new ConcurrentHashMap<>();
/**
* Sign of path.
@ -74,13 +75,13 @@ public class RouteDataRepository {
*/
public static final int MIN_WEIGHT = 0;
public void updateRouteData(final List<UnifiedRouteDataStructure> routeDataList) {
public void updateRouteData(final List<UnifiedRoutingDataStructure> routeDataList) {
ConcurrentHashMap<String, HashMap<String, List<MatchService>>> newRouteCache = new ConcurrentHashMap<>();
ConcurrentHashMap<String, List<MatchService>> newPathRuleMap = new ConcurrentHashMap<>();
for (UnifiedRouteDataStructure routeData : routeDataList) {
for (UnifiedRoutingDataStructure routeData : routeDataList) {
nonNullCheck(routeData);
buildHashIndex(routeData, newRouteCache, newPathRuleMap);
defaultRouteVersion.put(routeData.getTargetService(),
defaultRoutingVersion.put(routeData.getTargetService(),
routeData.getLabelRouteRule().getDefaultRouteVersion());
}
// Replace it atomically
@ -88,16 +89,16 @@ public class RouteDataRepository {
this.pathRuleMap = newPathRuleMap;
}
private void nonNullCheck(UnifiedRouteDataStructure unifiedRouteDataStructure) {
String targetService = unifiedRouteDataStructure.getTargetService();
private void nonNullCheck(UnifiedRoutingDataStructure unifiedRoutingDataStructure) {
String targetService = unifiedRoutingDataStructure.getTargetService();
if (targetService == null) {
LOG.error("Lose target Service name.");
}
final LabelRouteRule labelRouteData = unifiedRouteDataStructure
final RoutingRule labelRouteData = unifiedRoutingDataStructure
.getLabelRouteRule();
final List<MatchService> matchServiceList = labelRouteData.getMatchRouteList();
for (MatchService matchService : matchServiceList) {
final List<RouteRule> ruleList = matchService.getRuleList();
final List<Rule> ruleList = matchService.getRuleList();
String version = matchService.getVersion();
Integer weight = matchService.getWeight();
if (CollectionUtils.isEmpty(ruleList)) {
@ -118,7 +119,7 @@ public class RouteDataRepository {
}
}
private void buildHashIndex(final UnifiedRouteDataStructure routerData,
private void buildHashIndex(final UnifiedRoutingDataStructure routerData,
ConcurrentHashMap<String, HashMap<String, List<MatchService>>> newRouteCache,
ConcurrentHashMap<String, List<MatchService>> newPathRuleMap) {
final List<MatchService> matchRouteList = routerData.getLabelRouteRule()
@ -126,7 +127,7 @@ public class RouteDataRepository {
HashMap<String, List<MatchService>> singleRuleMap = new HashMap<>();
for (MatchService matchService : matchRouteList) {
List<RouteRule> ruleList = matchService.getRuleList();
List<Rule> ruleList = matchService.getRuleList();
// Take out the path label separately, because there is no key for hash index.
if (ruleList.size() == 1
@ -140,7 +141,7 @@ public class RouteDataRepository {
newPathRuleMap.put(routerData.getTargetService(), matchServiceList);
continue;
}
for (RouteRule routeRule : ruleList) {
for (Rule routeRule : ruleList) {
List<MatchService> matchServiceList = singleRuleMap
.get(routeRule.getKey());
if (matchServiceList == null) {
@ -160,7 +161,7 @@ public class RouteDataRepository {
}
public String getDefaultRouteVersion(String targetService) {
return defaultRouteVersion.get(targetService);
return defaultRoutingVersion.get(targetService);
}
public List<MatchService> getPathRules(String targetService) {

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.ribbon;
package com.alibaba.cloud.routing.ribbon;
import java.util.ArrayList;
import java.util.Arrays;
@ -27,17 +27,17 @@ import java.util.concurrent.ThreadLocalRandom;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.cloud.commons.governance.labelrouting.MatchService;
import com.alibaba.cloud.commons.governance.labelrouting.rule.RouteRule;
import com.alibaba.cloud.commons.governance.routing.MatchService;
import com.alibaba.cloud.commons.governance.routing.rule.Rule;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.cloud.nacos.NacosServiceManager;
import com.alibaba.cloud.nacos.ribbon.NacosServer;
import com.alibaba.cloud.router.RouterProperties;
import com.alibaba.cloud.router.publish.TargetServiceChangedPublisher;
import com.alibaba.cloud.router.repository.RouteDataRepository;
import com.alibaba.cloud.router.util.ConditionMatchUtil;
import com.alibaba.cloud.router.util.LoadBalanceUtil;
import com.alibaba.cloud.router.util.RequestContext;
import com.alibaba.cloud.routing.RoutingProperties;
import com.alibaba.cloud.routing.publish.TargetServiceChangedPublisher;
import com.alibaba.cloud.routing.repository.RoutingDataRepository;
import com.alibaba.cloud.routing.util.ConditionMatchUtil;
import com.alibaba.cloud.routing.util.LoadBalanceUtil;
import com.alibaba.cloud.routing.util.RequestContext;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.netflix.loadbalancer.AbstractServerPredicate;
@ -54,9 +54,10 @@ import org.springframework.util.CollectionUtils;
* @author HH
* @since 2.2.10-RC1
*/
public class LabelRouteLBRule extends PredicateBasedRule {
public class RoutingLoadBalanceRule extends PredicateBasedRule {
private static final Logger LOG = LoggerFactory.getLogger(LabelRouteLBRule.class);
private static final Logger LOG = LoggerFactory
.getLogger(RoutingLoadBalanceRule.class);
/**
* Support Parsing Rules from path,only URI at present.
@ -110,10 +111,10 @@ public class LabelRouteLBRule extends PredicateBasedRule {
private NacosServiceManager nacosServiceManager;
@Autowired
private RouteDataRepository routeDataRepository;
private RoutingDataRepository routingDataRepository;
@Autowired
private RouterProperties routerProperties;
private RoutingProperties routingProperties;
@Autowired
private TargetServiceChangedPublisher targetServiceChangedPublisher;
@ -126,11 +127,11 @@ public class LabelRouteLBRule extends PredicateBasedRule {
targetServiceChangedPublisher.addTargetService(targetServiceName);
// If routeData isn't present, use normal load balance rule.
final HashMap<String, List<MatchService>> routeData = routeDataRepository
final HashMap<String, List<MatchService>> routeData = routingDataRepository
.getRouteRule(targetServiceName);
if (routeData == null) {
return loadBalanceUtil.loadBalanceByOrdinaryRule(loadBalancer, key,
routerProperties.getRule());
routingProperties.getRule());
}
// Get instances from register-center.
@ -214,7 +215,7 @@ public class LabelRouteLBRule extends PredicateBasedRule {
}
}
final Map<String, String[]> parameterMap = request.getParameterMap();
int defaultVersionWeight = RouteDataRepository.SUM_WEIGHT;
int defaultVersionWeight = RoutingDataRepository.SUM_WEIGHT;
boolean isMatch = false;
// Parse rule.
@ -244,7 +245,7 @@ public class LabelRouteLBRule extends PredicateBasedRule {
}
}
final List<MatchService> pathRules = routeDataRepository
final List<MatchService> pathRules = routingDataRepository
.getPathRules(targetServiceName);
if (!isMatch && pathRules != null) {
for (MatchService matchService : pathRules) {
@ -260,8 +261,8 @@ public class LabelRouteLBRule extends PredicateBasedRule {
}
// Add default route
if (defaultVersionWeight > RouteDataRepository.MIN_WEIGHT) {
String defaultRouteVersion = routeDataRepository
if (defaultVersionWeight > RoutingDataRepository.MIN_WEIGHT) {
String defaultRouteVersion = routingDataRepository
.getDefaultRouteVersion(targetServiceName);
versionSet.add(defaultRouteVersion);
weightMap.put(defaultRouteVersion, defaultVersionWeight);
@ -275,18 +276,18 @@ public class LabelRouteLBRule extends PredicateBasedRule {
HashSet<String> versionSet, HashMap<String, Integer> weightMap,
HashSet<String> fallbackVersionSet,
HashMap<String, Integer> fallbackWeightMap) {
final List<MatchService> matchServiceList = routeDataRepository
final List<MatchService> matchServiceList = routingDataRepository
.getRouteRule(targetServiceName).get(keyName);
if (matchServiceList == null) {
return NO_MATCH;
}
for (MatchService matchService : matchServiceList) {
final List<RouteRule> ruleList = matchService.getRuleList();
final List<Rule> ruleList = matchService.getRuleList();
String version = matchService.getVersion();
Integer weight = matchService.getWeight();
String fallback = matchService.getFallback();
boolean isMatchRule = true;
for (RouteRule routeRule : ruleList) {
for (Rule routeRule : ruleList) {
String type = routeRule.getType();
switch (type) {
case PATH:
@ -318,7 +319,7 @@ public class LabelRouteLBRule extends PredicateBasedRule {
return NO_MATCH;
}
private boolean parseRequestPath(final RouteRule routeRule,
private boolean parseRequestPath(final Rule routeRule,
final HttpServletRequest request) {
String condition = routeRule.getCondition();
String value = routeRule.getValue();
@ -326,7 +327,7 @@ public class LabelRouteLBRule extends PredicateBasedRule {
return conditionMatch(condition, value, uri);
}
private boolean parseRequestHeader(final RouteRule routeRule,
private boolean parseRequestHeader(final Rule routeRule,
final HashMap<String, String> requestHeaders) {
if (requestHeaders.size() == 0) {
return false;
@ -337,7 +338,7 @@ public class LabelRouteLBRule extends PredicateBasedRule {
return conditionMatch(condition, value, headerValue);
}
private boolean parseRequestParameter(final RouteRule routeRule,
private boolean parseRequestParameter(final Rule routeRule,
final Map<String, String[]> parameterMap) {
if (parameterMap == null || parameterMap.size() == 0) {
return false;
@ -389,12 +390,12 @@ public class LabelRouteLBRule extends PredicateBasedRule {
}
}
if (sum > RouteDataRepository.SUM_WEIGHT) {
LOG.error("Sum of weight has over {} ", RouteDataRepository.SUM_WEIGHT);
if (sum > RoutingDataRepository.SUM_WEIGHT) {
LOG.error("Sum of weight has over {} ", RoutingDataRepository.SUM_WEIGHT);
}
double random = ThreadLocalRandom.current().nextDouble(
RouteDataRepository.MIN_WEIGHT, RouteDataRepository.SUM_WEIGHT);
RoutingDataRepository.MIN_WEIGHT, RoutingDataRepository.SUM_WEIGHT);
int chooseServiceIndex = Arrays.binarySearch(weightArray, random);
if (chooseServiceIndex < 0) {
chooseServiceIndex = -chooseServiceIndex - 1;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.ribbon;
package com.alibaba.cloud.routing.ribbon;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
@ -25,12 +25,12 @@ import org.springframework.context.annotation.Configuration;
* @since 2.2.10-RC1
*/
@Configuration(proxyBeanMethods = false)
public class LabelRouteLBRuleAutoConfiguration {
public class RoutingLoadBalanceRuleAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public LabelRouteLBRule labelRouteRule() {
return new LabelRouteLBRule();
public RoutingLoadBalanceRule routingLoadBalanceRule() {
return new RoutingLoadBalanceRule();
}
}

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.util;
package com.alibaba.cloud.routing.util;
import com.netflix.loadbalancer.AvailabilityFilteringRule;
import com.netflix.loadbalancer.BestAvailableRule;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.web;
package com.alibaba.cloud.routing.web;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.web;
package com.alibaba.cloud.routing.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

@ -14,12 +14,12 @@
* limitations under the License.
*/
package com.alibaba.cloud.router.web;
package com.alibaba.cloud.routing.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.cloud.router.util.RequestContext;
import com.alibaba.cloud.routing.util.RequestContext;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;

@ -1,6 +1,6 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.alibaba.cloud.router.LabelRoutingAutoConfiguration,\
com.alibaba.cloud.router.feign.FeignInterceptorAutoConfiguration,\
com.alibaba.cloud.router.ribbon.LabelRouteLBRuleAutoConfiguration,\
com.alibaba.cloud.router.web.WebMvcAutoConfiguration,\
com.alibaba.cloud.router.RouterPropertiesAutoConfiguration
com.alibaba.cloud.routing.RoutingAutoConfiguration,\
com.alibaba.cloud.routing.feign.RoutingFeignInterceptorAutoConfiguration,\
com.alibaba.cloud.routing.ribbon.RoutingLoadBalanceRuleAutoConfiguration,\
com.alibaba.cloud.routing.web.WebMvcAutoConfiguration,\
com.alibaba.cloud.routing.RoutingPropertiesAutoConfiguration

Loading…
Cancel
Save