Package org.apache.dubbo.rpc.cluster
Interface Router
- All Superinterfaces:
Comparable<Router>
- All Known Implementing Classes:
AbstractRouter
Router. (SPI, Prototype, ThreadSafe)
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault intintRouter's priority, used to sort routers.org.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 theroute(List, URL, Invocation)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.default <T> voidNotify the router the invoker list.route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation) Deprecated.default <T> RouterResult<Invoker<T>> route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage) ** This method can return the state of whether routerChain needed to continue route. ** Filter invokers with current routing rule and only return the invokers that comply with the rule.default voidstop()
-
Field Details
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITY- See Also:
-
-
Method Details
-
getUrl
org.apache.dubbo.common.URL getUrl()Get the router url.- Returns:
- url
-
route
@Deprecated default <T> List<Invoker<T>> route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation) throws RpcException Deprecated.Filter invokers with current routing rule and only return the invokers that comply with the rule.- Parameters:
invokers- invoker listurl- refer urlinvocation- invocation- Returns:
- routed invokers
- Throws:
RpcException
-
route
default <T> RouterResult<Invoker<T>> route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation, boolean needToPrintMessage) throws RpcException ** This method can return the state of whether routerChain needed to continue route. ** Filter invokers with current routing rule and only return the invokers that comply with the rule.- Parameters:
invokers- invoker listurl- refer urlinvocation- invocationneedToPrintMessage- whether to print router state. Such as `use router branch a`.- Returns:
- state with route result
- Throws:
RpcException
-
notify
Notify the router the invoker list. Invoker list may change from time to time. This method gives the router a chance to prepare beforeroute(List, URL, Invocation)gets called.- Type Parameters:
T- invoker's type- Parameters:
invokers- invoker list
-
isRuntime
boolean isRuntime()To decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.- Returns:
- true if the router need to execute every time.
-
isForce
boolean isForce()To decide whether this router should take effect when none of the invoker can match the router rule, which means theroute(List, URL, Invocation)would be empty. Most of time, most router implementation would default this value to false.- Returns:
- true to execute if none of invokers matches the current router
-
getPriority
int getPriority()Router's priority, used to sort routers.- Returns:
- router's priority
-
stop
default void stop() -
compareTo
- Specified by:
compareToin interfaceComparable<Router>
-