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

[Feature] Move Mesh Rule Router to SPI Extensions #14069

Open
wants to merge 3 commits into
base: 3.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -17,8 +17,8 @@
package org.apache.dubbo.rpc.cluster.configurator.parser.model;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.AddressMatch;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.ListStringMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.AddressMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.ListStringMatch;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.cluster.configurator.parser.model;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.StringMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.StringMatch;

public class ParamMatch {
private String key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh;

import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleManager;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleManager;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.rpc.cluster.router.mesh.util.MeshRuleDispatcher;
import org.apache.dubbo.rpc.cluster.router.mesh.util.MeshRuleListener;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.MeshRuleDispatcher;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.MeshRuleListener;

import java.text.MessageFormat;
import java.util.HashMap;
Expand All @@ -38,9 +38,9 @@
import org.yaml.snakeyaml.representer.Representer;

import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_FAILED_RECEIVE_RULE;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.METADATA_KEY;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.NAME_KEY;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.STANDARD_ROUTER_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.METADATA_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.NAME_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.STANDARD_ROUTER_KEY;

public class MeshAppRuleListener implements ConfigurationListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

/**
* Mesh Rule Listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.extension.SPI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.VsDestinationGroup;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.DestinationRuleSpec;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.Subset;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.VsDestinationGroup;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.DestinationRuleSpec;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.Subset;
import org.apache.dubbo.rpc.cluster.router.state.BitList;

import java.util.Collections;
Expand All @@ -33,7 +33,7 @@
import java.util.Map;
import java.util.Objects;

import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.INVALID_APP_NAME;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.INVALID_APP_NAME;

public class MeshRuleCache<T> {
private final List<String> appList;
Expand Down Expand Up @@ -146,7 +146,7 @@ public static <T> MeshRuleCache<T> emptyCache() {
Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap(), BitList.emptyList());
}

protected static boolean isLabelMatch(URL url, String protocolServiceKey, Map<String, String> inputMap) {
public static boolean isLabelMatch(URL url, String protocolServiceKey, Map<String, String> inputMap) {
if (inputMap == null || inputMap.size() == 0) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

public class MeshRuleConstants {
public static final String INVALID_APP_NAME = "unknown";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.MeshRuleListener;
import org.apache.dubbo.rpc.cluster.governance.GovernanceRuleRepository;
import org.apache.dubbo.rpc.cluster.router.mesh.util.MeshRuleListener;
import org.apache.dubbo.rpc.model.ModuleModel;

import java.util.Objects;
Expand All @@ -29,7 +29,7 @@
import java.util.stream.Collectors;

import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_FAILED_RECEIVE_RULE;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.MESH_RULE_DATA_ID_SUFFIX;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.MESH_RULE_DATA_ID_SUFFIX;

public class MeshRuleManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
Expand All @@ -26,19 +26,19 @@
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.VsDestinationGroup;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.DubboMatchRequest;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.DubboRoute;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.DubboRouteDetail;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.VirtualServiceRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.VirtualServiceSpec;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.destination.DubboDestination;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.destination.DubboRouteDestination;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.StringMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.MeshRuleListener;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.TracingContextProvider;
import org.apache.dubbo.rpc.cluster.router.RouterSnapshotNode;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.VsDestinationGroup;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.DubboMatchRequest;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.DubboRoute;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.DubboRouteDetail;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.VirtualServiceRule;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.VirtualServiceSpec;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.destination.DubboDestination;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.destination.DubboRouteDestination;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.StringMatch;
import org.apache.dubbo.rpc.cluster.router.mesh.util.MeshRuleListener;
import org.apache.dubbo.rpc.cluster.router.mesh.util.TracingContextProvider;
import org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter;
import org.apache.dubbo.rpc.cluster.router.state.BitList;

Expand All @@ -52,10 +52,10 @@
import java.util.concurrent.ThreadLocalRandom;

import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_FAILED_RECEIVE_RULE;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.DESTINATION_RULE_KEY;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.INVALID_APP_NAME;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.KIND_KEY;
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.VIRTUAL_SERVICE_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.DESTINATION_RULE_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.INVALID_APP_NAME;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.KIND_KEY;
import static org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route.MeshRuleConstants.VIRTUAL_SERVICE_KEY;

public abstract class MeshRuleRouter<T> extends AbstractStateRouter<T> implements MeshRuleListener {

Expand All @@ -80,7 +80,7 @@ public MeshRuleRouter(URL url) {
}

@Override
protected BitList<Invoker<T>> doRoute(
public BitList<Invoker<T>> doRoute(
BitList<Invoker<T>> invokers,
URL url,
Invocation invocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.URL;

import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.STANDARD_ROUTER_KEY;

public class StandardMeshRuleRouter<T> extends MeshRuleRouter<T> {

public StandardMeshRuleRouter(URL url) {
Expand All @@ -28,6 +26,6 @@ public StandardMeshRuleRouter(URL url) {

@Override
public String ruleSuffix() {
return STANDARD_ROUTER_KEY;
return MeshRuleConstants.STANDARD_ROUTER_KEY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.route;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.route;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule;

import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.VirtualServiceRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.DestinationRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.VirtualServiceRule;

import java.util.LinkedList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

public class ConnectionPoolSettings {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

import org.apache.dubbo.rpc.cluster.router.mesh.rule.BaseRule;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.BaseRule;

public class DestinationRule extends BaseRule {
private DestinationRuleSpec spec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

public class TCPSettings {
private int maxConnections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

public class TcpKeepalive {
private int probes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination;

import org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.loadbalance.LoadBalancerSettings;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.loadbalance.LoadBalancerSettings;

public class TrafficPolicy {
private LoadBalancerSettings loadBalancer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.loadbalance;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.loadbalance;

public class ConsistentHashLB {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.loadbalance;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.loadbalance;

public class LoadBalancerSettings {
private SimpleLB simple;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.destination.loadbalance;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.destination.loadbalance;

public enum SimpleLB {
ROUND_ROBIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice;
package org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice;

import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.DubboAttachmentMatch;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.DubboMethodMatch;
import org.apache.dubbo.rpc.cluster.router.mesh.rule.virtualservice.match.StringMatch;
import org.apache.dubbo.rpc.cluster.router.mesh.util.TracingContextProvider;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.DubboAttachmentMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.DubboMethodMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.rule.virtualservice.match.StringMatch;
import org.apache.dubbo.rpc.cluster.configurator.parser.model.mesh.util.TracingContextProvider;

import java.util.Map;
import java.util.Set;
Expand Down
Loading
Loading