-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1605 from daizhenyu/develop-xds-route-930
Sermant framework supports route and load balance config based xDS protocol
- Loading branch information
Showing
38 changed files
with
2,299 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...rmant-agentcore-core/src/main/java/io/sermant/core/service/xds/XdsLoadBalanceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds; | ||
|
||
import io.sermant.core.service.xds.entity.XdsLbPolicy; | ||
|
||
/** | ||
* xDS load balance service | ||
* | ||
* @author daizhenyu | ||
* @since 2024-07-30 | ||
**/ | ||
public interface XdsLoadBalanceService { | ||
/** | ||
* get lb policy of cluster | ||
* | ||
* @param clusterName cluster name | ||
* @return route rules | ||
*/ | ||
XdsLbPolicy getClusterLbPolicy(String clusterName); | ||
|
||
/** | ||
* get lb policy of service (base cluster) | ||
* | ||
* @param serviceName service name | ||
* @return route rules | ||
*/ | ||
XdsLbPolicy getServiceLbPolicy(String serviceName); | ||
} |
45 changes: 45 additions & 0 deletions
45
...ore/sermant-agentcore-core/src/main/java/io/sermant/core/service/xds/XdsRouteService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds; | ||
|
||
import io.sermant.core.service.xds.entity.XdsRoute; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* xDS route service | ||
* | ||
* @author daizhenyu | ||
* @since 2024-07-30 | ||
**/ | ||
public interface XdsRouteService { | ||
/** | ||
* get route rules of service | ||
* | ||
* @param serviceName service name | ||
* @return route rules | ||
*/ | ||
List<XdsRoute> getServiceRoute(String serviceName); | ||
|
||
/** | ||
* get lb policy of cluster | ||
* | ||
* @param clusterName cluster name | ||
* @return route rules | ||
*/ | ||
boolean isLocalityRoute(String clusterName); | ||
} |
65 changes: 65 additions & 0 deletions
65
...e/sermant-agentcore-core/src/main/java/io/sermant/core/service/xds/entity/XdsCluster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds.entity; | ||
|
||
/** | ||
* XdsCluster corresponds to io.envoyproxy.envoy.config.cluster.v3.Cluster | ||
* | ||
* @author daizhenyu | ||
* @since 2024-08-06 | ||
**/ | ||
public class XdsCluster { | ||
private String clusterName; | ||
|
||
private String serviceName; | ||
|
||
private XdsLbPolicy lbPolicy; | ||
|
||
private boolean isLocalityLb; | ||
|
||
public String getClusterName() { | ||
return clusterName; | ||
} | ||
|
||
public void setClusterName(String clusterName) { | ||
this.clusterName = clusterName; | ||
} | ||
|
||
public String getServiceName() { | ||
return serviceName; | ||
} | ||
|
||
public void setServiceName(String serviceName) { | ||
this.serviceName = serviceName; | ||
} | ||
|
||
public XdsLbPolicy getLbPolicy() { | ||
return lbPolicy; | ||
} | ||
|
||
public void setLbPolicy(XdsLbPolicy lbPolicy) { | ||
this.lbPolicy = lbPolicy; | ||
} | ||
|
||
public boolean isLocalityLb() { | ||
return isLocalityLb; | ||
} | ||
|
||
public void setLocalityLb(boolean localityLb) { | ||
isLocalityLb = localityLb; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ntcore-core/src/main/java/io/sermant/core/service/xds/entity/XdsClusterLoadAssigment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds.entity; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* XdsClusterLoadAssigment corresponds to io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment | ||
* | ||
* @author daizhenyu | ||
* @since 2024-08-15 | ||
**/ | ||
public class XdsClusterLoadAssigment { | ||
private String serviceName; | ||
|
||
private String clusterName; | ||
|
||
private Map<XdsLocality, Set<ServiceInstance>> localityInstances; | ||
|
||
public String getServiceName() { | ||
return serviceName; | ||
} | ||
|
||
public void setServiceName(String serviceName) { | ||
this.serviceName = serviceName; | ||
} | ||
|
||
public String getClusterName() { | ||
return clusterName; | ||
} | ||
|
||
public void setClusterName(String clusterName) { | ||
this.clusterName = clusterName; | ||
} | ||
|
||
public Map<XdsLocality, Set<ServiceInstance>> getLocalityInstances() { | ||
return localityInstances; | ||
} | ||
|
||
public void setLocalityInstances( | ||
Map<XdsLocality, Set<ServiceInstance>> localityInstances) { | ||
this.localityInstances = localityInstances; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...ant-agentcore-core/src/main/java/io/sermant/core/service/xds/entity/XdsHeaderMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds.entity; | ||
|
||
import io.sermant.core.service.xds.entity.match.MatchStrategy; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* xDS HeaderMatcher | ||
* | ||
* @author daizhenyu | ||
* @since 2024-08-15 | ||
**/ | ||
public class XdsHeaderMatcher { | ||
private final String name; | ||
|
||
private final MatchStrategy matchStrategy; | ||
|
||
/** | ||
* parameterized constructor | ||
* | ||
* @param name header name | ||
* @param matchStrategy match strategy | ||
*/ | ||
public XdsHeaderMatcher(String name, MatchStrategy matchStrategy) { | ||
this.name = name; | ||
this.matchStrategy = matchStrategy; | ||
} | ||
|
||
/** | ||
* the request header matches the route configuration header or not. | ||
* | ||
* @param headers request headers | ||
* @return isMatch | ||
*/ | ||
public boolean isMatch(Map<String, String> headers) { | ||
if (headers.containsKey(name)) { | ||
return matchStrategy.isMatch(headers.get(name)); | ||
} | ||
return false; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...tcore-core/src/main/java/io/sermant/core/service/xds/entity/XdsHttpConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds.entity; | ||
|
||
/** | ||
* xDS HttpConnectionManager | ||
* | ||
* @author daizhenyu | ||
* @since 2024-08-15 | ||
**/ | ||
public class XdsHttpConnectionManager { | ||
private String routeConfigName; | ||
|
||
public String getRouteConfigName() { | ||
return routeConfigName; | ||
} | ||
|
||
public void setRouteConfigName(String routeConfigName) { | ||
this.routeConfigName = routeConfigName; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
.../sermant-agentcore-core/src/main/java/io/sermant/core/service/xds/entity/XdsLbPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sermant.core.service.xds.entity; | ||
|
||
/** | ||
* xDS LbPolicy | ||
* | ||
* @author daizhenyu | ||
* @since 2024-08-15 | ||
**/ | ||
public enum XdsLbPolicy { | ||
/** | ||
* random | ||
*/ | ||
RANDOM, | ||
/** | ||
* round_robin | ||
*/ | ||
ROUND_ROBIN, | ||
/** | ||
* least_request | ||
*/ | ||
LEAST_REQUEST, | ||
/** | ||
* ring_hash | ||
*/ | ||
RING_HASH, | ||
/** | ||
* maglev | ||
*/ | ||
MAGLEV, | ||
/** | ||
* unrecognized | ||
*/ | ||
UNRECOGNIZED; | ||
} |
Oops, something went wrong.