Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ opsgenie
Optimise
optimise
optimizationObjective
OptIn
optionality
ora
oracledb
Expand Down
31 changes: 31 additions & 0 deletions java-sdk/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[*.java]
indent_size = 2

[*.kt]
indent_size = 2
11 changes: 11 additions & 0 deletions java-sdk/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary
56 changes: 56 additions & 0 deletions java-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.kotlin

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
# Ignore Gradle build output directory
build

### Artifacts of airflow standalone command ###
airflow.cfg
airflow.db
simple_auth_manager_passwords.json.generated
logs/dag_id=*
logs/dag_processor

### Compatibility Test Results ###
validation/serialization/serialized_java.json
validation/serialization/serialized_python.json
74 changes: 74 additions & 0 deletions java-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Airflow Java SDK

A **JVM** SDK for Apache Airflow. You can use any JVM-compatible language to write
workflow bundles, and have Airflow consume the result.

The SDK and execution-time logic is implemented in Kotlin.
An example is bundled showing how the SDK can be used in Java.

## Building

```bash
./gradlew build
```

## Technical Details

The Java program is launched as a subprocess by the Airflow worker and communicates
through TCP sockets. The Java program accepts flags `--comm` and `--logs` from the
command line.

The Java program "parses" DAGs on launch, and then connects to the specified TCP servers.
The rest is similar to the standard Airflow:

* DAG-parsing:
1. On connection, the parent immediately sends a DagParsingRequest through the socket.
2. The Java program sends back a DagParsingResult to the parent.
3. The Java program exits.
* Execution:
1. On connection, the parent immediately sends a StartupDetails through the socket.
2. The Java program uses the information to find the relevant task to execute.
3. The task is run.
4. The Java program tells the parent to update the task's terminal state.
5. The Java program exits.

Communication uses the same formats as the Python-based processes.

## Serialization Validation

Workflow:

```bash
# 1. Generate Java output (runs as part of normal test suite)
# More specifically, the test `sdk/src/test/kotlin/org/apache/airflow/sdk/execution/SerializationCompatibilityTest.kt` generates the output file `validation/serialization/serialized_java.json`.
./gradlew sdk:test

# 2. Generate Python output (requires Airflow env)
uv run validation/serialization/serialize_python.py \
validation/serialization/test_dags.yaml \
validation/serialization/serialized_python.json

# 3. Compare
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered implementing this via a pytest?

Copy link
Copy Markdown
Member Author

@jason810496 jason810496 Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to finish it in #65959.

It should be integrated as part of CI, either in prek hook static check or pytest to guard the compatibility between each language and the breaking changes in Airflow internal serialization format.

uv run validation/serialization/compare.py \
validation/serialization/serialized_python.json \
validation/serialization/serialized_java.json
```
Loading
Loading