Class AbstractStateRouter<T>
java.lang.Object
org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter<T>
- All Implemented Interfaces:
StateRouter<T>
- Direct Known Subclasses:
AppScriptStateRouter,ConditionStateRouter,ListenableStateRouter,MeshRuleRouter,MockInvokersSelector,MultiDestConditionRouter,ScriptStateRouter,TagStateRouter
The abstract class of StateRoute.
- Since:
- 3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringBuild Router's Current State Snapshot for QoSorg.apache.dubbo.common.URLgetUrl()Get the router url.booleanisForce()To decide whether this router should take effect when none of the invoker can match the router rule, which means theStateRouter.route(BitList, URL, Invocation, boolean, Holder)would be empty.booleanTo decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.voidNotify the router the invoker list.route(BitList<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage, org.apache.dubbo.common.utils.Holder<RouterSnapshotNode<T>> nodeHolder) Filter invokers with current routing rule and only return the invokers that comply with the rule.voidsetForce(boolean force) final voidsetNextRouter(StateRouter<T> nextRouter) Next Router node state is maintained by AbstractStateRouter and this method is not allow to override.voidsetUrl(org.apache.dubbo.common.URL url) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.dubbo.rpc.cluster.router.state.StateRouter
stop
-
Constructor Details
-
AbstractStateRouter
public AbstractStateRouter(org.apache.dubbo.common.URL url)
-
-
Method Details
-
getUrl
public org.apache.dubbo.common.URL getUrl()Description copied from interface:StateRouterGet the router url.- Specified by:
getUrlin interfaceStateRouter<T>- Returns:
- url
-
setUrl
public void setUrl(org.apache.dubbo.common.URL url) -
isRuntime
public boolean isRuntime()Description copied from interface:StateRouterTo decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.- Specified by:
isRuntimein interfaceStateRouter<T>- Returns:
- true if the router need to execute every time.
-
isForce
public boolean isForce()Description copied from interface:StateRouterTo decide whether this router should take effect when none of the invoker can match the router rule, which means theStateRouter.route(BitList, URL, Invocation, boolean, Holder)would be empty. Most of time, most router implementation would default this value to false.- Specified by:
isForcein interfaceStateRouter<T>- Returns:
- true to execute if none of invokers matches the current router
-
setForce
public void setForce(boolean force) -
getRuleRepository
-
getNextRouter
-
notify
Description copied from interface:StateRouterNotify the router the invoker list. Invoker list may change from time to time. This method gives the router a chance to prepare beforeStateRouter.route(BitList, URL, Invocation, boolean, Holder)gets called. No need to notify next node.- Specified by:
notifyin interfaceStateRouter<T>- Parameters:
invokers- invoker list
-
route
public final BitList<Invoker<T>> route(BitList<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage, org.apache.dubbo.common.utils.Holder<RouterSnapshotNode<T>> nodeHolder) throws RpcException Description copied from interface:StateRouterFilter invokers with current routing rule and only return the invokers that comply with the rule. Caching address lists in BitMap mode improves routing performance.- Specified by:
routein interfaceStateRouter<T>- Parameters:
invokers- invoker bit listurl- refer urlinvocation- invocationneedToPrintMessage- whether to print router state. Such as `use router branch a`.- Returns:
- state with route result
- Throws:
RpcException
-
setNextRouter
Next Router node state is maintained by AbstractStateRouter and this method is not allow to override. If a specified router wants to control the behaviour of continue route or not, please overridesupportContinueRoute()- Specified by:
setNextRouterin interfaceStateRouter<T>- Parameters:
nextRouter- next router node
-
buildSnapshot
Description copied from interface:StateRouterBuild Router's Current State Snapshot for QoS- Specified by:
buildSnapshotin interfaceStateRouter<T>- Returns:
- Current State
-