datax(16):源码解读AbstractReporter

之前介绍了通信类communication,容器类container,communication的收集类collector,今天再看一个报告类Reporter;


一、概述AbstractReporter

  1. 主要作用:Reporter的主要功能是将收集到的信息上报给上级
  2. 主要方法:reportTGCommunication(汇报TG的communication信息给上级),reportJobCommunication(汇报job的communication信息给上级)

二、族谱

族谱里面目前只有父子二人,父类AbstractReporter里面只是负责声明抽象方法,子类里负责具体实现;
在这里插入图片描述


三、主要方法

AbstractReporter

  /**
   * 汇报job的communication信息给上级(目前datax中job无上级,所以子类中do nothing)
   *
   * @param jobId         Long
   * @param communication Communication
   */
  public abstract void reportJobCommunication(Long jobId, Communication communication);

  /**
   * 汇报TG的communication信息给上级
   *
   * @param taskGroupId   Integer
   * @param communication Communication
   */
  public abstract void reportTGCommunication(Integer taskGroupId, Communication communication);

子类ProcessInnerReporter,注意里面reportJobCommunication是do nothing

  /**
   * 汇报job的communication信息给上级(目前datax中job无上级,所以do nothing)
   *
   * @param jobId         Integer
   * @param communication Communication
   */
  @Override
  public void reportJobCommunication(Long jobId, Communication communication) {
    // do nothing
  }

  /**
   * 将TaskGroupContainer的信息汇报给上级,操作也很简单直接更新注册时分配给该TaskGroup的Communication(Map中的值)
   *
   * @param taskGroupId   Integer
   * @param communication Communication
   */
  @Override
  public void reportTGCommunication(Integer taskGroupId, Communication communication) {
    LocalTGCommunicationManager.updateTaskGroupCommunication(taskGroupId, communication);
  }


注:

  1. 对源码进行略微改动,主要修改为 1 阿里代码规约扫描出来的,2 clean code;

  2. 所有代码都已经上传到github(master分支和dev),可以免费白嫖

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

water___Wang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值