监控中心扩展

扩展说明

负责服务调用次和调用时间的监控。

扩展接口

  • com.alibaba.dubbo.monitor.MonitorFactory
  • com.alibaba.dubbo.monitor.Monitor

    扩展配置

  1. <!-- 定义监控中心 -->
  2. <dubbo:monitor address="xxx://ip:port" />

已知扩展

com.alibaba.dubbo.monitor.support.dubbo.DubboMonitorFactory

扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxMonitorFactoryjava (实现MonitorFactory接口)
  7. |-XxxMonitor.java (实现Monitor接口)
  8. |-resources
  9. |-META-INF
  10. |-dubbo
  11. |-com.alibaba.dubbo.monitor.MonitorFactory (纯文本文件,内容为:xxx=com.xxx.XxxMonitorFactory)

XxxMonitorFactory.java:

  1. package com.xxx;
  2. import com.alibaba.dubbo.monitor.MonitorFactory;
  3. import com.alibaba.dubbo.monitor.Monitor;
  4. import com.alibaba.dubbo.common.URL;
  5. public class XxxMonitorFactory implements MonitorFactory {
  6. public Monitor getMonitor(URL url) {
  7. return new XxxMonitor(url);
  8. }
  9. }

XxxMonitor.java:

  1. package com.xxx;
  2. import com.alibaba.dubbo.monitor.Monitor;
  3. public class XxxMonitor implements Monitor {
  4. public void count(URL statistics) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/com.alibaba.dubbo.monitor.MonitorFactory:

  1. xxx=com.xxx.XxxMonitorFactory

原文: http://dubbo.apache.org/#!/docs/dev/impls/monitor.md?lang=zh-cn