Skip to content

Commit 51a9fb2

Browse files
author
苏义超
committed
Merge branch 'Improvement-18056-extract-syc' of github.com:njnu-seafish/dolphinscheduler into Improvement-18056-extract-syc
2 parents 4a7af80 + c502ea1 commit 51a9fb2

49 files changed

Lines changed: 1654 additions & 213 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ dolphinscheduler-master/logs
5555
dolphinscheduler-api/logs
5656
__pycache__
5757
ds_schema_check_test
58+
docs/superpowers/

CLAUDE.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# CLAUDE.md — Apache DolphinScheduler
2+
3+
Apache DolphinScheduler is a distributed, visual DAG workflow-scheduling platform. This is the monorepo: backend servers (master / worker / api / alert), a Vue 3 frontend, plugin families for tasks / datasources / storage / alerting / scheduling, and the release tooling.
4+
5+
**This file is an index.** Each module has its own `CLAUDE.md` with the details — do not duplicate module contents here.
6+
7+
---
8+
9+
## Tech stack (project-wide)
10+
11+
- **Java 1.8** (do not assume 11+ APIs; `dolphinscheduler-api-test` is the only Java 11 island).
12+
- **Spring Boot 2.6.1** across servers, **Jetty** (Tomcat is excluded transitively).
13+
- **MyBatis-Plus** for ORM; **HikariCP** for the metadata DB pool, **Druid** inside user-facing datasource plugins.
14+
- **Quartz** for cron scheduling (via `scheduler-plugin`).
15+
- **Netty / gRPC** for inter-server RPC (see `extract-base`).
16+
- **Vue 3 + Vite + TypeScript + Naive UI** for the frontend.
17+
- **Maven** multi-module reactor (26 modules in root `pom.xml` + 2 test modules).
18+
- **Zookeeper 3.8** by default for the registry (Etcd and JDBC also supported).
19+
20+
## Runnable services
21+
22+
A production deployment runs **four independent services** (plus an external registry and metadata DB). A fifth entry point — `StandaloneServer` — embeds all four in one JVM for development.
23+
24+
| Service | Module | Main class | Default ports |
25+
|---------|--------|------------|---------------|
26+
| **API** | [`dolphinscheduler-api`](dolphinscheduler-api/CLAUDE.md) | `org.apache.dolphinscheduler.api.ApiApplicationServer` | `12345` (HTTP / UI + REST) |
27+
| **Master** | [`dolphinscheduler-master`](dolphinscheduler-master/CLAUDE.md) | `org.apache.dolphinscheduler.server.master.MasterServer` | `5679` (RPC) |
28+
| **Worker** | [`dolphinscheduler-worker`](dolphinscheduler-worker/CLAUDE.md) | `org.apache.dolphinscheduler.server.worker.WorkerServer` | `1235` (RPC) |
29+
| **Alert** | [`dolphinscheduler-alert`](dolphinscheduler-alert/CLAUDE.md) (→ `-alert-server`) | `org.apache.dolphinscheduler.alert.AlertServer` | `50053` (HTTP), `50052` (RPC) |
30+
| Standalone (dev only) | [`dolphinscheduler-standalone-server`](dolphinscheduler-standalone-server/CLAUDE.md) | `org.apache.dolphinscheduler.StandaloneServer` | `12345` + `50052` (API + alert; master/worker use in-JVM calls) |
31+
32+
Every service is a `@SpringBootApplication` on Jetty and implements `IStoppable`. Scale Master / Worker / Alert horizontally; coordination happens via the registry (Zookeeper by default). API is stateless and also scales horizontally behind a load balancer.
33+
34+
Ports are overridable via `server.port` / service-specific keys in each service's `application.yaml`.
35+
36+
## Build & run
37+
38+
```bash
39+
# Full build (release profile; produces dist tarball)
40+
./mvnw clean install -Prelease
41+
42+
# Zookeeper 3.4 legacy
43+
./mvnw clean install -Prelease -Dzk-3.4
44+
45+
# Skip UI build (faster iteration on backend only)
46+
./mvnw -pl '!dolphinscheduler-ui' clean install
47+
48+
# Build one module (+ its required siblings)
49+
./mvnw -pl dolphinscheduler-master -am clean install
50+
51+
# Format (Spotless is configured)
52+
./mvnw spotless:apply
53+
54+
# Standalone server (after building)
55+
cd dolphinscheduler-standalone-server/target && ./bin/start.sh
56+
```
57+
58+
Binary artifact: `dolphinscheduler-dist/target/apache-dolphinscheduler-*-bin.tar.gz`.
59+
60+
## Test
61+
62+
```bash
63+
# Unit tests for one module
64+
./mvnw -pl dolphinscheduler-master test
65+
66+
# API integration tests (separate reactor, requires Docker)
67+
mvn -pl dolphinscheduler-api-test/dolphinscheduler-api-test-case test
68+
69+
# E2E browser tests (Selenium + Docker)
70+
mvn -pl dolphinscheduler-e2e/dolphinscheduler-e2e-case test
71+
72+
# Apple Silicon: add -Dm1_chip=true to the Docker-driven suites
73+
```
74+
75+
---
76+
77+
## Module index
78+
79+
Click into a module's `CLAUDE.md` for details. Each description is one line here on purpose.
80+
81+
### Core execution
82+
83+
- [`dolphinscheduler-master`](dolphinscheduler-master/CLAUDE.md) — workflow orchestration engine; consumes `Command`s, runs the DAG state machine, dispatches to workers.
84+
- [`dolphinscheduler-worker`](dolphinscheduler-worker/CLAUDE.md) — runs physical tasks dispatched from master; hosts task plugins.
85+
- [`dolphinscheduler-task-executor`](dolphinscheduler-task-executor/CLAUDE.md) — reusable task-lifecycle framework embedded by the worker.
86+
- [`dolphinscheduler-alert`](dolphinscheduler-alert/CLAUDE.md) — alert server + channel plugins (email, Feishu, DingTalk, …).
87+
88+
### API layer
89+
90+
- [`dolphinscheduler-api`](dolphinscheduler-api/CLAUDE.md) — REST API server (entry point for UI, Python SDK, external clients).
91+
- [`dolphinscheduler-api-test`](dolphinscheduler-api-test/CLAUDE.md) — integration tests against the REST API (Docker Compose + Testcontainers).
92+
- [`dolphinscheduler-authentication`](dolphinscheduler-authentication/CLAUDE.md) — Actuator-endpoint auth + AWS credential helpers (NOT the main login path).
93+
94+
### Shared libraries
95+
96+
- [`dolphinscheduler-common`](dolphinscheduler-common/CLAUDE.md) — foundation utilities (everything depends on this).
97+
- [`dolphinscheduler-dao`](dolphinscheduler-dao/CLAUDE.md) — MyBatis DAO layer + SQL migration scripts.
98+
- [`dolphinscheduler-service`](dolphinscheduler-service/CLAUDE.md) — business logic between DAO and the servers.
99+
- [`dolphinscheduler-spi`](dolphinscheduler-spi/CLAUDE.md) — Service-Provider Interface root (every plugin depends on this).
100+
- [`dolphinscheduler-extract`](dolphinscheduler-extract/CLAUDE.md) — RPC interface contracts between servers.
101+
- [`dolphinscheduler-eventbus`](dolphinscheduler-eventbus/CLAUDE.md) — in-process event-bus abstractions.
102+
- [`dolphinscheduler-registry`](dolphinscheduler-registry/CLAUDE.md) — pluggable registry (Zookeeper / Etcd / JDBC).
103+
- [`dolphinscheduler-meter`](dolphinscheduler-meter/CLAUDE.md) — metrics (Prometheus) + server load-protection primitives.
104+
105+
### Plugin families
106+
107+
- [`dolphinscheduler-task-plugin`](dolphinscheduler-task-plugin/CLAUDE.md) — task-type plugins (shell, SQL, Spark, Flink, K8s, EMR, …). 33 concrete plugins.
108+
- [`dolphinscheduler-datasource-plugin`](dolphinscheduler-datasource-plugin/CLAUDE.md) — user-facing datasource plugins (MySQL, Hive, Trino, Snowflake, …). 28 concrete plugins.
109+
- [`dolphinscheduler-storage-plugin`](dolphinscheduler-storage-plugin/CLAUDE.md) — resource storage (S3, HDFS, OSS, GCS, ABS, OBS, COS).
110+
- [`dolphinscheduler-scheduler-plugin`](dolphinscheduler-scheduler-plugin/CLAUDE.md) — cron scheduler (Quartz today).
111+
- [`dolphinscheduler-dao-plugin`](dolphinscheduler-dao-plugin/CLAUDE.md) — metadata-DB dialect support (MySQL / PostgreSQL / H2).
112+
113+
### Build, ops, tools
114+
115+
- [`dolphinscheduler-bom`](dolphinscheduler-bom/CLAUDE.md) — Maven BOM; central dependency version pinning.
116+
- [`dolphinscheduler-dist`](dolphinscheduler-dist/CLAUDE.md) — assembles the release tarball + Docker images.
117+
- [`dolphinscheduler-standalone-server`](dolphinscheduler-standalone-server/CLAUDE.md) — all-in-one JVM with H2 (dev / smoke tests).
118+
- [`dolphinscheduler-tools`](dolphinscheduler-tools/CLAUDE.md) — CLIs for schema upgrade + resource / lineage migration.
119+
- [`dolphinscheduler-microbench`](dolphinscheduler-microbench/CLAUDE.md) — JMH micro-benchmarks.
120+
- [`dolphinscheduler-yarn-aop`](dolphinscheduler-yarn-aop/CLAUDE.md) — AspectJ weaver capturing YARN ApplicationIds.
121+
122+
### Frontend & E2E
123+
124+
- [`dolphinscheduler-ui`](dolphinscheduler-ui/CLAUDE.md) — Vue 3 frontend.
125+
- [`dolphinscheduler-e2e`](dolphinscheduler-e2e/CLAUDE.md) — Selenium browser tests.
126+
127+
---
128+
129+
## Architecture overview (one paragraph)
130+
131+
A **user** hits the UI, which calls the API server. The API server writes to the **metadata DB** and, for runtime operations (start / kill / pause workflow), talks to the **master** over RPC. The master consumes `t_ds_command` rows, runs the workflow state machine, and dispatches tasks to **workers**. Workers execute task plugins (shell, SQL, Spark, …) and stream lifecycle events back to master. Failures and SLA breaches flow to the **alert server**, which fans out through alert plugins. **Registry** (Zookeeper / Etcd / JDBC) provides service discovery, leader election, and distributed locks. **Storage plugins** back the resource center and distributed-task artifacts. **Quartz** (via scheduler plugin) fires scheduled workflows, which become new `Command` rows.
132+
133+
## Where things live (quick lookup)
134+
135+
| Looking for… | Start here |
136+
|--------------|------------|
137+
| A REST endpoint | `dolphinscheduler-api/src/main/java/.../api/controller/` |
138+
| Workflow execution logic | `dolphinscheduler-master/src/main/java/.../server/master/engine/` |
139+
| Task execution logic | `dolphinscheduler-worker` + the specific `task-plugin/<type>` |
140+
| How "X" is stored | `dolphinscheduler-dao/src/main/java/.../dao/entity/` |
141+
| SQL schema / upgrade | `dolphinscheduler-dao/src/main/resources/sql/` |
142+
| RPC contract between servers | `dolphinscheduler-extract/dolphinscheduler-extract-<role>` |
143+
| UI page source | `dolphinscheduler-ui/src/views/<feature>/` |
144+
| API call in the UI | `dolphinscheduler-ui/src/service/modules/<resource>.ts` |
145+
| Version of a dependency | `dolphinscheduler-bom/pom.xml` |
146+
147+
## Project-wide conventions
148+
149+
- **Formatting**: `./mvnw spotless:apply`. CI will fail PRs that aren't formatted. Java imports are ordered; license headers are enforced.
150+
- **Commit style**: `[Type-ISSUE_ID] [Scope] Subject`, e.g. `[Fix-18168] [Worker] ...`. Scopes match module names.
151+
- **Branching**: `dev` is the main integration branch (not `main`/`master`).
152+
- **PRs must link a GitHub issue** and keep their scope tight — one module / one concern.
153+
- **Do not break wire / DB compatibility** silently. Changes to `extract-*` RPC interfaces, `dao` entities, enum values, and `spi.DbType` ripple to deployed clusters mid-upgrade.
154+
- **Only one registry / storage / DB dialect is active at runtime**. Code paths that check "which one" belong inside the plugin SPI, not sprinkled through services.
155+
156+
## External references
157+
158+
- Release docs (version-specific): https://dolphinscheduler.apache.org/en-us/docs
159+
- GitHub issues: https://github.com/apache/dolphinscheduler/issues
160+
- Python SDK: https://dolphinscheduler.apache.org/python/main/index.html
161+
- Contribution guide: [`docs/docs/en/contribute/join/contribute.md`](docs/docs/en/contribute/join/contribute.md)

docs/docs/en/guide/alert/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you need to use `Http script` for alerting, create an alert instance in the a
1212
| Body | The request body of the `Http` request in JSON format, when using `POST` or `PUT` method to alert. |
1313
| Content Type | The content-type of header. |
1414

15-
> Alarm message supports variables `$msg`, which can be used in `URL`, `Headers`, and `Body`.
15+
> Alarm message supports variables `${msg}`, which can be used in `URL`, `Headers`, and `Body`.
1616
1717
### GET HTTP
1818

docs/docs/zh/guide/alert/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| 请求体(Body) | Http`请求的完整请求体,以JSON为格式,非必填 |
1313
| Content-Type | 请求体的`Content-Type`,默认为`application/json` |
1414

15-
> 告警消息,支持变量`$msg`,可在`URL`,`请求头`,`请求体`中使用,非必填。
15+
> 告警消息,支持变量`${msg}`,可在`URL`,`请求头`,`请求体`中使用,非必填。
1616
1717
### GET Http告警
1818

dolphinscheduler-alert/CLAUDE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# CLAUDE.md — dolphinscheduler-alert
2+
3+
Alert / notification subsystem. Master and worker publish alert events (task failure, timeout, SLA breach, …); this subsystem evaluates them and dispatches via configured channel plugins (email, webhook, Feishu, DingTalk, PagerDuty, …).
4+
5+
**This directory is a Maven parent POM.**
6+
7+
## Sub-modules
8+
9+
- **`dolphinscheduler-alert-server`** — the runnable alert server. `@SpringBootApplication` `AlertServer` + HA coordinator (`AlertHAServer`) + RPC server (`AlertRpcServer`) + event loop.
10+
- **`dolphinscheduler-alert-plugins`** — parent of the concrete channel plugins:
11+
- `dolphinscheduler-alert-email`, `-http`, `-feishu`, `-dingtalk`, `-wechat`, `-webexteams`, `-pagerduty`, `-telegram`, `-slack`, `-script`, etc. (see directory listing for the current set). Each plugin implements the `AlertPlugin` SPI and is loaded dynamically at runtime.
12+
13+
## How alerting works (end-to-end)
14+
15+
1. Master/worker calls into `dolphinscheduler-extract-alert` RPC with an `AlertRequest`.
16+
2. `AlertRpcServer` receives it, persists/enqueues onto `AlertEventPendingQueue`.
17+
3. `AlertEventFetcher` pulls pending events in `AlertEventLoop`.
18+
4. `AlertSender` looks up the alert group's configured plugins, invokes each.
19+
5. Delivery result is recorded to the DB for audit.
20+
21+
## Extension points
22+
23+
- **`AlertPlugin` SPI** — new channel? Implement the interface in a new sub-module of `dolphinscheduler-alert-plugins` and it will be discovered by `AlertPluginManager`.
24+
- Alert rule logic is currently fixed (type-based); extending rules means editing `AlertEventLoop` / `AlertSender`.
25+
26+
## Gotchas
27+
28+
- **Alert server is separate from master/worker** by design. Running it as an embedded part of master is not supported — it has its own HA, its own port, its own `application.yaml`.
29+
- **`AlertEventPendingQueue` is DB-backed** (not just in-memory) so restarting the alert server does not lose queued alerts.
30+
- **HA pattern mirrors master/worker**: only the leader pulls from the queue; others stand by.
31+
- **Plugin config is per-alert-group**, stored in the DB. Adding a plugin implementation does not enable it for anyone until an admin creates an alert group referencing it.
32+
- **Channel-specific rate limits / retries** live *inside* each plugin, not in the server. Don't add a global retry loop in `AlertSender`.
33+
34+
## Tests
35+
36+
- `alert-server/src/test/java` — unit tests for config, RPC, event queue, sender.
37+
- Each plugin has its own `src/test/java` with mocked channel calls.
38+
39+
## Related modules
40+
41+
- `dolphinscheduler-extract-alert` — RPC contracts this server implements.
42+
- `dolphinscheduler-dao` — persists alert events + audit.
43+
- `dolphinscheduler-registry-all`, `dolphinscheduler-meter`, `dolphinscheduler-spi`.
44+
- Callers: `dolphinscheduler-master`, `dolphinscheduler-worker`.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# CLAUDE.md — dolphinscheduler-api-test
2+
3+
Integration test harness for the REST API. **Not** bundled into the release — this module exists to run curl-style black-box tests against a full DolphinScheduler stack booted via Docker Compose + Testcontainers.
4+
5+
**This is a Maven parent POM.** This module is **not** declared in the root `pom.xml` `<modules>` — run it explicitly (e.g. `mvn -pl dolphinscheduler-api-test test -am`) or via CI workflows.
6+
7+
## Sub-modules
8+
9+
- **`dolphinscheduler-api-test-core`** — the reusable framework:
10+
- `@DolphinScheduler` annotation (marks a test class, accepts `composeFiles`).
11+
- `DolphinSchedulerExtension` — JUnit 5 extension that starts the Compose stack, injects `RequestClient` and page objects.
12+
- `RequestClient` — thin HTTP client with session handling.
13+
- Page-object base classes (`LoginPage`, `WorkflowDefinitionPage`, `ProjectPage`, `TenantPage`, `UserPage`, `WorkerGroupPage`).
14+
- **`dolphinscheduler-api-test-case`** — the actual test classes. `WorkflowDefinitionAPITest`, `TenantAPITest`, `SchedulerAPITest`, etc. Each class uses `@DolphinScheduler(composeFiles = { "docker/basic/docker-compose.yaml" })` to declare its environment.
15+
16+
## Stack bootstrap
17+
18+
Compose files live under `src/test/resources/docker/<scenario>/docker-compose.yaml`:
19+
20+
- `basic/` — standard API + Postgres.
21+
- `tenant/` — scenario with multi-tenant configuration.
22+
- `oidc-login/` — API with Keycloak for OIDC flow (`realm-export.json` alongside).
23+
24+
The JUnit extension uses Testcontainers Compose to wait for port readiness before returning.
25+
26+
## Running
27+
28+
```
29+
# Full suite
30+
mvn -pl dolphinscheduler-api-test/dolphinscheduler-api-test-case test
31+
32+
# Single class (Mac M1)
33+
mvn -pl dolphinscheduler-api-test/dolphinscheduler-api-test-case test \
34+
-Dtest=WorkflowDefinitionAPITest -Dm1_chip=true
35+
```
36+
37+
Flags:
38+
39+
- `-Dm1_chip=true` — forces `arm64/v8` platform for Docker on Apple Silicon.
40+
- `-Dlocal=true` — skips Testcontainers and points at a locally-running DolphinScheduler instead.
41+
42+
## Gotchas
43+
44+
- **Java 11 required** to compile this module (rest of the repo targets 1.8).
45+
- **`@Order` is mandatory** on test methods within a class — tests are state-dependent and must run in declared order.
46+
- **`@DisableIfTestFails` (from junit-pioneer)** cascades a failure to dependent tests in the same class; don't silently disable without understanding the chain.
47+
- **`sessionId` is threaded through page objects**: `LoginPage.login(...)` returns a session ID that subsequent page objects must receive. Don't instantiate page objects without first logging in.
48+
- **This module is excluded from the root reactor build** — CI drives it via a dedicated workflow. Check `.github/workflows/` before assuming a PR runs these.
49+
50+
## Related modules
51+
52+
- `dolphinscheduler-api` — the system under test.
53+
- `dolphinscheduler-dao` — depended on to reuse entity DTOs.
54+
- `dolphinscheduler-e2e` — complementary browser-level tests (selenium against UI).

0 commit comments

Comments
 (0)