Flink源码4-Slot分配和Task执行

本文详细解析了Flink作业执行时的Slot分配过程,从JobMaster的startJobExecution开始,包括Scheduler的启动、申请Slot、Task部署到TaskManager的整个流程,深入理解Flink的资源管理和任务调度机制。
摘要由CSDN通过智能技术生成

接上期:——》JobMaster#startJobExecution()
resetAndStartScheduler();
——》JobMaster#resetAndStartScheduler
schedulerAssignedFuture.thenRun(this::startScheduling);
——》JobMaster#startScheduling()
schedulerNG.startScheduling();

SchedulerBase# startScheduling();

startAllOperatorCoordinators();
* 注释: 开始调度
*/
startSchedulingInternal();

DefaultScheduler#startSchedulingInternal
schedulingStrategy.startScheduling();

LazyFromSourcesSchedulingStrategy#startScheduling();

* 注释: 申请 Slot 并且开始 部署 ExecutionVertices
*/
allocateSlotsAndDeployExecutionVertices(schedulingTopology.getVertices());
——》LazyFromSourcesSchedulingStrategy#allocateSlotsAndDeployExecutionVertices

* 注释: 申请 slot 和 部署
* schedulerOperations = DefaultScheduler
*/
schedulerOperations.allocateSlotsAndDeploy(Collections.

DefaultScheduler#allocateSlotsAndDeploy()

*******来到正式入口:DefaultScheduler#allocateSlotsAndDeploy()***********
流程:
1、JobMaster 发送请求申请 slot
2、ResourceManager 接收到请求,执行 slot请求处理
3、TaskManager 处理 ResourceManager 发送过来的 Slot 请求
4、JobMaster 接收到 TaskManager 发送过来的 Slot 申请处理结果

1、JobMaster 发送请求申请 slot 0:31 ~

—— 5 》DefaultScheduler#allocateSlotsAndDeploy()

* 1 注释: 申请Slot
final List<SlotExecutionVertexAssignment> slotExecutionVertexAssignments = allocateSlots(executionVertexDeploymentOptions);
.............
* 2 注释: 部署运行
*/
waitForAllSlotsAndDeploy(deploymentHandles);

——先走 1 》DefaultScheduler#allocateSlots() 0:21
* 注释: 申请Slot
*/
final List<SlotExecutionVertexAssignment>
slotExecutionVertexAssignments = allocateSlots(executionVertexDeploymentOptions);
——》DefaultScheduler#allocateSlots()

——4 》DefaultExecutionSlotAllocator#allocateSlotsFor

  • 注释: NormalSlotProviderStrategy */
    slotProviderStrategy.allocateSlot

    SlotProviderStrategy#NormalSlotProviderStrategy#allocateSlot()

    SchedulerImpl#allocateSlot()
    ——》SchedulerImpl#allocateSlotInternal
    ——》SchedulerImpl#internalAllocateSlot
    —— 》SchedulerImpl# allocateSingleSlot

    //第1 步: 从池中获取
    Optional<SlotAndLocality> slotAndLocality = tryAllocateFromAvailable
    if(slotAndLocality.isPresent()) {
    return //如果slot池里面有直接分配
    CompletableFuture.completedFuture(completeAllocationByAssigningPayload
    else{//否则new 一个
    return requestNewAllocatedSlot(slotRequestId, slotProfile
    }
    ——》SchedulerImpl# requestNewAllocatedSlot
    return slotPool.requestNewAllocatedSlot(slotRequestId,

    SlotPoolImpl#requestNewAllocatedS
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值