Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Dolphinscheduler WorkerGroupDispatcherCoordinator Dispatch

From Leeroopedia


Knowledge Sources
Domains Distributed_Systems, Task_Scheduling
Last Updated 2026-02-10 00:00 GMT

Overview

Concrete tool for dispatching tasks to workers using WorkerGroupDispatcherCoordinator with worker group routing and TaskDispatchableEventBus delay queue.

Description

WorkerGroupDispatcherCoordinator is a Spring @Component that coordinates task dispatch across worker groups. It maintains a map of WorkerGroupDispatcher instances and provides dispatchTask(ITaskExecutionRunnable, long delayTimeMills) for submitting tasks with optional delay. TaskDispatchableEventBus extends AbstractDelayEventBus providing add(), take(), size(), and clear() for queue management.

Usage

Called by the workflow engine when tasks are ready for dispatch. The coordinator is autowired and managed by Spring.

Code Reference

Source Location

  • Repository: dolphinscheduler
  • File: dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/dispatcher/WorkerGroupDispatcherCoordinator.java (L36-104)
  • File: dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/dispatcher/TaskDispatchableEventBus.java (L25-44)

Signature

@Component
public class WorkerGroupDispatcherCoordinator implements AutoCloseable {
    public void start();
    public void dispatchTask(ITaskExecutionRunnable taskExecutionRunnable,
                             long delayTimeMills);
    public boolean removeTask(ITaskExecutionRunnable taskExecutionRunnable);
    public boolean existWorkerGroup(String workerGroup);
    @Override public void close();
}

public class TaskDispatchableEventBus<V, T> extends AbstractDelayEventBus<V, T> {
    public void add(V event);
    public V take();
    public int size();
    public void clear();
}

Import

import org.apache.dolphinscheduler.server.master.engine.task.dispatcher.WorkerGroupDispatcherCoordinator;

I/O Contract

Inputs

Name Type Required Description
taskExecutionRunnable ITaskExecutionRunnable Yes Task with execution context and target worker group
delayTimeMills long No Delay before dispatch (0 for immediate)

Outputs

Name Type Description
Task dispatch RPC call Task dispatched to selected worker via ITaskExecutorClient
TaskDispatchableEvent Event Event added to delay queue for deferred processing

Usage Examples

Dispatching a Task Immediately

// In workflow event processing
workerGroupDispatcherCoordinator.dispatchTask(taskExecutionRunnable, 0);

Dispatching with Delay

// Retry with 30-second delay
workerGroupDispatcherCoordinator.dispatchTask(taskExecutionRunnable, 30000);

Cancelling a Pending Dispatch

boolean removed = workerGroupDispatcherCoordinator.removeTask(taskExecutionRunnable);

Related Pages

Implements Principle

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment