接上期:——》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