Class TagStateRouter<T>
java.lang.Object
org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter<T>
org.apache.dubbo.rpc.cluster.router.tag.TagStateRouter<T>
- All Implemented Interfaces:
EventListener,org.apache.dubbo.common.config.configcenter.ConfigurationListener,StateRouter<T>
public class TagStateRouter<T>
extends AbstractStateRouter<T>
implements org.apache.dubbo.common.config.configcenter.ConfigurationListener
TagRouter, "application.tag-router"
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoRoute(BitList<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage, org.apache.dubbo.common.utils.Holder<RouterSnapshotNode<T>> nodeHolder, org.apache.dubbo.common.utils.Holder<String> messageHolder) 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.voidprocess(org.apache.dubbo.common.config.configcenter.ConfigChangedEvent event) select addresses by tag with levelvoidsetApplication(String app) voidsetTagRouterRule(TagRouterRule tagRouterRule) voidstop()Methods inherited from class org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter
buildSnapshot, getNextRouter, getRuleRepository, getUrl, route, setForce, setNextRouter, setUrl
-
Field Details
-
NAME
- See Also:
-
TAG_SEPERATOR
public static final char TAG_SEPERATOR- See Also:
-
-
Constructor Details
-
TagStateRouter
public TagStateRouter(org.apache.dubbo.common.URL url)
-
-
Method Details
-
process
public void process(org.apache.dubbo.common.config.configcenter.ConfigChangedEvent event) - Specified by:
processin interfaceorg.apache.dubbo.common.config.configcenter.ConfigurationListener
-
doRoute
public BitList<Invoker<T>> doRoute(BitList<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage, org.apache.dubbo.common.utils.Holder<RouterSnapshotNode<T>> nodeHolder, org.apache.dubbo.common.utils.Holder<String> messageHolder) throws RpcException - Throws:
RpcException
-
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>- Overrides:
isRuntimein classAbstractStateRouter<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>- Overrides:
isForcein classAbstractStateRouter<T>- Returns:
- true to execute if none of invokers matches the current router
-
setApplication
-
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>- Overrides:
notifyin classAbstractStateRouter<T>- Parameters:
invokers- invoker list
-
getInvokers
-
stop
public void stop()- Specified by:
stopin interfaceStateRouter<T>
-
setTagRouterRule
-
selectAddressByTagLevel
public static Set<String> selectAddressByTagLevel(Map<String, Set<String>> tagAddresses, String tagSelector, boolean isForce) select addresses by tag with levelexample: selector=beta|team1|partner1 step1.select tagAddresses with selector=beta|team1|partner1, if result is empty, then run step2 step2.select tagAddresses with selector=beta|team1, if result is empty, then run step3 step3.select tagAddresses with selector=beta, if result is empty, result is null
- Parameters:
tagAddresses-tagSelector- eg: beta|team1|partner1- Returns:
-