类 ConditionRouter
- java.lang.Object
-
- org.apache.dubbo.rpc.cluster.router.AbstractRouter
-
- org.apache.dubbo.rpc.cluster.router.condition.ConditionRouter
-
- 所有已实现的接口:
Comparable<Router>,Router
public class ConditionRouter extends AbstractRouter
ConditionRouter It supports the conditional routing configured by "override://", in 2.6.x, refer to https://dubbo.apache.org/en/docs/v2.7/user/examples/routing-rule/ . For 2.7.x and later, please refer toServiceRouterandAppRouterrefer to https://dubbo.apache.org/zh/docs/v2.7/user/examples/routing-rule/ .
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringNAME-
从接口继承的字段 org.apache.dubbo.rpc.cluster.Router
DEFAULT_PRIORITY
-
-
构造器概要
构造器 构造器 说明 ConditionRouter(String rule, boolean force, boolean enabled)ConditionRouter(org.apache.dubbo.common.URL url)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 org.apache.dubbo.common.URLgetUrl()Get the router url.voidinit(String rule)booleanisRuntime()To decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.booleanmatchArguments(Map.Entry<String,org.apache.dubbo.rpc.cluster.router.condition.ConditionRouter.MatchPair> matchPair, Invocation invocation)analysis the arguments in the rule.<T> List<Invoker<T>>route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation)Filter invokers with current routing rule and only return the invokers that comply with the rule.-
从类继承的方法 org.apache.dubbo.rpc.cluster.router.AbstractRouter
getPriority, isForce, setForce, setPriority, setUrl
-
-
-
-
构造器详细资料
-
ConditionRouter
public ConditionRouter(String rule, boolean force, boolean enabled)
-
ConditionRouter
public ConditionRouter(org.apache.dubbo.common.URL url)
-
-
方法详细资料
-
init
public void init(String rule)
-
route
public <T> List<Invoker<T>> route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation) throws RpcException
从接口复制的说明:RouterFilter invokers with current routing rule and only return the invokers that comply with the rule.- 参数:
invokers- invoker listurl- refer urlinvocation- invocation- 返回:
- routed invokers
- 抛出:
RpcException
-
isRuntime
public boolean isRuntime()
从接口复制的说明:RouterTo decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.- 指定者:
isRuntime在接口中Router- 覆盖:
isRuntime在类中AbstractRouter- 返回:
- true if the router need to execute every time.
-
getUrl
public org.apache.dubbo.common.URL getUrl()
从接口复制的说明:RouterGet the router url.- 指定者:
getUrl在接口中Router- 覆盖:
getUrl在类中AbstractRouter- 返回:
- url
-
matchArguments
public boolean matchArguments(Map.Entry<String,org.apache.dubbo.rpc.cluster.router.condition.ConditionRouter.MatchPair> matchPair, Invocation invocation)
analysis the arguments in the rule. Examples would be like this: "arguments[0]=1", whenCondition is that the first argument is equal to '1'. "arguments[1]=a", whenCondition is that the second argument is equal to 'a'.- 参数:
matchPair-invocation-- 返回:
-
-