-
Notifications
You must be signed in to change notification settings - Fork 17k
Add Java SDK #65956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jason810496
wants to merge
16
commits into
apache:main
Choose a base branch
from
astronomer:feature/java-sdk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add Java SDK #65956
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c03cce0
Initial Java-SDK
jason810496 f3ba258
Rename language field as sdk in java-sdk
jason810496 876179a
Add ADRs for JavaSDK and Coordinator
jason810496 26e6fa9
Add lisense header
jason810496 b47360d
Add test coverage for process management
jason810496 aa12466
CI: Fix yamllint check
jason810496 0bbd499
Fix stray character
uranusjr 728813f
Introduce Bundle and Dag Builder patterns (#1572)
uranusjr 7ac6547
Apply ktlintFormat changes (#1574)
uranusjr ee623c0
Remove dag parameters for now (#1573)
uranusjr 3cd2322
Add ktlint pre-commit hook (#1575)
uranusjr 45e1d81
Fix license in example
uranusjr 584e0b1
Enhance ADR documentation for Java SDK to reflect latest discussion
jason810496 26247c7
Move sdk.java out of provider as coordinator-java distribution
jason810496 fdb38ca
Pass runtime context to Task::execute
uranusjr ae91075
Introduce Builder annotations (#1576)
uranusjr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1129,6 +1129,7 @@ opsgenie | |
| Optimise | ||
| optimise | ||
| optimizationObjective | ||
| OptIn | ||
| optionality | ||
| ora | ||
| oracledb | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| uv run validation/serialization/compare.py \ | ||
| validation/serialization/serialized_python.json \ | ||
| validation/serialization/serialized_java.json | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.