之前介绍了通信类communication,容器类container,communication的收集类collector,今天再看一个报告类Reporter;
一、概述AbstractReporter
- 主要作用:Reporter的主要功能是将收集到的信息上报给上级
- 主要方法: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 阿里代码规约扫描出来的,2 clean code;
-
所有代码都已经上传到github(master分支和dev),可以免费白嫖