首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >datax(16):源码解读AbstractReporter

datax(16):源码解读AbstractReporter

作者头像
全栈程序员站长
发布2022-08-29 13:29:33
发布2022-08-29 13:29:33
3400
举报

大家好,又见面了,我是你们的朋友全栈君。

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

一、概述AbstractReporter

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

二、族谱

族谱里面目前只有父子二人,父类AbstractReporter里面只是负责声明抽象方法,子类里负责具体实现;

三、主要方法

AbstractReporter

代码语言:javascript
复制
  /** * 汇报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

代码语言:javascript
复制
  /** * 汇报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),可以免费白嫖

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/145657.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年5月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、概述AbstractReporter
  • 二、族谱
  • 三、主要方法
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档