datax参数设置_Datax3.0中配置解读(1)

本文详细解析了DataX3.0中的核心配置参数,包括`taskGroup.channel`和`job.setting.speed.channel`的作用。`taskGroup.channel`用于确定每个任务组的通道数,影响任务分配;而`job.setting.speed.channel`设定任务的并发执行通道数,直接影响任务执行的并发度和效率。通过调整这两个参数,可以优化DataX的作业调度和执行性能。
摘要由CSDN通过智能技术生成

首先从一个简单的配置文件开始core.json部分配置

"container": {

"job": {

"reportInterval": 10000

},

"taskGroup": {

"channel": 5

},

"trace": {

"enable": "false"

}

}taskGroup.channel在什么地方会用到?

com.alibaba.datax.core.job.schedule() 方法中:

int channelsPerTaskGroup = this.configuration.getInt(

CoreConstant.DATAX_CORE_CONTAINER_TASKGROUP_CHANNEL, 5);

taskGroup.channel有什么作用?我们现看另一个参数"job": {

"setting": {

"speed": {

"channel":1

}

},

"content": [

{

"reader": {

},

"writer": {

}

}

}

]

}

}

job.setting.speed.channel这个参数又有什么作用,在什么地方被用到?

com.alibaba.datax.core.job.split()方法中的this.adjustChannelNumber();方法中初始化

在没有配置job.setting.speed.byte,job.setting.speed.record的情况下会走到这里

boolean isChannelLimit = (this.configuration.getInt(

CoreConstant.DATAX_JOB_SETTING_SPEED_CHANNEL, 0) > 0);//job.setting.speed.channel

if (isChannelLimit) {

this.needChannelNumber = this.configuration.getInt(

CoreConstant.DATAX_JOB_SETTING_SPEED_CHANNEL);//获取任务配置的channel

LOG.info("Job set Channel-Number to " + this.needChannelNumber

+ " channels.");

return;

}

继续schedule方法,此时会和拆分的任务数比较取最小值

this.needChannelNumber = Math.min(this.needChannelNumber, taskNumber);

然后进入关键的方法:

/**

* 通过获取配置信息得到每个taskGroup需要运行哪些tasks任务

* 总任务书/配置的任务组数目  获取需要定义几个taskGroupConfigs

*/

List taskGroupConfigs = JobAssignUtil.assignFairly(this.configuration,

this.needChannelNumber, channelsPerTaskGroup);

可以看到下面一行代码:

int taskGroupNumber = (int) Math.ceil(1.0 * channelNumber / channelsPerTaskGroup);// 返回大于或者等于指定表达式的最小整数,即向上取整

此时可以看到channelsPerTaskGroup 也就是taskGroup.channel的作用

会帮我们计算出taskGroupNumber.

List taskGroupConfig = doAssign(resourceMarkAndTaskIdMap, configuration, taskGroupNumber);

taskGroupNumber的作用是什么?继续跟进代码

scheduler.schedule(taskGroupConfigs);

startAllTaskGroup(configurations);

public void startAllTaskGroup(List configurations) {

this.taskGroupContainerExecutorService = Executors

.newFixedThreadPool(configurations.size());

for (Configuration taskGroupConfiguration : configurations) {

TaskGroupContainerRunner taskGroupContainerRunner = newTaskGroupContainerRunner(taskGroupConfiguration);

this.taskGroupContainerExecutorService.execute(taskGroupContainerRunner);

}

this.taskGroupContainerExecutorService.shutdown();

}

可以看到有几个taskGroupNumber,就会启动几个线程去执行任务组

从上面可以分享出:job.setting.speed.channel配置1的话,只会有一个线程去执行切分的所有任务

当job.setting.speed.channel配置为15的话,有三个线程到线程池中去执行切分的任务。

并发会增大。

打开App,阅读手记

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值