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 AbstractClusterSubscribeListener Notify

From Leeroopedia


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

Overview

Concrete tool for detecting node failures through AbstractClusterSubscribeListener which processes registry REMOVE events and notifies cluster change listeners.

Description

AbstractClusterSubscribeListener<T> is an abstract class implementing SubscribeListener from the registry API. Its notify(Event) method processes registry events: it parses the heartbeat JSON from the event data using parseServerFromHeartbeat(String), then routes to onServerAdded(), onServerRemove(), or onServerUpdate() based on the event type. MasterClusters and WorkerClusters extend this class and implement the routing methods.

Usage

Registered as a subscriber with the registry client during cluster initialization. Processes events automatically.

Code Reference

Source Location

  • Repository: dolphinscheduler
  • File: dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/AbstractClusterSubscribeListener.java (L26-72)

Signature

public abstract class AbstractClusterSubscribeListener<T>
        implements SubscribeListener {
    @Override
    public void notify(Event event);

    public abstract SubscribeScope getSubscribeScope();

    protected abstract T parseServerFromHeartbeat(String heartBeatJson);
    protected abstract void onServerAdded(T server);
    protected abstract void onServerRemove(T server);
    protected abstract void onServerUpdate(T server);
}

Import

import org.apache.dolphinscheduler.server.master.cluster.AbstractClusterSubscribeListener;

I/O Contract

Inputs

Name Type Required Description
Event Registry Event Yes Contains type (ADD/REMOVE/UPDATE), key (path), and data (heartbeat JSON)

Outputs

Name Type Description
Cluster topology update Internal state Server added/removed from cluster maps
Listener notifications Callbacks All IClustersChangeListener instances notified

Usage Examples

Event Processing Flow

// When a worker node crashes:
// 1. ZooKeeper session expires
// 2. Registry fires REMOVE event with path "/workers/worker-1:1234"
// 3. AbstractClusterSubscribeListener.notify(event) is called
// 4. parseServerFromHeartbeat(event.data()) extracts WorkerServerMetadata
// 5. onServerRemove(workerMetadata) removes from WorkerClusters map
// 6. All IClustersChangeListener.onServerRemove() called
// 7. FailoverCoordinator receives notification and starts worker failover

Related Pages

Implements Principle

Requires Environment

Page Connections

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