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 Details

  • 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:
      process in interface org.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: StateRouter
      To decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.
      Specified by:
      isRuntime in interface StateRouter<T>
      Overrides:
      isRuntime in class AbstractStateRouter<T>
      Returns:
      true if the router need to execute every time.
    • isForce

      public boolean isForce()
      Description copied from interface: StateRouter
      To decide whether this router should take effect when none of the invoker can match the router rule, which means the StateRouter.route(BitList, URL, Invocation, boolean, Holder) would be empty. Most of time, most router implementation would default this value to false.
      Specified by:
      isForce in interface StateRouter<T>
      Overrides:
      isForce in class AbstractStateRouter<T>
      Returns:
      true to execute if none of invokers matches the current router
    • setApplication

      public void setApplication(String app)
    • notify

      public void notify(BitList<Invoker<T>> invokers)
      Description copied from interface: StateRouter
      Notify the router the invoker list. Invoker list may change from time to time. This method gives the router a chance to prepare before StateRouter.route(BitList, URL, Invocation, boolean, Holder) gets called. No need to notify next node.
      Specified by:
      notify in interface StateRouter<T>
      Overrides:
      notify in class AbstractStateRouter<T>
      Parameters:
      invokers - invoker list
    • getInvokers

      public BitList<Invoker<T>> getInvokers()
    • stop

      public void stop()
      Specified by:
      stop in interface StateRouter<T>
    • setTagRouterRule

      public void setTagRouterRule(TagRouterRule tagRouterRule)
    • selectAddressByTagLevel

      public static Set<String> selectAddressByTagLevel(Map<String,Set<String>> tagAddresses, String tagSelector, boolean isForce)
      select addresses by tag with level

      example: 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: