路由状态命令

路由状态命令

Dubbo 的很多流量治理能力是基于 Router 进行实现的,在生产环境中,如果出现流量结果不符合预期的情况,可以通过路由状态命令来查看路由的状态,以此来定位可能存在的问题。

参考链接:路由状态采集

getRouterSnapshot 命令

获取当前的每层路由的分组状态。(仅支持 StateRouter)

命令:getRouterSnapshot {serviceName}

serviceName 为需要采集的服务名,支持匹配

  1. dubbo>getRouterSnapshot com.dubbo.dubbointegration.BackendService
  2. com.dubbo.dubbointegration.BackendService@2c2e824a
  3. [ All Invokers:2 ] [ Valid Invokers: 2 ]
  4. MockInvokersSelector Total: 2
  5. [ Mocked -> Empty (Total: 0) ]
  6. [ Normal -> 172.18.111.187:20880,172.18.111.183:20880 (Total: 2) ]
  7. StandardMeshRuleRouter not support
  8. TagStateRouter not support
  9. ServiceStateRouter not support
  10. AppStateRouter not support
  11. TailStateRouter End
  12. dubbo>

enableRouterSnapshot 命令

开启路由结果采集模式

命令:enableRouterSnapshot {serviceName}

serviceName 为需要采集的服务名,支持匹配

  1. dubbo>enableRouterSnapshot com.dubbo.*
  2. OK. Found service count: 1. This will cause performance degradation, please be careful!
  3. dubbo>

disableRouterSnapshot 命令

关闭路由结果采集模式

命令:disableRouterSnapshot {serviceName}

serviceName 为需要采集的服务名,支持匹配

  1. dubbo>disableRouterSnapshot com.dubbo.*
  2. OK. Found service count: 1
  3. dubbo>

getEnabledRouterSnapshot 命令

获取当前已经开启采集的服务

  1. dubbo>getEnabledRouterSnapshot
  2. com.dubbo.dubbointegration.BackendService
  3. dubbo>

getRecentRouterSnapshot 命令

通过 qos 命令获取历史的路由状态。(最多存储 32 个结果)

  1. dubbo>getRecentRouterSnapshot
  2. 1658224330156 - Router snapshot service com.dubbo.dubbointegration.BackendService from registry 172.18.111.184 on the consumer 172.18.111.184 using the dubbo version 3.0.9 is below:
  3. [ Parent (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) ] Input: 172.18.111.187:20880,172.18.111.183:20880 -> Chain Node Output: 172.18.111.187:20880,172.18.111.183:20880
  4. [ MockInvokersSelector (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: invocation.need.mock not set. Return normal Invokers. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  5. [ StandardMeshRuleRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: MeshRuleCache has not been built. Skip route. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  6. [ TagStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Disable Tag Router. Reason: tagRouterRule is invalid or disabled ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  7. [ ServiceStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Directly return. Reason: Invokers from previous router is empty or conditionRouters is empty. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  8. [ AppStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Directly return. Reason: Invokers from previous router is empty or conditionRouters is empty. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  9. 1658224330156 - Router snapshot service com.dubbo.dubbointegration.BackendService from registry 172.18.111.184 on the consumer 172.18.111.184 using the dubbo version 3.0.9 is below:
  10. [ Parent (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) ] Input: 172.18.111.187:20880,172.18.111.183:20880 -> Chain Node Output: 172.18.111.187:20880,172.18.111.183:20880
  11. [ MockInvokersSelector (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: invocation.need.mock not set. Return normal Invokers. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  12. [ StandardMeshRuleRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: MeshRuleCache has not been built. Skip route. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  13. [ TagStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Disable Tag Router. Reason: tagRouterRule is invalid or disabled ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  14. [ ServiceStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Directly return. Reason: Invokers from previous router is empty or conditionRouters is empty. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  15. [ AppStateRouter (Input: 2) (Current Node Output: 2) (Chain Node Output: 2) Router message: Directly return. Reason: Invokers from previous router is empty or conditionRouters is empty. ] Current Node Output: 172.18.111.187:20880,172.18.111.183:20880
  16. ···
  17. dubbo>

最后修改 December 16, 2022: Fix check (#1736) (97972c1)