From c85472539e28e49930514b5ed19e057328de3b8c Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 20 Jul 2024 21:28:02 +0800 Subject: [PATCH 1/8] [DSIP-9][feature]add raft registration plugin --- dolphinscheduler-bom/pom.xml | 8 + .../common/constants/Constants.java | 5 + dolphinscheduler-dist/release-docs/LICENSE | 22 +- .../licenses/LICENSE-affinity.txt | 201 +++++++++++++++ .../release-docs/licenses/LICENSE-bolt.txt | 201 +++++++++++++++ .../licenses/LICENSE-collectionschema.txt | 201 +++++++++++++++ .../licenses/LICENSE-disruptor.txt | 201 +++++++++++++++ .../release-docs/licenses/LICENSE-hessian.txt | 201 +++++++++++++++ .../licenses/LICENSE-jctools-core.txt | 201 +++++++++++++++ .../licenses/LICENSE-jraft-core.txt | 201 +++++++++++++++ .../licenses/LICENSE-jraft-rheakv-core.txt | 201 +++++++++++++++ .../licenses/LICENSE-metrics-core.txt | 201 +++++++++++++++ .../licenses/LICENSE-protostuff-core.txt | 201 +++++++++++++++ .../licenses/LICENSE-protostuff-runtime.txt | 201 +++++++++++++++ .../licenses/LICENSE-rocksdbjni.txt | 201 +++++++++++++++ .../licenses/LICENSE-sofa-common-tools.txt | 201 +++++++++++++++ .../dolphinscheduler-registry-all/pom.xml | 5 + .../dolphinscheduler-registry-raft/README.md | 56 ++++ .../dolphinscheduler-registry-raft/pom.xml | 56 ++++ .../raft/IRaftConnectionStateManager.java | 47 ++++ .../registry/raft/IRaftLockManager.java | 59 +++++ .../raft/IRaftSubscribeDataManager.java | 40 +++ .../raft/RaftConnectionStateManager.java | 141 ++++++++++ .../plugin/registry/raft/RaftLockManager.java | 139 ++++++++++ .../raft/RaftRegisterAutoConfiguration.java | 53 ++++ .../plugin/registry/raft/RaftRegistry.java | 141 ++++++++++ .../registry/raft/RaftRegistryProperties.java | 43 ++++ .../raft/RaftSubscribeDataManager.java | 162 ++++++++++++ .../raft/client/IRaftRegisterClient.java | 130 ++++++++++ .../raft/client/RaftRegisterClient.java | 206 +++++++++++++++ .../raft/server/RaftRegisterServer.java | 79 ++++++ .../main/resources/META-INF/spring.factories | 19 ++ .../register/raft/RaftRegistryTestCase.java | 240 ++++++++++++++++++ .../src/test/resources/application.yaml | 30 +++ .../dolphinscheduler-registry-plugins/pom.xml | 1 + 35 files changed, 4290 insertions(+), 5 deletions(-) create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-affinity.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-bolt.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-collectionschema.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-disruptor.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-hessian.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-jctools-core.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-core.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-rheakv-core.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-metrics-core.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-core.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-runtime.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-rocksdbjni.txt create mode 100644 dolphinscheduler-dist/release-docs/licenses/LICENSE-sofa-common-tools.txt create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/pom.xml create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml diff --git a/dolphinscheduler-bom/pom.xml b/dolphinscheduler-bom/pom.xml index b7efb4815cf1..61d73dbd6f27 100644 --- a/dolphinscheduler-bom/pom.xml +++ b/dolphinscheduler-bom/pom.xml @@ -124,6 +124,7 @@ 0.10.1 2.1.4 0.3.2 + 1.3.14 @@ -986,6 +987,13 @@ delight-nashorn-sandbox ${nashorn-sandbox.version} + + + + com.alipay.sofa + jraft-rheakv-core + ${jraft.version} + diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/Constants.java index cb0b81201107..426450012dad 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/Constants.java @@ -695,4 +695,9 @@ public final class Constants { public static final String RELEASE_STATE = "releaseState"; public static final String EXECUTE_TYPE = "executeType"; + /** + * use for endKey of RheaKVStore scan + */ + public static final String RAFT_END_KEY = "zzzz"; + } diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE index a4cdfeadabbc..b5b6f9eb3d68 100644 --- a/dolphinscheduler-dist/release-docs/LICENSE +++ b/dolphinscheduler-dist/release-docs/LICENSE @@ -572,11 +572,23 @@ The text of each license is also included at licenses/LICENSE-[project].txt. tea-rpc-util 0.1.3.jar https://github.com/aliyun/aliyun-openapi-java-sdk/blob/master/README.md#license Apache 2.0 tea-util 0.2.13.jar https://github.com/aliyun/aliyun-openapi-java-sdk/blob/master/README.md#license Apache 2.0 delight-nashorn-sandbox 0.3.2 https://github.com/javadelight/delight-nashorn-sandbox/blob/master/README.md#license Apache 2.0 - - - - - + jraft-core 1.3.14: https://mvnrepository.com/artifact/com.alipay.sofa/jraft-core/1.3.14 Apache 2.0 + jctools-core 2.1.1: https://mvnrepository.com/artifact/org.jctools/jctools-core/2.1.1 Apache 2.0 + commons-lang 2.6 https://mvnrepository.com/artifact/commons-lang/commons-lang/2.6 Apache 2.0 + hessian 3.3.6: https://mvnrepository.com/artifact/com.alipay.sofa/hessian/3.3.6 Apache 2.0 + metrics-core 4.2.11: https://mvnrepository.com/artifact/io.dropwizard.metrics/metrics-core/4.2.11 Apache 2.0 + affinity 3.1.7: https://mvnrepository.com/artifact/net.openhft/affinity/3.1.7, Apache 2.0 + disruptor 3.3.7: https://mvnrepository.com/artifact/com.lmax/disruptor/3.3.7, Apache 2.0 + commons-compress 1.21: https://mvnrepository.com/artifact/org.apache.commons/commons-compress/1.21 Apache 2.0 + bolt 1.6.4: https://mvnrepository.com/artifact/com.alipay.sofa/bolt/1.6.4, Apache 2.0 + rocksdbjni 8.8.1: https://mvnrepository.com/artifact/org.rocksdb/rocksdbjni/8.8.1, Apache 2.0 + jraft-rheakv-core 1.3.14: https://mvnrepository.com/artifact/com.alipay.sofa/jraft-rheakv-core/1.3.14, Apache 2.0 + sofa-common-tools 1.0.12: https://mvnrepository.com/artifact/com.alipay.sofa.common/sofa-common-tools/1.0.12 Apache 2.0 + annotations 12.0: https://mvnrepository.com/artifact/com.intellij/annotations/12.0 Apache 2.0 + protostuff-core 1.7.2: https://mvnrepository.com/artifact/io.protostuff/protostuff-core/1.7.2 Apache 2.0 + protostuff-api 1.7.2: https://mvnrepository.com/artifact/io.protostuff/protostuff-api/1.7.2 Apache 2.0 + protostuff-runtime 1.7.2: https://mvnrepository.com/artifact/io.protostuff/protostuff-runtime/1.7.2 Apache 2.0 + protostuff-collectionschema 1.7.2: https://mvnrepository.com/artifact/io.protostuff/protostuff-collectionschema/1.7.2 Apache 2.0 jna-platform diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-affinity.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-affinity.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-affinity.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-bolt.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-bolt.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-bolt.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-collectionschema.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-collectionschema.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-collectionschema.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-disruptor.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-disruptor.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-disruptor.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-hessian.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-hessian.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-hessian.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-jctools-core.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jctools-core.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jctools-core.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-core.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-core.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-core.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-rheakv-core.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-rheakv-core.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-jraft-rheakv-core.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-metrics-core.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-metrics-core.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-metrics-core.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-core.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-core.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-core.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-runtime.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-runtime.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-protostuff-runtime.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-rocksdbjni.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-rocksdbjni.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-rocksdbjni.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-dist/release-docs/licenses/LICENSE-sofa-common-tools.txt b/dolphinscheduler-dist/release-docs/licenses/LICENSE-sofa-common-tools.txt new file mode 100644 index 000000000000..aa29d40653a8 --- /dev/null +++ b/dolphinscheduler-dist/release-docs/licenses/LICENSE-sofa-common-tools.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014-2018 Chronicle Software Ltd + + Licensed 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. \ No newline at end of file diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-all/pom.xml b/dolphinscheduler-registry/dolphinscheduler-registry-all/pom.xml index ee0a30a03a8d..211c25c790b3 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-all/pom.xml +++ b/dolphinscheduler-registry/dolphinscheduler-registry-all/pom.xml @@ -42,5 +42,10 @@ dolphinscheduler-registry-etcd ${project.version} + + org.apache.dolphinscheduler + dolphinscheduler-registry-raft + ${project.version} + diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md new file mode 100644 index 000000000000..ddb67f645f1a --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md @@ -0,0 +1,56 @@ +# Introduction + +This module is the RAFT consensus algorithm registry plugin module, this plugin will use raft cluster as the registry center. +The Raft registration plugin consists of two parts: +the server and the client. The Master module of DolphinScheduler will form a Raft server cluster +, while the Worker modules and API modules will interact with the Raft server using the Raft client. + +# How to use + +If you want to set the registry center as raft, + +you need to set the registry properties in master/worker/api's appplication.yml, + + +`please remember change the server-port in appplication.yml`. + +NOTE: In production environment, in order to achieve high availability, the master must be an odd number e.g 3 or 5. + +master's properties example +```yaml +registry: + type: raft + cluster-name: dolphinscheduler + server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 + server-address: 127.0.0.1 + server-port: 8181 + log-storage-dir: raft-data/ + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: master +``` +worker's appplication.yml example +```yaml +registry: + type: raft + cluster-name: dolphinscheduler + server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: worker +``` +api's appplication.yml example +```yaml +registry: + type: raft + cluster-name: dolphinscheduler + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: api +``` + +Then you can start your DolphinScheduler cluster, your cluster will use raft cluster as registry center to +store server metadata. \ No newline at end of file diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/pom.xml b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/pom.xml new file mode 100644 index 000000000000..ef8fb361817d --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + org.apache.dolphinscheduler + dolphinscheduler-registry-plugins + dev-SNAPSHOT + + + dolphinscheduler-registry-raft + + + + org.apache.dolphinscheduler + dolphinscheduler-registry-api + + + org.apache.dolphinscheduler + dolphinscheduler-common + + + com.alipay.sofa + jraft-rheakv-core + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.dolphinscheduler + dolphinscheduler-registry-it + ${project.version} + test-jar + test + + + + diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java new file mode 100644 index 000000000000..1851896e351b --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java @@ -0,0 +1,47 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import org.apache.dolphinscheduler.registry.api.ConnectionListener; +import org.apache.dolphinscheduler.registry.api.ConnectionState; + +/** + * Interface for managing the connection state in a raft registry client. + */ +public interface IRaftConnectionStateManager extends AutoCloseable { + + /** + * Starts the connection state manager. + * This method initializes and starts monitoring the connection state. + */ + void start(); + + /** + * Adds a connection listener to listen for connection state changes. + * + * @param listener the listener to be added for connection state changes + */ + void addConnectionListener(ConnectionListener listener); + + /** + * Retrieves the current connection state. + * + * @return the current connection state + */ + ConnectionState getConnectionState(); +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java new file mode 100644 index 000000000000..e904dc4b0439 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java @@ -0,0 +1,59 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +/** + * Interface for managing locks in a raft registry client. + */ +public interface IRaftLockManager extends AutoCloseable { + + /** + * Acquires a lock with the specified key. + * This method blocks until the lock is acquired. + * + * @param lockKey the key for the lock + * @return true if the lock was successfully acquired, false otherwise + */ + boolean acquireLock(String lockKey); + + /** + * Acquires a lock with the specified key, with a timeout. + * This method blocks until the lock is acquired or the timeout is reached. + * + * @param lockKey the key for the lock + * @param timeout the maximum time to wait for the lock in milliseconds + * @return true if the lock was successfully acquired within the timeout, false otherwise + */ + boolean acquireLock(String lockKey, long timeout); + + /** + * Releases the lock with the specified key. + * + * @param lockKey the key for the lock + * @return true if the lock was successfully released, false otherwise + */ + boolean releaseLock(String lockKey); + + /** + * Closes the lock manager and releases any resources held by it. + * + * @throws Exception if an error occurs while closing the lock manager + */ + @Override + void close() throws Exception; +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java new file mode 100644 index 000000000000..f8ab846a72c3 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java @@ -0,0 +1,40 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import org.apache.dolphinscheduler.registry.api.SubscribeListener; + +/** + * Interface for managing data subscriptions in a raft registry client. + */ +public interface IRaftSubscribeDataManager extends AutoCloseable { + + /** + * Starts the data subscription manager. + * This method initializes and starts the data subscription functionality. + */ + void start(); + + /** + * Adds a listener to subscribe to data changes at the specified path. + * + * @param path the path to subscribe to for data changes + * @param listener the listener to be notified of data changes + */ + void addDataSubscribeListener(String path, SubscribeListener listener); +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java new file mode 100644 index 000000000000..e371bc6a3850 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java @@ -0,0 +1,141 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import org.apache.dolphinscheduler.registry.api.ConnectionListener; +import org.apache.dolphinscheduler.registry.api.ConnectionState; + +import java.time.Duration; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import lombok.extern.slf4j.Slf4j; + +import com.alipay.sofa.jraft.RouteTable; +import com.alipay.sofa.jraft.option.CliOptions; +import com.alipay.sofa.jraft.rpc.CliClientService; +import com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +@Slf4j +public class RaftConnectionStateManager implements IRaftConnectionStateManager { + + private static final String DEFAULT_REGION_ID = "--1"; + private ConnectionState currentConnectionState; + private static final Duration CONNECT_STATE_CHECK_INTERVENE = Duration.ofSeconds(2); + private final RaftRegistryProperties properties; + private final List connectionListeners = new CopyOnWriteArrayList<>(); + private final ScheduledExecutorService scheduledExecutorService; + private final CliOptions cliOptions; + private final CliClientService cliClientService; + + public RaftConnectionStateManager(RaftRegistryProperties properties) { + this.properties = properties; + this.cliOptions = new CliOptions(); + this.cliOptions.setMaxRetry(3); + this.cliOptions.setTimeoutMs(5000); + this.cliClientService = new CliClientServiceImpl(); + this.scheduledExecutorService = Executors.newScheduledThreadPool( + 1, + new ThreadFactoryBuilder().setNameFormat("ConnectionStateRefreshThread").setDaemon(true).build()); + } + + public void start() { + cliClientService.init(cliOptions); + scheduledExecutorService.scheduleWithFixedDelay( + new ConnectionStateRefreshTask(connectionListeners), + CONNECT_STATE_CHECK_INTERVENE.toMillis(), + CONNECT_STATE_CHECK_INTERVENE.toMillis(), + TimeUnit.MILLISECONDS); + } + + public void addConnectionListener(ConnectionListener listener) { + connectionListeners.add(listener); + } + + @Override + public ConnectionState getConnectionState() { + return currentConnectionState; + } + + class ConnectionStateRefreshTask implements Runnable { + + private final List connectionListeners; + ConnectionStateRefreshTask(List connectionListeners) { + this.connectionListeners = connectionListeners; + } + + @Override + public void run() { + try { + ConnectionState newConnectionState = getCurrentConnectionState(); + if (newConnectionState == currentConnectionState) { + // no state change + return; + } + if (newConnectionState == ConnectionState.DISCONNECTED + && currentConnectionState == ConnectionState.CONNECTED) { + currentConnectionState = ConnectionState.DISCONNECTED; + triggerListeners(ConnectionState.DISCONNECTED); + } else if (newConnectionState == ConnectionState.CONNECTED + && currentConnectionState == ConnectionState.DISCONNECTED) { + currentConnectionState = ConnectionState.CONNECTED; + triggerListeners(ConnectionState.RECONNECTED); + } else if (currentConnectionState == null) { + currentConnectionState = newConnectionState; + triggerListeners(currentConnectionState); + } + } catch (Exception ex) { + log.error("raft registry connection state check failed", ex); + currentConnectionState = ConnectionState.DISCONNECTED; + triggerListeners(ConnectionState.DISCONNECTED); + } + } + + private ConnectionState getCurrentConnectionState() { + try { + String groupId = properties.getClusterName() + DEFAULT_REGION_ID; + if (RouteTable.getInstance().refreshLeader(cliClientService, groupId, 2000).isOk()) { + return ConnectionState.CONNECTED; + } else { + return ConnectionState.DISCONNECTED; + } + } catch (Exception ex) { + log.error("cannot connect to raft leader", ex); + return ConnectionState.DISCONNECTED; + } + } + + private void triggerListeners(ConnectionState connectionState) { + for (ConnectionListener connectionListener : connectionListeners) { + connectionListener.onUpdate(connectionState); + } + } + } + + @Override + public void close() throws Exception { + connectionListeners.clear(); + scheduledExecutorService.shutdownNow(); + cliClientService.shutdown(); + } + +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java new file mode 100644 index 000000000000..1f7715318d0a --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java @@ -0,0 +1,139 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import org.apache.dolphinscheduler.common.thread.ThreadUtils; +import org.apache.dolphinscheduler.common.utils.NetUtils; +import org.apache.dolphinscheduler.common.utils.OSUtils; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import com.alipay.sofa.jraft.rhea.client.RheaKVStore; +import com.alipay.sofa.jraft.rhea.util.concurrent.DistributedLock; +import com.alipay.sofa.jraft.util.ExecutorServiceHelper; + +public class RaftLockManager implements IRaftLockManager { + + private final Map distributedLockMap = new ConcurrentHashMap<>(); + private final RheaKVStore rheaKvStore; + private final RaftRegistryProperties raftRegistryProperties; + private static final ScheduledExecutorService WATCH_DOG = Executors.newSingleThreadScheduledExecutor(); + private static final String LOCK_OWNER_PREFIX = NetUtils.getHost() + "_" + OSUtils.getProcessID() + "_"; + + public RaftLockManager(RheaKVStore rheaKVStore, RaftRegistryProperties raftRegistryProperties) { + this.rheaKvStore = rheaKVStore; + this.raftRegistryProperties = raftRegistryProperties; + } + + @Override + public boolean acquireLock(String lockKey) { + final String lockOwner = getLockOwnerPrefix(); + if (isThreadReentrant(lockKey, lockOwner)) { + return true; + } + + final DistributedLock distributedLock = rheaKvStore.getDistributedLock(lockKey, + raftRegistryProperties.getDistributedLockTimeout().toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); + + while (true) { + if (distributedLock.tryLock()) { + distributedLockMap.put(lockKey, LockEntry.builder().distributedLock(distributedLock) + .lockOwner(lockOwner) + .build()); + return true; + } else { + // fail to acquire lock + ThreadUtils.sleep(raftRegistryProperties.getDistributedLockRetryInterval().toMillis()); + } + } + } + + @Override + public boolean acquireLock(String lockKey, long timeout) { + final String lockOwner = getLockOwnerPrefix(); + if (isThreadReentrant(lockKey, lockOwner)) { + return true; + } + final long endTime = System.currentTimeMillis() + timeout; + final DistributedLock distributedLock = rheaKvStore.getDistributedLock(lockKey, + raftRegistryProperties.getDistributedLockTimeout().toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); + + while (System.currentTimeMillis() < endTime) { + if (distributedLock.tryLock()) { + distributedLockMap.put(lockKey, LockEntry.builder().distributedLock(distributedLock) + .lockOwner(lockOwner) + .build()); + return true; + } else { + // fail to acquire lock + ThreadUtils.sleep(raftRegistryProperties.getDistributedLockRetryInterval().toMillis()); + } + } + + return false; + } + + private boolean isThreadReentrant(String lockKey, String lockOwner) { + final LockEntry lockEntry = distributedLockMap.get(lockKey); + return lockEntry != null && lockOwner.equals(lockEntry.getLockOwner()); + } + + @Override + public boolean releaseLock(String lockKey) { + final String lockOwner = getLockOwnerPrefix(); + final LockEntry lockEntry = distributedLockMap.get(lockKey); + if (lockEntry == null || !lockOwner.equals(lockEntry.getLockOwner())) { + return false; + } + + final DistributedLock distributedLock = distributedLockMap.get(lockKey).getDistributedLock(); + if (distributedLock != null) { + distributedLock.unlock(); + } + distributedLockMap.remove(lockKey); + return true; + } + + public static String getLockOwnerPrefix() { + return LOCK_OWNER_PREFIX + Thread.currentThread().getName(); + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class LockEntry { + + private DistributedLock distributedLock; + private String lockOwner; + } + + @Override + public void close() throws Exception { + ExecutorServiceHelper.shutdownAndAwaitTermination(WATCH_DOG); + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java new file mode 100644 index 000000000000..91ff0f0927b7 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java @@ -0,0 +1,53 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import org.apache.dolphinscheduler.plugin.registry.raft.server.RaftRegisterServer; + +import lombok.extern.slf4j.Slf4j; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Slf4j +@Configuration(proxyBeanMethods = false) +@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft") +@EnableConfigurationProperties(RaftRegistryProperties.class) +public class RaftRegisterAutoConfiguration { + + public RaftRegisterAutoConfiguration() { + log.info("Load RaftRegisterAutoConfiguration"); + } + + @Bean + public RaftRegistry raftRegistry(RaftRegistryProperties raftRegistryProperties) { + RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); + raftRegistry.start(); + return raftRegistry; + } + + @Bean + @ConditionalOnProperty(prefix = "register", name = "module", havingValue = "master") + public RaftRegisterServer raftRegisterServer(RaftRegistryProperties raftRegistryProperties) { + RaftRegisterServer raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); + raftRegisterServer.start(); + return raftRegisterServer; + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java new file mode 100644 index 000000000000..7c00e6c69614 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java @@ -0,0 +1,141 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.apache.dolphinscheduler.common.thread.ThreadUtils; +import org.apache.dolphinscheduler.plugin.registry.raft.client.IRaftRegisterClient; +import org.apache.dolphinscheduler.plugin.registry.raft.client.RaftRegisterClient; +import org.apache.dolphinscheduler.registry.api.ConnectionListener; +import org.apache.dolphinscheduler.registry.api.Registry; +import org.apache.dolphinscheduler.registry.api.RegistryException; +import org.apache.dolphinscheduler.registry.api.SubscribeListener; + +import java.time.Duration; +import java.util.Collection; + +import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class RaftRegistry implements Registry { + + private final IRaftRegisterClient raftRegisterClient; + public RaftRegistry(RaftRegistryProperties raftRegistryProperties) { + this.raftRegisterClient = new RaftRegisterClient(raftRegistryProperties); + } + + @Override + public void start() { + log.info("starting raft registry..."); + raftRegisterClient.start(); + log.info("raft registry started successfully"); + } + + @Override + public boolean isConnected() { + return raftRegisterClient.isConnectivity(); + } + + @Override + public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryException { + try { + long startTimeMillis = System.currentTimeMillis(); + long endTimeMillis = timeout.toMillis() > 0 ? startTimeMillis + timeout.toMillis() : Long.MAX_VALUE; + + while (System.currentTimeMillis() < endTimeMillis) { + if (raftRegisterClient.isConnectivity()) { + return; + } + } + ThreadUtils.sleep(50); + } catch (Exception ex) { + throw new RegistryException("connect to raft cluster timeout", ex); + } + } + + @Override + public void subscribe(String path, SubscribeListener listener) { + checkNotNull(path); + checkNotNull(listener); + raftRegisterClient.subscribeRaftRegistryDataChange(path, listener); + } + + @Override + public void addConnectionStateListener(ConnectionListener listener) { + checkNotNull(listener); + raftRegisterClient.subscribeConnectionStateChange(listener); + } + + @Override + public String get(String key) { + checkNotNull(key); + return raftRegisterClient.getRegistryDataByKey(key); + } + + @Override + public void put(String key, String value, boolean deleteOnDisconnect) { + checkNotNull(key); + raftRegisterClient.putRegistryData(key, value, deleteOnDisconnect); + } + + @Override + public void delete(String key) { + checkNotNull(key); + raftRegisterClient.deleteRegistryDataByKey(key); + } + + @Override + public Collection children(String key) { + checkNotNull(key); + return raftRegisterClient.getRegistryDataChildren(key); + } + + @Override + public boolean exists(String key) { + checkNotNull(key); + return raftRegisterClient.existRaftRegistryDataKey(key); + } + + @Override + public boolean acquireLock(String key) { + checkNotNull(key); + return raftRegisterClient.acquireRaftRegistryLock(key); + } + + @Override + public boolean acquireLock(String key, long timeout) { + checkNotNull(key); + return raftRegisterClient.acquireRaftRegistryLock(key, timeout); + } + + @Override + public boolean releaseLock(String key) { + checkNotNull(key); + return raftRegisterClient.releaseRaftRegistryLock(key); + } + + @Override + public void close() { + log.info("closing raft registry..."); + raftRegisterClient.close(); + log.info("raft registry closed"); + } + +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java new file mode 100644 index 000000000000..f16a6694db54 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java @@ -0,0 +1,43 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import java.time.Duration; + +import lombok.Data; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Data +@Configuration +@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft") +@ConfigurationProperties(prefix = "registry") +public class RaftRegistryProperties { + + private String clusterName; + private String serverAddressList; + private String serverAddress; + private int serverPort; + private String logStorageDir; + private Duration distributedLockTimeout = Duration.ofSeconds(3); + private Duration distributedLockRetryInterval = Duration.ofSeconds(5); + private String module = "master"; + private Duration listenerCheckInterval = Duration.ofSeconds(3); +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java new file mode 100644 index 000000000000..c5f51f0c2b5b --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java @@ -0,0 +1,162 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft; + +import static com.alipay.sofa.jraft.util.BytesUtil.readUtf8; + +import org.apache.dolphinscheduler.common.constants.Constants; +import org.apache.dolphinscheduler.registry.api.Event; +import org.apache.dolphinscheduler.registry.api.SubscribeListener; +import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType; + +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import lombok.extern.slf4j.Slf4j; + +import com.alipay.sofa.jraft.rhea.client.RheaKVStore; +import com.alipay.sofa.jraft.rhea.storage.KVEntry; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +@Slf4j +public class RaftSubscribeDataManager implements IRaftSubscribeDataManager { + + private final Map> dataSubScribeMap = new ConcurrentHashMap<>(); + + private final RaftRegistryProperties properties; + + private final RheaKVStore kvStore; + + public RaftSubscribeDataManager(RaftRegistryProperties properties, RheaKVStore kvStore) { + this.properties = properties; + this.kvStore = kvStore; + } + + private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool( + 1, + new ThreadFactoryBuilder().setNameFormat("SubscribeListenerCheckThread").setDaemon(true).build()); + + public void start() { + scheduledExecutorService.scheduleWithFixedDelay(new SubscribeCheckTask(), + properties.getListenerCheckInterval().toMillis(), + properties.getListenerCheckInterval().toMillis(), + TimeUnit.MILLISECONDS); + } + + @Override + public void addDataSubscribeListener(String path, SubscribeListener listener) { + final List subscribeListeners = + dataSubScribeMap.computeIfAbsent(path, k -> new ArrayList<>()); + subscribeListeners.add(listener); + } + + private class SubscribeCheckTask implements Runnable { + + private final Map oldDataMap = new ConcurrentHashMap<>(); + + @Override + public void run() { + final Map newDataMap = getNodeDataMap(); + if (dataSubScribeMap.isEmpty() || newDataMap.isEmpty()) { + return; + } + // find the different + final Map addedData = new HashMap<>(); + final Map deletedData = new HashMap<>(); + final Map updatedData = new HashMap<>(); + for (Map.Entry entry : newDataMap.entrySet()) { + final String oldData = oldDataMap.get(entry.getKey()); + if (oldData == null) { + addedData.put(entry.getKey(), entry.getValue()); + } else { + if (!oldData.equals(entry.getValue())) { + updatedData.put(entry.getKey(), entry.getValue()); + } + } + } + for (Map.Entry entry : oldDataMap.entrySet()) { + if (!newDataMap.containsKey(entry.getKey())) { + deletedData.put(entry.getKey(), entry.getValue()); + } + } + oldDataMap.clear(); + oldDataMap.putAll(newDataMap); + // trigger listener + triggerListener(addedData, deletedData, updatedData); + } + + private void triggerListener(Map addedData, Map deletedData, + Map updatedData) { + for (Map.Entry> entry : dataSubScribeMap.entrySet()) { + String subscribeKey = entry.getKey(); + final List subscribeListeners = entry.getValue(); + if (!addedData.isEmpty()) { + triggerListener(addedData, subscribeKey, subscribeListeners, Event.Type.ADD); + } + if (!updatedData.isEmpty()) { + triggerListener(updatedData, subscribeKey, subscribeListeners, Event.Type.UPDATE); + } + if (!deletedData.isEmpty()) { + triggerListener(deletedData, subscribeKey, subscribeListeners, Event.Type.REMOVE); + } + } + } + + private Map getNodeDataMap() { + final Map dataMap = new HashMap<>(); + final List entryList = kvStore.bScan(RegistryNodeType.ALL_SERVERS.getRegistryPath(), + RegistryNodeType.ALL_SERVERS.getRegistryPath() + Constants.SINGLE_SLASH + Constants.RAFT_END_KEY); + for (KVEntry kvEntry : entryList) { + final String entryKey = readUtf8(kvEntry.getKey()); + final String entryValue = readUtf8(kvEntry.getValue()); + if (StringUtils.isEmpty(entryValue) + || !entryKey.startsWith(RegistryNodeType.ALL_SERVERS.getRegistryPath())) { + continue; + } + dataMap.put(entryKey, entryValue); + } + return dataMap; + } + + private void triggerListener(Map nodeDataMap, String subscribeKey, + List subscribeListeners, Event.Type type) { + for (Map.Entry entry : nodeDataMap.entrySet()) { + final String key = entry.getKey(); + if (key.startsWith(subscribeKey)) { + subscribeListeners + .forEach(listener -> listener.notify(new Event(key, key, entry.getValue(), type))); + } + } + } + } + + @Override + public void close() { + log.info("closing raft subscribe data manager"); + dataSubScribeMap.clear(); + scheduledExecutorService.shutdown(); + log.info("raft subscribe data manager closed successfully"); + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java new file mode 100644 index 000000000000..365dbdccc17c --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java @@ -0,0 +1,130 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft.client; + +import org.apache.dolphinscheduler.registry.api.ConnectionListener; +import org.apache.dolphinscheduler.registry.api.SubscribeListener; + +import java.util.Collection; + +public interface IRaftRegisterClient extends AutoCloseable { + + /** + * Start the raft registry client. Once started, the client will connect to the raft registry server and then it can be used. + */ + void start(); + + /** + * Check the connectivity of the client. + * + * @return true if the client is connected, false otherwise + */ + boolean isConnectivity(); + + /** + * Subscribe to the raft registry connection state change event. + * + * @param connectionStateListener the listener to handle connection state changes + */ + void subscribeConnectionStateChange(ConnectionListener connectionStateListener); + + /** + * Subscribe to the register data change event. + * + * @param path the path to subscribe to + * @param listener the listener to handle data changes + */ + void subscribeRaftRegistryDataChange(String path, SubscribeListener listener); + + /** + * Get the raft register data by key. + * + * @param key the key of the register data + * @return the value associated with the key + */ + String getRegistryDataByKey(String key); + + /** + * Put the register data to the raft registry server. + *

+ * If the key already exists, then update the value. If the key does not exist, then insert a new key-value pair. + * + * @param key the key of the register data + * @param value the value to be associated with the key + * @param deleteOnDisconnect if true, the data will be deleted when the client disconnects + */ + void putRegistryData(String key, String value, boolean deleteOnDisconnect); + + /** + * Delete the register data by key. + * + * @param key the key of the register data to be deleted + */ + void deleteRegistryDataByKey(String key); + + /** + * List all the children of the given key. + *

+ * e.g. key = "/dolphinscheduler/master", and data exists in db as "/dolphinscheduler/master/master1", "/dolphinscheduler/master/master2" + *

+ * then the return value will be ["master1", "master2"] + * + * @param key the key whose children are to be listed + * @return a collection of children keys + */ + Collection getRegistryDataChildren(String key); + + /** + * Check if the key exists in the raft registry server. + * + * @param key the key to check + * @return true if the key exists, false otherwise + */ + boolean existRaftRegistryDataKey(String key); + + /** + * Acquire the raft registry lock by key. This is a blocking method. If you want to stop the blocking, you can interrupt the thread. + * + * @param lockKey the key of the lock to be acquired + * @return true if the lock was successfully acquired, false otherwise + */ + boolean acquireRaftRegistryLock(String lockKey); + + /** + * Acquire the raft registry lock by key until timeout. + * + * @param lockKey the key of the lock to be acquired + * @param timeout the maximum time to wait for the lock + * @return true if the lock was successfully acquired, false otherwise + */ + boolean acquireRaftRegistryLock(String lockKey, long timeout); + + /** + * Release the raft registry lock by key. If the lockKey does not exist, this method will do nothing. + * + * @param lockKey the key of the lock to be released + * @return true if the lock was successfully released, false otherwise + */ + boolean releaseRaftRegistryLock(String lockKey); + + /** + * Close the raft registry client. Once the client is closed, it cannot work anymore. + */ + @Override + void close(); +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java new file mode 100644 index 000000000000..7db79e76eb20 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java @@ -0,0 +1,206 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft.client; + +import static com.alipay.sofa.jraft.util.BytesUtil.readUtf8; +import static com.alipay.sofa.jraft.util.BytesUtil.writeUtf8; + +import org.apache.dolphinscheduler.common.constants.Constants; +import org.apache.dolphinscheduler.plugin.registry.raft.*; +import org.apache.dolphinscheduler.registry.api.ConnectionListener; +import org.apache.dolphinscheduler.registry.api.ConnectionState; +import org.apache.dolphinscheduler.registry.api.RegistryException; +import org.apache.dolphinscheduler.registry.api.SubscribeListener; +import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import lombok.extern.slf4j.Slf4j; + +import com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore; +import com.alipay.sofa.jraft.rhea.client.RheaKVStore; +import com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions; +import com.alipay.sofa.jraft.rhea.options.RegionRouteTableOptions; +import com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions; +import com.alipay.sofa.jraft.rhea.options.configured.MultiRegionRouteTableOptionsConfigured; +import com.alipay.sofa.jraft.rhea.options.configured.PlacementDriverOptionsConfigured; +import com.alipay.sofa.jraft.rhea.options.configured.RheaKVStoreOptionsConfigured; +import com.alipay.sofa.jraft.rhea.storage.KVEntry; + +@Slf4j +public class RaftRegisterClient implements IRaftRegisterClient { + + private final RheaKVStore rheaKvStore; + private final RaftRegistryProperties raftRegistryProperties; + private final IRaftConnectionStateManager raftConnectionStateManager; + private final IRaftSubscribeDataManager raftSubscribeDataManager; + private final IRaftLockManager raftLockManager; + private volatile boolean started; + private static final String MASTER_MODULE = "master"; + public RaftRegisterClient(RaftRegistryProperties raftRegistryProperties) { + this.raftRegistryProperties = raftRegistryProperties; + this.rheaKvStore = new DefaultRheaKVStore(); + this.raftConnectionStateManager = new RaftConnectionStateManager(raftRegistryProperties); + this.raftSubscribeDataManager = new RaftSubscribeDataManager(raftRegistryProperties, rheaKvStore); + this.raftLockManager = new RaftLockManager(rheaKvStore, raftRegistryProperties); + + initRheakv(); + } + + private void initRheakv() { + final List regionRouteTableOptionsList = MultiRegionRouteTableOptionsConfigured + .newConfigured() + .withInitialServerList(-1L /* default id */, raftRegistryProperties.getServerAddressList()) + .config(); + final PlacementDriverOptions pdOpts = PlacementDriverOptionsConfigured.newConfigured() + .withFake(true) + .withRegionRouteTableOptionsList(regionRouteTableOptionsList) + .config(); + final RheaKVStoreOptions opts = RheaKVStoreOptionsConfigured.newConfigured() // + .withClusterName(raftRegistryProperties.getClusterName()) // + .withPlacementDriverOptions(pdOpts) // + .config(); + this.rheaKvStore.init(opts); + } + + @Override + public void start() { + if (this.started) { + log.info("RaftRegisterClient is already started"); + return; + } + if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) { + raftSubscribeDataManager.start(); + } + raftConnectionStateManager.start(); + this.started = true; + } + + @Override + public boolean isConnectivity() { + return raftConnectionStateManager.getConnectionState() == ConnectionState.CONNECTED; + } + + @Override + public void subscribeConnectionStateChange(ConnectionListener connectionStateListener) { + raftConnectionStateManager.addConnectionListener(connectionStateListener); + } + + @Override + public void subscribeRaftRegistryDataChange(String path, SubscribeListener listener) { + raftSubscribeDataManager.addDataSubscribeListener(path, listener); + } + + @Override + public String getRegistryDataByKey(String key) { + String value = readUtf8(rheaKvStore.bGet(key)); + if (value == null) { + throw new RegistryException("key does not exist"); + } + return value; + } + + @Override + public void putRegistryData(String key, String value, boolean deleteOnDisconnect) { + rheaKvStore.bPut(key, writeUtf8(value)); + } + + @Override + public void deleteRegistryDataByKey(String key) { + rheaKvStore.bDelete(key); + } + + @Override + public Collection getRegistryDataChildren(String key) { + String basePath = null; + if (key.startsWith(RegistryNodeType.MASTER.getRegistryPath())) { + basePath = RegistryNodeType.MASTER.getRegistryPath(); + } else if (key.startsWith(RegistryNodeType.WORKER.getRegistryPath())) { + basePath = RegistryNodeType.WORKER.getRegistryPath(); + } else if (key.startsWith(RegistryNodeType.ALERT_SERVER.getRegistryPath())) { + basePath = RegistryNodeType.ALERT_SERVER.getRegistryPath(); + } else { + throw new UnsupportedOperationException("unsupported get registry data children by key:" + key); + } + List kvEntries = rheaKvStore.bScan(basePath + Constants.SINGLE_SLASH, + basePath + Constants.SINGLE_SLASH + Constants.RAFT_END_KEY); + return getRegisterList(kvEntries); + } + + @Override + public boolean existRaftRegistryDataKey(String key) { + return rheaKvStore.bContainsKey(key); + } + + private Collection getRegisterList(List kvEntries) { + if (kvEntries == null || kvEntries.isEmpty()) { + return new ArrayList<>(); + } + List registerList = new ArrayList<>(); + for (KVEntry kvEntry : kvEntries) { + String entryKey = readUtf8(kvEntry.getKey()); + String childKey = entryKey.substring(entryKey.lastIndexOf(Constants.SINGLE_SLASH) + 1); + registerList.add(childKey); + } + return registerList; + } + + @Override + public boolean acquireRaftRegistryLock(String lockKey) { + try { + return raftLockManager.acquireLock(lockKey); + } catch (Exception ex) { + log.error("acquire raft registry lock error", ex); + raftLockManager.releaseLock(lockKey); + throw new RegistryException("acquire raft register lock error: " + lockKey, ex); + } + } + + @Override + public boolean acquireRaftRegistryLock(String lockKey, long timeout) { + try { + return raftLockManager.acquireLock(lockKey, timeout); + } catch (Exception ex) { + log.error("acquire raft registry lock error", ex); + raftLockManager.releaseLock(lockKey); + throw new RegistryException("acquire raft register lock error: " + lockKey, ex); + } + } + + @Override + public boolean releaseRaftRegistryLock(String lockKey) { + try { + return raftLockManager.releaseLock(lockKey); + } catch (Exception ex) { + log.error("release raft registry lock error", ex); + throw new RegistryException("release raft registry lock error, lockKey:" + lockKey, ex); + } + } + + @Override + public void close() { + log.info("start close raft register client"); + if (rheaKvStore != null) { + rheaKvStore.shutdown(); + } + this.started = false; + log.info("closed raft register client"); + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java new file mode 100644 index 000000000000..bc67d99c796d --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java @@ -0,0 +1,79 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft.server; + +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; + +import lombok.extern.slf4j.Slf4j; + +import com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore; +import com.alipay.sofa.jraft.rhea.client.RheaKVStore; +import com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions; +import com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions; +import com.alipay.sofa.jraft.rhea.options.StoreEngineOptions; +import com.alipay.sofa.jraft.rhea.options.configured.PlacementDriverOptionsConfigured; +import com.alipay.sofa.jraft.rhea.options.configured.RheaKVStoreOptionsConfigured; +import com.alipay.sofa.jraft.rhea.options.configured.StoreEngineOptionsConfigured; +import com.alipay.sofa.jraft.rhea.storage.StorageType; +import com.alipay.sofa.jraft.util.Endpoint; + +@Slf4j +public class RaftRegisterServer { + + private final RheaKVStore rheaKVStore; + private final RheaKVStoreOptions options; + private volatile boolean started; + public RaftRegisterServer(RaftRegistryProperties raftRegistryProperties) { + final PlacementDriverOptions pdOpts = PlacementDriverOptionsConfigured.newConfigured() + .withFake(true) // use a fake pd + .config(); + final StoreEngineOptions storeOpts = StoreEngineOptionsConfigured.newConfigured() + .withStorageType(StorageType.Memory) + .withRaftDataPath(raftRegistryProperties.getLogStorageDir()) + .withServerAddress( + new Endpoint(raftRegistryProperties.getServerAddress(), raftRegistryProperties.getServerPort())) + .config(); + this.options = RheaKVStoreOptionsConfigured.newConfigured() + .withClusterName(raftRegistryProperties.getClusterName()) + .withInitialServerList(raftRegistryProperties.getServerAddressList()) + .withStoreEngineOptions(storeOpts) + .withPlacementDriverOptions(pdOpts) + .config(); + this.rheaKVStore = new DefaultRheaKVStore(); + } + + public void start() { + if (this.started) { + log.info("raft register server is already started"); + return; + } + log.info("starting raft register server..."); + this.rheaKVStore.init(this.options); + log.info("raft register server started successfully"); + this.started = true; + } + + public void stop() { + log.info("stopping raft register server"); + if (this.rheaKVStore != null) { + this.rheaKVStore.shutdown(); + } + this.started = false; + log.info("raft register server stopped successfully"); + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000000..7b0158a982e4 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories @@ -0,0 +1,19 @@ +# +# 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. +# + +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + org.apache.dolphinscheduler.plugin.registry.raft.RaftRegisterAutoConfiguration diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java new file mode 100644 index 000000000000..8c5a1e29890c --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java @@ -0,0 +1,240 @@ +/* + * 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. + */ +package org.apache.dolphinscheduler.plugin.register.raft; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistry; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; +import org.apache.dolphinscheduler.plugin.registry.raft.server.RaftRegisterServer; +import org.apache.dolphinscheduler.registry.api.ConnectionState; +import org.apache.dolphinscheduler.registry.api.Event; +import org.apache.dolphinscheduler.registry.api.RegistryException; +import org.apache.dolphinscheduler.registry.api.SubscribeListener; + +import java.time.Duration; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +import lombok.SneakyThrows; + +import org.assertj.core.util.Lists; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; + +import com.google.common.truth.Truth; + +@SpringBootTest(classes = RaftRegistryProperties.class) +@SpringBootApplication(scanBasePackageClasses = RaftRegistryProperties.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class RaftRegistryTestCase { + + @Autowired + private RaftRegistryProperties raftRegistryProperties; + private static RaftRegisterServer raftRegisterServer; + private static RaftRegistry registry; + + @BeforeAll + public void start() { + if (raftRegisterServer == null && registry == null) { + raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); + registry = new RaftRegistry(raftRegistryProperties); + raftRegisterServer.start(); + registry.start(); + } + } + + @Test + public void testPut() { + String key = "/nodes/master" + System.nanoTime(); + String value = "127.0.0.1:8080"; + registry.put(key, value, true); + Truth.assertThat(registry.get(key)).isEqualTo(value); + + // Update the value + registry.put(key, "123", true); + Truth.assertThat(registry.get(key)).isEqualTo("123"); + } + + @Test + public void testGet() { + String key = "/nodes/master" + System.nanoTime(); + String value = "127.0.0.1:8080"; + assertThrows(RegistryException.class, () -> registry.get(key)); + registry.put(key, value, true); + Truth.assertThat(registry.get(key)).isEqualTo(value); + } + + @Test + public void testIsConnected() throws InterruptedException { + Truth.assertThat(registry.isConnected()).isTrue(); + } + + @Test + public void testConnectUntilTimeout() { + await().atMost(Duration.ofSeconds(10)) + .untilAsserted(() -> registry.connectUntilTimeout(Duration.ofSeconds(3))); + } + + @SneakyThrows + @Test + public void testSubscribe() { + final AtomicBoolean subscribeAdded = new AtomicBoolean(false); + final AtomicBoolean subscribeRemoved = new AtomicBoolean(false); + final AtomicBoolean subscribeUpdated = new AtomicBoolean(false); + + SubscribeListener subscribeListener = event -> { + System.out.println("Receive event: " + event); + if (event.type() == Event.Type.ADD) { + subscribeAdded.compareAndSet(false, true); + } + if (event.type() == Event.Type.REMOVE) { + subscribeRemoved.compareAndSet(false, true); + } + if (event.type() == Event.Type.UPDATE) { + subscribeUpdated.compareAndSet(false, true); + } + }; + + String key = "/nodes/master/"; + registry.subscribe(key, subscribeListener); + registry.put(key, String.valueOf(System.nanoTime()), true); + // If multiple event occurs in a refresh time, only the last event will be triggered + Thread.sleep(3000); + registry.put(key, String.valueOf(System.nanoTime()), true); + Thread.sleep(3000); + registry.delete(key); + + await().atMost(Duration.ofSeconds(10)) + .untilAsserted(() -> { + Assertions.assertTrue(subscribeAdded.get()); + Assertions.assertTrue(subscribeUpdated.get()); + Assertions.assertTrue(subscribeRemoved.get()); + }); + } + + @SneakyThrows + @Test + public void testAddConnectionStateListener() { + AtomicReference connectionState = new AtomicReference<>(); + registry.addConnectionStateListener(connectionState::set); + Truth.assertThat(connectionState.get()).isNull(); + // after initialization, the connection status will change to connected + // await().atMost(Duration.ofSeconds(2)) + // .until(() -> ConnectionState.CONNECTED == connectionState.get()); + } + + @Test + public void testDelete() { + String key = "/nodes/master" + System.nanoTime(); + String value = "127.0.0.1:8080"; + // Delete a non-existent key + registry.delete(key); + + registry.put(key, value, true); + Truth.assertThat(registry.get(key)).isEqualTo(value); + registry.delete(key); + Truth.assertThat(registry.exists(key)).isFalse(); + } + + @Test + public void testChildren() { + String master1 = "/nodes/master/127.0.0.1:8080"; + String master2 = "/nodes/master/127.0.0.2:8080"; + String value = "123"; + registry.put(master1, value, true); + registry.put(master2, value, true); + System.out.println(registry.children("/nodes/master")); + Truth.assertThat(registry.children("/nodes/master")) + .containsAtLeastElementsIn(Lists.newArrayList("127.0.0.1:8080", "127.0.0.2:8080")); + } + + @Test + public void testExists() { + String key = "/nodes/master" + System.nanoTime(); + String value = "123"; + Truth.assertThat(registry.exists(key)).isFalse(); + registry.put(key, value, true); + Truth.assertThat(registry.exists(key)).isTrue(); + } + + @SneakyThrows + @Test + public void testAcquireLock() { + String lockKey = "/lock" + System.nanoTime(); + + // 1. Acquire the lock at the main thread + Truth.assertThat(registry.acquireLock(lockKey)).isTrue(); + // Acquire the lock at the main thread again + // It should acquire success + Truth.assertThat(registry.acquireLock(lockKey)).isTrue(); + + // Acquire the lock at another thread + // It should acquire failed + CompletableFuture acquireResult = CompletableFuture.supplyAsync(() -> registry.acquireLock(lockKey)); + assertThrows(TimeoutException.class, () -> acquireResult.get(3000, TimeUnit.MILLISECONDS)); + } + + @SneakyThrows + @Test + public void testAcquireLock_withTimeout() { + String lockKey = "/lock" + System.nanoTime(); + // 1. Acquire the lock in the main thread + Truth.assertThat(registry.acquireLock(lockKey, 3000)).isTrue(); + + // Acquire the lock in the main thread + // It should acquire success + Truth.assertThat(registry.acquireLock(lockKey, 3000)).isTrue(); + + // Acquire the lock at another thread + // It should acquire failed + CompletableFuture acquireResult = + CompletableFuture.supplyAsync(() -> registry.acquireLock(lockKey, 3000)); + Truth.assertThat(acquireResult.get()).isFalse(); + } + + @SneakyThrows + @Test + public void testReleaseLock() { + String lockKey = "/lock" + System.nanoTime(); + // 1. Acquire the lock in the main thread + Truth.assertThat(registry.acquireLock(lockKey, 3000)).isTrue(); + + // Acquire the lock at another thread + // It should acquire failed + CompletableFuture acquireResult = + CompletableFuture.supplyAsync(() -> registry.acquireLock(lockKey, 3000)); + Truth.assertThat(acquireResult.get()).isFalse(); + + // 2. Release the lock in the main thread + Truth.assertThat(registry.releaseLock(lockKey)).isTrue(); + + // Acquire the lock at another thread + // It should acquire success + acquireResult = CompletableFuture.supplyAsync(() -> registry.acquireLock(lockKey, 3000)); + Truth.assertThat(acquireResult.get()).isTrue(); + } +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml new file mode 100644 index 000000000000..cdfede7702a1 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml @@ -0,0 +1,30 @@ +# +# 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. +# + +registry: + type: raft + module: master + clusterName: dolphinscheduler + serverAddressList: 127.0.0.1:8082 + serverAddress: 127.0.0.1 + serverPort: 8082 + logStorageDir: raft-data/ + distributedLockTimeout: 3s + distributedLockRetryInterval: 3s + listenerCheckInterval: 3s + + diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/pom.xml b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/pom.xml index aa184104d63d..d265a2bc0ad8 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/pom.xml +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/pom.xml @@ -33,5 +33,6 @@ dolphinscheduler-registry-jdbc dolphinscheduler-registry-etcd dolphinscheduler-registry-it + dolphinscheduler-registry-raft From b763e70fdeffd4772cb62f61cd6ebf71bf51cc2d Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 22 Jul 2024 15:57:50 +0800 Subject: [PATCH 2/8] Fix magic numbers and Adjust auto-configuration --- .../dolphinscheduler-registry-raft/README.md | 47 ++++++++++--------- .../raft/RaftConnectionStateManager.java | 4 +- .../plugin/registry/raft/RaftRegistry.java | 3 +- ...ava => RaftRegistryAutoConfiguration.java} | 35 ++++++++++---- .../raft/RaftSubscribeDataManager.java | 5 +- .../main/resources/META-INF/spring.factories | 2 +- .../register/raft/RaftRegistryTestCase.java | 16 +------ 7 files changed, 62 insertions(+), 50 deletions(-) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{RaftRegisterAutoConfiguration.java => RaftRegistryAutoConfiguration.java} (64%) diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md index ddb67f645f1a..2e3f4174a9a3 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md @@ -19,37 +19,38 @@ NOTE: In production environment, in order to achieve high availability, the mast master's properties example ```yaml registry: - type: raft - cluster-name: dolphinscheduler - server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 - server-address: 127.0.0.1 - server-port: 8181 - log-storage-dir: raft-data/ - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s - module: master + type: raft + cluster-name: dolphinscheduler + server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 + server-address: 127.0.0.1 + server-port: 8181 + log-storage-dir: raft-data/ + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: master ``` worker's appplication.yml example ```yaml registry: - type: raft - cluster-name: dolphinscheduler - server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s - module: worker + type: raft + cluster-name: dolphinscheduler + server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: worker ``` api's appplication.yml example ```yaml registry: - type: raft - cluster-name: dolphinscheduler - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s - module: api + type: raft + cluster-name: dolphinscheduler + server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 + listener-check-interval: 3s + distributed-lock-timeout: 3s + distributedLockRetryInterval: 3s + module: api ``` Then you can start your DolphinScheduler cluster, your cluster will use raft cluster as registry center to diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java index e371bc6a3850..c488909ed352 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java @@ -57,7 +57,7 @@ public RaftConnectionStateManager(RaftRegistryProperties properties) { 1, new ThreadFactoryBuilder().setNameFormat("ConnectionStateRefreshThread").setDaemon(true).build()); } - + @Override public void start() { cliClientService.init(cliOptions); scheduledExecutorService.scheduleWithFixedDelay( @@ -66,7 +66,7 @@ public void start() { CONNECT_STATE_CHECK_INTERVENE.toMillis(), TimeUnit.MILLISECONDS); } - + @Override public void addConnectionListener(ConnectionListener listener) { connectionListeners.add(listener); } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java index 7c00e6c69614..c4700b45b935 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java @@ -36,6 +36,7 @@ @Slf4j public class RaftRegistry implements Registry { + private static final long RECONNECT_WAIT_TIME_MS = 50L; private final IRaftRegisterClient raftRegisterClient; public RaftRegistry(RaftRegistryProperties raftRegistryProperties) { this.raftRegisterClient = new RaftRegisterClient(raftRegistryProperties); @@ -64,7 +65,7 @@ public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryExcept return; } } - ThreadUtils.sleep(50); + ThreadUtils.sleep(RECONNECT_WAIT_TIME_MS); } catch (Exception ex) { throw new RegistryException("connect to raft cluster timeout", ex); } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java similarity index 64% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java index 91ff0f0927b7..9051aef9387b 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegisterAutoConfiguration.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java @@ -25,29 +25,48 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; @Slf4j @Configuration(proxyBeanMethods = false) @ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft") @EnableConfigurationProperties(RaftRegistryProperties.class) -public class RaftRegisterAutoConfiguration { +public class RaftRegistryAutoConfiguration { - public RaftRegisterAutoConfiguration() { + public RaftRegistryAutoConfiguration() { log.info("Load RaftRegisterAutoConfiguration"); } @Bean - public RaftRegistry raftRegistry(RaftRegistryProperties raftRegistryProperties) { + @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") + public RaftRegisterServer raftRegisterServer(RaftRegistryProperties raftRegistryProperties) { + RaftRegisterServer raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); + raftRegisterServer.start(); + return raftRegisterServer; + } + + @Bean + @DependsOn("raftRegisterServer") + @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") + public RaftRegistry masterRegisterClient(RaftRegistryProperties raftRegistryProperties) { RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); raftRegistry.start(); return raftRegistry; } @Bean - @ConditionalOnProperty(prefix = "register", name = "module", havingValue = "master") - public RaftRegisterServer raftRegisterServer(RaftRegistryProperties raftRegistryProperties) { - RaftRegisterServer raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); - raftRegisterServer.start(); - return raftRegisterServer; + @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "worker") + public RaftRegistry workerRegisterClient(RaftRegistryProperties raftRegistryProperties) { + RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); + raftRegistry.start(); + return raftRegistry; + } + + @Bean + @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "api") + public RaftRegistry apiRegisterClient(RaftRegistryProperties raftRegistryProperties) { + RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); + raftRegistry.start(); + return raftRegistry; } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java index c5f51f0c2b5b..8b4cfab6adab 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java @@ -43,6 +43,8 @@ @Slf4j public class RaftSubscribeDataManager implements IRaftSubscribeDataManager { + private static final int SUBSCRIBE_LISTENER_THREAD_POOL_SIZE = 1; + private final Map> dataSubScribeMap = new ConcurrentHashMap<>(); private final RaftRegistryProperties properties; @@ -55,9 +57,10 @@ public RaftSubscribeDataManager(RaftRegistryProperties properties, RheaKVStore k } private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool( - 1, + SUBSCRIBE_LISTENER_THREAD_POOL_SIZE, new ThreadFactoryBuilder().setNameFormat("SubscribeListenerCheckThread").setDaemon(true).build()); + @Override public void start() { scheduledExecutorService.scheduleWithFixedDelay(new SubscribeCheckTask(), properties.getListenerCheckInterval().toMillis(), diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories index 7b0158a982e4..cd245597ae71 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/resources/META-INF/spring.factories @@ -16,4 +16,4 @@ # org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.dolphinscheduler.plugin.registry.raft.RaftRegisterAutoConfiguration + org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryAutoConfiguration diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java index 8c5a1e29890c..1b478f5fb7d3 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java @@ -38,7 +38,6 @@ import org.assertj.core.util.Lists; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; @@ -53,19 +52,8 @@ public class RaftRegistryTestCase { @Autowired - private RaftRegistryProperties raftRegistryProperties; - private static RaftRegisterServer raftRegisterServer; - private static RaftRegistry registry; - - @BeforeAll - public void start() { - if (raftRegisterServer == null && registry == null) { - raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); - registry = new RaftRegistry(raftRegistryProperties); - raftRegisterServer.start(); - registry.start(); - } - } + private RaftRegistry registry; + @Test public void testPut() { From a33a5ce54d49b72fcd8a6128ee164127e6885684 Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 23 Jul 2024 20:52:32 +0800 Subject: [PATCH 3/8] Fix magic numbers --- .../dolphinscheduler-registry-raft/README.md | 6 ++-- .../raft/RaftConnectionStateManager.java | 16 ++++----- .../plugin/registry/raft/RaftLockManager.java | 26 ++++----------- .../registry/raft/RaftRegistryProperties.java | 7 ++++ .../raft/RaftSubscribeDataManager.java | 11 +++---- .../raft/client/RaftRegisterClient.java | 8 ++++- .../registry/raft/model/RaftLockEntry.java | 33 +++++++++++++++++++ .../register/raft/RaftRegistryTestCase.java | 2 -- 8 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/RaftLockEntry.java diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md index 2e3f4174a9a3..6d057ae3e75d 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md @@ -27,7 +27,7 @@ registry: log-storage-dir: raft-data/ listener-check-interval: 3s distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s + distributed-lock-retry-interval: 3s module: master ``` worker's appplication.yml example @@ -38,7 +38,7 @@ registry: server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 listener-check-interval: 3s distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s + distributed-lock-retry-interval: 3s module: worker ``` api's appplication.yml example @@ -49,7 +49,7 @@ registry: server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 listener-check-interval: 3s distributed-lock-timeout: 3s - distributedLockRetryInterval: 3s + distributed-lock-retry-interval: 3s module: api ``` diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java index c488909ed352..1137880926e9 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java @@ -20,7 +20,6 @@ import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; -import java.time.Duration; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executors; @@ -40,7 +39,6 @@ public class RaftConnectionStateManager implements IRaftConnectionStateManager { private static final String DEFAULT_REGION_ID = "--1"; private ConnectionState currentConnectionState; - private static final Duration CONNECT_STATE_CHECK_INTERVENE = Duration.ofSeconds(2); private final RaftRegistryProperties properties; private final List connectionListeners = new CopyOnWriteArrayList<>(); private final ScheduledExecutorService scheduledExecutorService; @@ -50,11 +48,11 @@ public class RaftConnectionStateManager implements IRaftConnectionStateManager { public RaftConnectionStateManager(RaftRegistryProperties properties) { this.properties = properties; this.cliOptions = new CliOptions(); - this.cliOptions.setMaxRetry(3); - this.cliOptions.setTimeoutMs(5000); + this.cliOptions.setMaxRetry(properties.getCliMaxRetries()); + this.cliOptions.setTimeoutMs((int) properties.getCliTimeout().toMillis()); this.cliClientService = new CliClientServiceImpl(); this.scheduledExecutorService = Executors.newScheduledThreadPool( - 1, + properties.getConnectionListenerThreadPoolSize(), new ThreadFactoryBuilder().setNameFormat("ConnectionStateRefreshThread").setDaemon(true).build()); } @Override @@ -62,8 +60,8 @@ public void start() { cliClientService.init(cliOptions); scheduledExecutorService.scheduleWithFixedDelay( new ConnectionStateRefreshTask(connectionListeners), - CONNECT_STATE_CHECK_INTERVENE.toMillis(), - CONNECT_STATE_CHECK_INTERVENE.toMillis(), + properties.getConnectStateCheckInterval().toMillis(), + properties.getConnectStateCheckInterval().toMillis(), TimeUnit.MILLISECONDS); } @Override @@ -113,7 +111,9 @@ public void run() { private ConnectionState getCurrentConnectionState() { try { String groupId = properties.getClusterName() + DEFAULT_REGION_ID; - if (RouteTable.getInstance().refreshLeader(cliClientService, groupId, 2000).isOk()) { + if (RouteTable.getInstance() + .refreshLeader(cliClientService, groupId, (int) properties.getRefreshLeaderTimeout().toMillis()) + .isOk()) { return ConnectionState.CONNECTED; } else { return ConnectionState.DISCONNECTED; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java index 1f7715318d0a..8cafdf71337e 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java @@ -20,6 +20,7 @@ import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; +import org.apache.dolphinscheduler.plugin.registry.raft.model.RaftLockEntry; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -27,18 +28,13 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import com.alipay.sofa.jraft.rhea.client.RheaKVStore; import com.alipay.sofa.jraft.rhea.util.concurrent.DistributedLock; import com.alipay.sofa.jraft.util.ExecutorServiceHelper; public class RaftLockManager implements IRaftLockManager { - private final Map distributedLockMap = new ConcurrentHashMap<>(); + private final Map distributedLockMap = new ConcurrentHashMap<>(); private final RheaKVStore rheaKvStore; private final RaftRegistryProperties raftRegistryProperties; private static final ScheduledExecutorService WATCH_DOG = Executors.newSingleThreadScheduledExecutor(); @@ -61,7 +57,7 @@ public boolean acquireLock(String lockKey) { while (true) { if (distributedLock.tryLock()) { - distributedLockMap.put(lockKey, LockEntry.builder().distributedLock(distributedLock) + distributedLockMap.put(lockKey, RaftLockEntry.builder().distributedLock(distributedLock) .lockOwner(lockOwner) .build()); return true; @@ -84,7 +80,7 @@ public boolean acquireLock(String lockKey, long timeout) { while (System.currentTimeMillis() < endTime) { if (distributedLock.tryLock()) { - distributedLockMap.put(lockKey, LockEntry.builder().distributedLock(distributedLock) + distributedLockMap.put(lockKey, RaftLockEntry.builder().distributedLock(distributedLock) .lockOwner(lockOwner) .build()); return true; @@ -98,14 +94,14 @@ public boolean acquireLock(String lockKey, long timeout) { } private boolean isThreadReentrant(String lockKey, String lockOwner) { - final LockEntry lockEntry = distributedLockMap.get(lockKey); + final RaftLockEntry lockEntry = distributedLockMap.get(lockKey); return lockEntry != null && lockOwner.equals(lockEntry.getLockOwner()); } @Override public boolean releaseLock(String lockKey) { final String lockOwner = getLockOwnerPrefix(); - final LockEntry lockEntry = distributedLockMap.get(lockKey); + final RaftLockEntry lockEntry = distributedLockMap.get(lockKey); if (lockEntry == null || !lockOwner.equals(lockEntry.getLockOwner())) { return false; } @@ -122,16 +118,6 @@ public static String getLockOwnerPrefix() { return LOCK_OWNER_PREFIX + Thread.currentThread().getName(); } - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class LockEntry { - - private DistributedLock distributedLock; - private String lockOwner; - } - @Override public void close() throws Exception { ExecutorServiceHelper.shutdownAndAwaitTermination(WATCH_DOG); diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java index f16a6694db54..9a463d646784 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java @@ -40,4 +40,11 @@ public class RaftRegistryProperties { private Duration distributedLockRetryInterval = Duration.ofSeconds(5); private String module = "master"; private Duration listenerCheckInterval = Duration.ofSeconds(3); + private int cliMaxRetries = 3; + private Duration cliTimeout = Duration.ofSeconds(5); + private Duration refreshLeaderTimeout = Duration.ofSeconds(2); + private Duration connectStateCheckInterval = Duration.ofSeconds(2); + private int subscribeListenerThreadPoolSize = 1; + private int connectionListenerThreadPoolSize = 1; + } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java index 8b4cfab6adab..b02d0db13cef 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java @@ -43,23 +43,22 @@ @Slf4j public class RaftSubscribeDataManager implements IRaftSubscribeDataManager { - private static final int SUBSCRIBE_LISTENER_THREAD_POOL_SIZE = 1; - private final Map> dataSubScribeMap = new ConcurrentHashMap<>(); private final RaftRegistryProperties properties; private final RheaKVStore kvStore; + private final ScheduledExecutorService scheduledExecutorService; + public RaftSubscribeDataManager(RaftRegistryProperties properties, RheaKVStore kvStore) { this.properties = properties; this.kvStore = kvStore; + this.scheduledExecutorService = Executors.newScheduledThreadPool( + properties.getSubscribeListenerThreadPoolSize(), + new ThreadFactoryBuilder().setNameFormat("SubscribeListenerCheckThread").setDaemon(true).build()); } - private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool( - SUBSCRIBE_LISTENER_THREAD_POOL_SIZE, - new ThreadFactoryBuilder().setNameFormat("SubscribeListenerCheckThread").setDaemon(true).build()); - @Override public void start() { scheduledExecutorService.scheduleWithFixedDelay(new SubscribeCheckTask(), diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java index 7db79e76eb20..b59e41445812 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java @@ -21,7 +21,13 @@ import static com.alipay.sofa.jraft.util.BytesUtil.writeUtf8; import org.apache.dolphinscheduler.common.constants.Constants; -import org.apache.dolphinscheduler.plugin.registry.raft.*; +import org.apache.dolphinscheduler.plugin.registry.raft.IRaftConnectionStateManager; +import org.apache.dolphinscheduler.plugin.registry.raft.IRaftLockManager; +import org.apache.dolphinscheduler.plugin.registry.raft.IRaftSubscribeDataManager; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftConnectionStateManager; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftLockManager; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftSubscribeDataManager; import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; import org.apache.dolphinscheduler.registry.api.RegistryException; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/RaftLockEntry.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/RaftLockEntry.java new file mode 100644 index 000000000000..3d22be56c270 --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/RaftLockEntry.java @@ -0,0 +1,33 @@ +/* + * 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. + */ +package org.apache.dolphinscheduler.plugin.registry.raft.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import com.alipay.sofa.jraft.rhea.util.concurrent.DistributedLock; +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RaftLockEntry { + + private DistributedLock distributedLock; + private String lockOwner; +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java index 1b478f5fb7d3..6dfe7c721272 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistry; import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; -import org.apache.dolphinscheduler.plugin.registry.raft.server.RaftRegisterServer; import org.apache.dolphinscheduler.registry.api.ConnectionState; import org.apache.dolphinscheduler.registry.api.Event; import org.apache.dolphinscheduler.registry.api.RegistryException; @@ -54,7 +53,6 @@ public class RaftRegistryTestCase { @Autowired private RaftRegistry registry; - @Test public void testPut() { String key = "/nodes/master" + System.nanoTime(); From 8c73f9912465f3f5f5ebaa0918614cc67a59db5c Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 30 Jul 2024 08:12:30 +0800 Subject: [PATCH 4/8] Add logic to remove ephemeral nodes upon disconnection --- .../registry/raft/RaftRegistryProperties.java | 1 + .../raft/client/RaftRegisterClient.java | 29 +++-- .../IRaftConnectionStateManager.java | 2 +- .../raft/{ => manage}/IRaftLockManager.java | 2 +- .../IRaftSubscribeDataManager.java | 2 +- .../RaftConnectionStateManager.java | 3 +- .../raft/{ => manage}/RaftLockManager.java | 3 +- .../RaftSubscribeDataManager.java | 109 +++++++++++++----- .../plugin/registry/raft/model/NodeItem.java | 33 ++++++ .../plugin/registry/raft/model/NodeType.java | 30 +++++ .../register/raft/RaftRegistryTestCase.java | 76 +++++++++++- 11 files changed, 238 insertions(+), 52 deletions(-) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/IRaftConnectionStateManager.java (96%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/IRaftLockManager.java (96%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/IRaftSubscribeDataManager.java (95%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/RaftConnectionStateManager.java (97%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/RaftLockManager.java (97%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/{ => manage}/RaftSubscribeDataManager.java (57%) create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeItem.java create mode 100644 dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeType.java diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java index 9a463d646784..7a878fd60763 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java @@ -44,6 +44,7 @@ public class RaftRegistryProperties { private Duration cliTimeout = Duration.ofSeconds(5); private Duration refreshLeaderTimeout = Duration.ofSeconds(2); private Duration connectStateCheckInterval = Duration.ofSeconds(2); + private Duration heartBeatTimeOut = Duration.ofSeconds(20); private int subscribeListenerThreadPoolSize = 1; private int connectionListenerThreadPoolSize = 1; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java index b59e41445812..7a0d6755b2a5 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java @@ -21,13 +21,14 @@ import static com.alipay.sofa.jraft.util.BytesUtil.writeUtf8; import org.apache.dolphinscheduler.common.constants.Constants; -import org.apache.dolphinscheduler.plugin.registry.raft.IRaftConnectionStateManager; -import org.apache.dolphinscheduler.plugin.registry.raft.IRaftLockManager; -import org.apache.dolphinscheduler.plugin.registry.raft.IRaftSubscribeDataManager; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftConnectionStateManager; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftLockManager; import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftSubscribeDataManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.IRaftConnectionStateManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.IRaftLockManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.IRaftSubscribeDataManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.RaftConnectionStateManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.RaftLockManager; +import org.apache.dolphinscheduler.plugin.registry.raft.manage.RaftSubscribeDataManager; +import org.apache.dolphinscheduler.plugin.registry.raft.model.NodeType; import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; import org.apache.dolphinscheduler.registry.api.RegistryException; @@ -116,16 +117,22 @@ public void subscribeRaftRegistryDataChange(String path, SubscribeListener liste @Override public String getRegistryDataByKey(String key) { - String value = readUtf8(rheaKvStore.bGet(key)); - if (value == null) { - throw new RegistryException("key does not exist"); + String compositeValue = readUtf8(rheaKvStore.bGet(key)); + if (compositeValue == null) { + throw new RegistryException("key does not exist:" + key); } - return value; + String[] nodeTypeAndValue = compositeValue.split(Constants.AT_SIGN); + if (nodeTypeAndValue.length != 2) { + throw new RegistryException("value format is incorrect for key: " + key + ", value: " + compositeValue); + } + return nodeTypeAndValue[1]; } @Override public void putRegistryData(String key, String value, boolean deleteOnDisconnect) { - rheaKvStore.bPut(key, writeUtf8(value)); + NodeType nodeType = deleteOnDisconnect ? NodeType.EPHEMERAL : NodeType.PERSISTENT; + String compositeValue = nodeType.getName() + Constants.AT_SIGN + value; + rheaKvStore.bPut(key, writeUtf8(compositeValue)); } @Override diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftConnectionStateManager.java similarity index 96% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftConnectionStateManager.java index 1851896e351b..f5c737b21231 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftConnectionStateManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftConnectionStateManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftLockManager.java similarity index 96% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftLockManager.java index e904dc4b0439..edd264dcc68f 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftLockManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftLockManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; /** * Interface for managing locks in a raft registry client. diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftSubscribeDataManager.java similarity index 95% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftSubscribeDataManager.java index f8ab846a72c3..21f18110c1a8 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/IRaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/IRaftSubscribeDataManager.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; import org.apache.dolphinscheduler.registry.api.SubscribeListener; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java similarity index 97% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java index 1137880926e9..54c2b8fdc101 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java @@ -15,8 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java similarity index 97% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java index 8cafdf71337e..7eee5c7263a2 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.plugin.registry.raft.model.RaftLockEntry; import java.util.Map; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java similarity index 57% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java index b02d0db13cef..2c5ce5f1429e 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java @@ -15,11 +15,16 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.registry.raft; +package org.apache.dolphinscheduler.plugin.registry.raft.manage; import static com.alipay.sofa.jraft.util.BytesUtil.readUtf8; import org.apache.dolphinscheduler.common.constants.Constants; +import org.apache.dolphinscheduler.common.model.BaseHeartBeat; +import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; +import org.apache.dolphinscheduler.plugin.registry.raft.model.NodeItem; +import org.apache.dolphinscheduler.plugin.registry.raft.model.NodeType; import org.apache.dolphinscheduler.registry.api.Event; import org.apache.dolphinscheduler.registry.api.SubscribeListener; import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType; @@ -76,37 +81,60 @@ public void addDataSubscribeListener(String path, SubscribeListener listener) { private class SubscribeCheckTask implements Runnable { - private final Map oldDataMap = new ConcurrentHashMap<>(); + private final Map oldDataMap = new ConcurrentHashMap<>(); @Override public void run() { - final Map newDataMap = getNodeDataMap(); - if (dataSubScribeMap.isEmpty() || newDataMap.isEmpty()) { - return; - } - // find the different - final Map addedData = new HashMap<>(); - final Map deletedData = new HashMap<>(); - final Map updatedData = new HashMap<>(); - for (Map.Entry entry : newDataMap.entrySet()) { - final String oldData = oldDataMap.get(entry.getKey()); - if (oldData == null) { - addedData.put(entry.getKey(), entry.getValue()); - } else { - if (!oldData.equals(entry.getValue())) { - updatedData.put(entry.getKey(), entry.getValue()); + try { + final Map newDataMap = getNodeDataMap(); + if (dataSubScribeMap.isEmpty() || newDataMap.isEmpty()) { + return; + } + // find the different + final Map addedData = new HashMap<>(); + final Map deletedData = new HashMap<>(); + final Map updatedData = new HashMap<>(); + for (Map.Entry entry : newDataMap.entrySet()) { + final NodeItem oldData = oldDataMap.get(entry.getKey()); + if (oldData == null) { + addedData.put(entry.getKey(), entry.getValue().getNodeValue()); + } else if (NodeType.EPHEMERAL.getName().equals(entry.getValue().getNodeType()) + && isUnHealthy(entry.getValue().getNodeValue())) { + kvStore.bDelete(entry.getKey()); + newDataMap.remove(entry.getKey(), entry.getValue()); + } else if (!oldData.getNodeValue().equals(entry.getValue().getNodeValue())) { + updatedData.put(entry.getKey(), entry.getValue().getNodeValue()); + } + } + for (Map.Entry entry : oldDataMap.entrySet()) { + if (!newDataMap.containsKey(entry.getKey())) { + deletedData.put(entry.getKey(), entry.getValue().getNodeValue()); } } + oldDataMap.clear(); + oldDataMap.putAll(newDataMap); + // trigger listener + triggerListener(addedData, deletedData, updatedData); + } catch (Exception ex) { + log.error("Error in SubscribeCheckTask run method", ex); } - for (Map.Entry entry : oldDataMap.entrySet()) { - if (!newDataMap.containsKey(entry.getKey())) { - deletedData.put(entry.getKey(), entry.getValue()); + } + + private boolean isUnHealthy(String heartBeat) { + try { + // consider this not a valid heartbeat instance, do not check + if (heartBeat == null || !heartBeat.contains("reportTime")) { + return false; } + BaseHeartBeat baseHeartBeat = JSONUtils.parseObject(heartBeat, BaseHeartBeat.class); + if (baseHeartBeat != null) { + return System.currentTimeMillis() - baseHeartBeat.getReportTime() > properties.getHeartBeatTimeOut() + .toMillis(); + } + } catch (Exception ex) { + log.error("Fail to parse heartBeat : {}", heartBeat, ex); } - oldDataMap.clear(); - oldDataMap.putAll(newDataMap); - // trigger listener - triggerListener(addedData, deletedData, updatedData); + return false; } private void triggerListener(Map addedData, Map deletedData, @@ -126,20 +154,41 @@ private void triggerListener(Map addedData, Map } } - private Map getNodeDataMap() { - final Map dataMap = new HashMap<>(); + private Map getNodeDataMap() { + final Map nodeItemMap = new HashMap<>(); final List entryList = kvStore.bScan(RegistryNodeType.ALL_SERVERS.getRegistryPath(), RegistryNodeType.ALL_SERVERS.getRegistryPath() + Constants.SINGLE_SLASH + Constants.RAFT_END_KEY); + for (KVEntry kvEntry : entryList) { final String entryKey = readUtf8(kvEntry.getKey()); - final String entryValue = readUtf8(kvEntry.getValue()); - if (StringUtils.isEmpty(entryValue) + final String compositeValue = readUtf8(kvEntry.getValue()); + + if (StringUtils.isEmpty(compositeValue) || !entryKey.startsWith(RegistryNodeType.ALL_SERVERS.getRegistryPath())) { continue; } - dataMap.put(entryKey, entryValue); + + String[] nodeTypeAndValue = parseCompositeValue(compositeValue); + if (nodeTypeAndValue.length < 2) { + continue; + } + String nodeType = nodeTypeAndValue[0]; + String nodeValue = nodeTypeAndValue[1]; + + nodeItemMap.put(entryKey, NodeItem.builder().nodeValue(nodeValue).nodeType(nodeType).build()); + } + return nodeItemMap; + } + + private String[] parseCompositeValue(String compositeValue) { + String[] nodeTypeAndValue = compositeValue.split(Constants.AT_SIGN); + if (nodeTypeAndValue.length < 2) { + log.error("Invalid compositeValue: {}", compositeValue); + return new String[]{}; } - return dataMap; + String nodeType = nodeTypeAndValue[0]; + String nodeValue = nodeTypeAndValue[1]; + return new String[]{nodeType, nodeValue}; } private void triggerListener(Map nodeDataMap, String subscribeKey, diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeItem.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeItem.java new file mode 100644 index 000000000000..bc0ecf4eba3a --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeItem.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class NodeItem { + + private String nodeType; + private String nodeValue; +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeType.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeType.java new file mode 100644 index 000000000000..89074579d36f --- /dev/null +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/model/NodeType.java @@ -0,0 +1,30 @@ +/* + * 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. + */ + +package org.apache.dolphinscheduler.plugin.registry.raft.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum NodeType { + + EPHEMERAL("ephemeralNode"), + PERSISTENT("persistentNode"); + private final String name; +} diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java index 6dfe7c721272..df284c74d2d5 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java @@ -19,6 +19,8 @@ import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertThrows; +import org.apache.dolphinscheduler.common.model.BaseHeartBeat; +import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistry; import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.registry.api.ConnectionState; @@ -87,7 +89,7 @@ public void testConnectUntilTimeout() { @SneakyThrows @Test - public void testSubscribe() { + public void testEphemeralNodeSubscribe() { final AtomicBoolean subscribeAdded = new AtomicBoolean(false); final AtomicBoolean subscribeRemoved = new AtomicBoolean(false); final AtomicBoolean subscribeUpdated = new AtomicBoolean(false); @@ -106,13 +108,19 @@ public void testSubscribe() { }; String key = "/nodes/master/"; + BaseHeartBeat baseHeartBeat = BaseHeartBeat.builder().reportTime(System.currentTimeMillis()) + .host("127.0.0.1:8081") + .build(); + registry.subscribe(key, subscribeListener); - registry.put(key, String.valueOf(System.nanoTime()), true); - // If multiple event occurs in a refresh time, only the last event will be triggered - Thread.sleep(3000); - registry.put(key, String.valueOf(System.nanoTime()), true); + registry.put(key, JSONUtils.toJsonString(baseHeartBeat), true); + Thread.sleep(3000); - registry.delete(key); + BaseHeartBeat newBaseHeartBeat = BaseHeartBeat.builder().reportTime(System.currentTimeMillis()) + .host("127.0.0.1:8081") + .build(); + registry.put(key, JSONUtils.toJsonString(newBaseHeartBeat), true); + Thread.sleep(20000); await().atMost(Duration.ofSeconds(10)) .untilAsserted(() -> { @@ -120,6 +128,62 @@ public void testSubscribe() { Assertions.assertTrue(subscribeUpdated.get()); Assertions.assertTrue(subscribeRemoved.get()); }); + + // verify that the temporary node data has been removed + try { + String currentData = registry.get(key); + } catch (RegistryException ex) { + Assertions.assertEquals("key does not exist:" + key, ex.getMessage(), + "Unexpected registry exception message"); + } + } + + @SneakyThrows + @Test + public void testPersistentNodeSubscribe() { + final AtomicBoolean subscribeAdded = new AtomicBoolean(false); + final AtomicBoolean subscribeRemoved = new AtomicBoolean(false); + final AtomicBoolean subscribeUpdated = new AtomicBoolean(false); + + SubscribeListener subscribeListener = event -> { + System.out.println("Receive event: " + event); + if (event.type() == Event.Type.ADD) { + subscribeAdded.compareAndSet(false, true); + } + if (event.type() == Event.Type.REMOVE) { + subscribeRemoved.compareAndSet(false, true); + } + if (event.type() == Event.Type.UPDATE) { + subscribeUpdated.compareAndSet(false, true); + } + }; + + String key = "/nodes/master/"; + BaseHeartBeat baseHeartBeat = BaseHeartBeat.builder().reportTime(System.currentTimeMillis()) + .host("127.0.0.1:8081") + .build(); + + registry.subscribe(key, subscribeListener); + registry.put(key, JSONUtils.toJsonString(baseHeartBeat), false); + + Thread.sleep(3000); + BaseHeartBeat newBaseHeartBeat = BaseHeartBeat.builder().reportTime(System.currentTimeMillis()) + .host("127.0.0.1:8081") + .build(); + registry.put(key, JSONUtils.toJsonString(newBaseHeartBeat), false); + Thread.sleep(20000); + + await().atMost(Duration.ofSeconds(10)) + .untilAsserted(() -> { + Assertions.assertTrue(subscribeAdded.get()); + Assertions.assertTrue(subscribeUpdated.get()); + Assertions.assertFalse(subscribeRemoved.get()); + }); + + String currentData = registry.get(key); + Assertions.assertNotNull(currentData, "Node data was unexpectedly removed"); + Assertions.assertEquals(JSONUtils.toJsonString(newBaseHeartBeat), currentData, + "Node data does not match the expected value"); } @SneakyThrows From eab6457e7cc2294382f274e80a3958fa4db3f36d Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 19 Aug 2024 11:21:39 +0800 Subject: [PATCH 5/8] =?UTF-8?q?Fix=20the=20abnormal=20startup=20of=20the?= =?UTF-8?q?=20raft=20cluster=EF=BC=88#10874=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../registry/api/RegistryClient.java | 26 +++++--- .../plugin/registry/raft/RaftRegistry.java | 40 +++++------- .../raft/RaftRegistryAutoConfiguration.java | 20 +++--- ...erClient.java => IRaftRegistryClient.java} | 2 +- ...terClient.java => RaftRegistryClient.java} | 26 ++++---- .../raft/manage/RaftSubscribeDataManager.java | 65 +++++++++---------- ...terServer.java => RaftRegistryServer.java} | 14 ++-- .../raft/RaftRegistryTestCase.java | 4 +- 8 files changed, 101 insertions(+), 96 deletions(-) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/{IRaftRegisterClient.java => IRaftRegistryClient.java} (98%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/{RaftRegisterClient.java => RaftRegistryClient.java} (91%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/{RaftRegisterServer.java => RaftRegistryServer.java} (88%) rename dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/{register => registry}/raft/RaftRegistryTestCase.java (98%) diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/RegistryClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/RegistryClient.java index 987c75b588b5..5f217cfc96f1 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/RegistryClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/RegistryClient.java @@ -44,6 +44,8 @@ import java.util.Optional; import java.util.Set; +import javax.annotation.PostConstruct; + import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @@ -62,14 +64,22 @@ public class RegistryClient { public RegistryClient(Registry registry) { this.registry = registry; - if (!registry.exists(RegistryNodeType.MASTER.getRegistryPath())) { - registry.put(RegistryNodeType.MASTER.getRegistryPath(), EMPTY, false); - } - if (!registry.exists(RegistryNodeType.WORKER.getRegistryPath())) { - registry.put(RegistryNodeType.WORKER.getRegistryPath(), EMPTY, false); - } - if (!registry.exists(RegistryNodeType.ALERT_SERVER.getRegistryPath())) { - registry.put(RegistryNodeType.ALERT_SERVER.getRegistryPath(), EMPTY, false); + } + + @PostConstruct + public void initializeRegistryPaths() { + try { + if (!registry.exists(RegistryNodeType.MASTER.getRegistryPath())) { + registry.put(RegistryNodeType.MASTER.getRegistryPath(), EMPTY, false); + } + if (!registry.exists(RegistryNodeType.WORKER.getRegistryPath())) { + registry.put(RegistryNodeType.WORKER.getRegistryPath(), EMPTY, false); + } + if (!registry.exists(RegistryNodeType.ALERT_SERVER.getRegistryPath())) { + registry.put(RegistryNodeType.ALERT_SERVER.getRegistryPath(), EMPTY, false); + } + } catch (Exception e) { + log.error("Failed to initialize registry paths", e); } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java index c4700b45b935..f416cacaf00c 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java @@ -20,8 +20,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import org.apache.dolphinscheduler.common.thread.ThreadUtils; -import org.apache.dolphinscheduler.plugin.registry.raft.client.IRaftRegisterClient; -import org.apache.dolphinscheduler.plugin.registry.raft.client.RaftRegisterClient; +import org.apache.dolphinscheduler.plugin.registry.raft.client.IRaftRegistryClient; +import org.apache.dolphinscheduler.plugin.registry.raft.client.RaftRegistryClient; import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.Registry; import org.apache.dolphinscheduler.registry.api.RegistryException; @@ -37,21 +37,19 @@ public class RaftRegistry implements Registry { private static final long RECONNECT_WAIT_TIME_MS = 50L; - private final IRaftRegisterClient raftRegisterClient; + private final IRaftRegistryClient raftRegistryClient; public RaftRegistry(RaftRegistryProperties raftRegistryProperties) { - this.raftRegisterClient = new RaftRegisterClient(raftRegistryProperties); + this.raftRegistryClient = new RaftRegistryClient(raftRegistryProperties); } @Override public void start() { - log.info("starting raft registry..."); - raftRegisterClient.start(); - log.info("raft registry started successfully"); + raftRegistryClient.start(); } @Override public boolean isConnected() { - return raftRegisterClient.isConnectivity(); + return raftRegistryClient.isConnectivity(); } @Override @@ -61,7 +59,7 @@ public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryExcept long endTimeMillis = timeout.toMillis() > 0 ? startTimeMillis + timeout.toMillis() : Long.MAX_VALUE; while (System.currentTimeMillis() < endTimeMillis) { - if (raftRegisterClient.isConnectivity()) { + if (raftRegistryClient.isConnectivity()) { return; } } @@ -75,68 +73,66 @@ public void connectUntilTimeout(@NonNull Duration timeout) throws RegistryExcept public void subscribe(String path, SubscribeListener listener) { checkNotNull(path); checkNotNull(listener); - raftRegisterClient.subscribeRaftRegistryDataChange(path, listener); + raftRegistryClient.subscribeRaftRegistryDataChange(path, listener); } @Override public void addConnectionStateListener(ConnectionListener listener) { checkNotNull(listener); - raftRegisterClient.subscribeConnectionStateChange(listener); + raftRegistryClient.subscribeConnectionStateChange(listener); } @Override public String get(String key) { checkNotNull(key); - return raftRegisterClient.getRegistryDataByKey(key); + return raftRegistryClient.getRegistryDataByKey(key); } @Override public void put(String key, String value, boolean deleteOnDisconnect) { checkNotNull(key); - raftRegisterClient.putRegistryData(key, value, deleteOnDisconnect); + raftRegistryClient.putRegistryData(key, value, deleteOnDisconnect); } @Override public void delete(String key) { checkNotNull(key); - raftRegisterClient.deleteRegistryDataByKey(key); + raftRegistryClient.deleteRegistryDataByKey(key); } @Override public Collection children(String key) { checkNotNull(key); - return raftRegisterClient.getRegistryDataChildren(key); + return raftRegistryClient.getRegistryDataChildren(key); } @Override public boolean exists(String key) { checkNotNull(key); - return raftRegisterClient.existRaftRegistryDataKey(key); + return raftRegistryClient.existRaftRegistryDataKey(key); } @Override public boolean acquireLock(String key) { checkNotNull(key); - return raftRegisterClient.acquireRaftRegistryLock(key); + return raftRegistryClient.acquireRaftRegistryLock(key); } @Override public boolean acquireLock(String key, long timeout) { checkNotNull(key); - return raftRegisterClient.acquireRaftRegistryLock(key, timeout); + return raftRegistryClient.acquireRaftRegistryLock(key, timeout); } @Override public boolean releaseLock(String key) { checkNotNull(key); - return raftRegisterClient.releaseRaftRegistryLock(key); + return raftRegistryClient.releaseRaftRegistryLock(key); } @Override public void close() { - log.info("closing raft registry..."); - raftRegisterClient.close(); - log.info("raft registry closed"); + raftRegistryClient.close(); } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java index 9051aef9387b..647c665d5f67 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.plugin.registry.raft; -import org.apache.dolphinscheduler.plugin.registry.raft.server.RaftRegisterServer; +import org.apache.dolphinscheduler.plugin.registry.raft.server.RaftRegistryServer; import lombok.extern.slf4j.Slf4j; @@ -34,21 +34,21 @@ public class RaftRegistryAutoConfiguration { public RaftRegistryAutoConfiguration() { - log.info("Load RaftRegisterAutoConfiguration"); + log.info("Load RaftRegistryAutoConfiguration"); } @Bean @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") - public RaftRegisterServer raftRegisterServer(RaftRegistryProperties raftRegistryProperties) { - RaftRegisterServer raftRegisterServer = new RaftRegisterServer(raftRegistryProperties); - raftRegisterServer.start(); - return raftRegisterServer; + public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) { + RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties); + raftRegistryServer.start(); + return raftRegistryServer; } @Bean - @DependsOn("raftRegisterServer") + @DependsOn("raftRegistryServer") @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") - public RaftRegistry masterRegisterClient(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistry masterRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); raftRegistry.start(); return raftRegistry; @@ -56,7 +56,7 @@ public RaftRegistry masterRegisterClient(RaftRegistryProperties raftRegistryProp @Bean @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "worker") - public RaftRegistry workerRegisterClient(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistry workerRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); raftRegistry.start(); return raftRegistry; @@ -64,7 +64,7 @@ public RaftRegistry workerRegisterClient(RaftRegistryProperties raftRegistryProp @Bean @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "api") - public RaftRegistry apiRegisterClient(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistry apiRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); raftRegistry.start(); return raftRegistry; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegistryClient.java similarity index 98% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegistryClient.java index 365dbdccc17c..3a6fd29d39d3 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegistryClient.java @@ -22,7 +22,7 @@ import java.util.Collection; -public interface IRaftRegisterClient extends AutoCloseable { +public interface IRaftRegistryClient extends AutoCloseable { /** * Start the raft registry client. Once started, the client will connect to the raft registry server and then it can be used. diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java similarity index 91% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java index 7a0d6755b2a5..525f192b85fa 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegisterClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java @@ -52,7 +52,7 @@ import com.alipay.sofa.jraft.rhea.storage.KVEntry; @Slf4j -public class RaftRegisterClient implements IRaftRegisterClient { +public class RaftRegistryClient implements IRaftRegistryClient { private final RheaKVStore rheaKvStore; private final RaftRegistryProperties raftRegistryProperties; @@ -61,7 +61,7 @@ public class RaftRegisterClient implements IRaftRegisterClient { private final IRaftLockManager raftLockManager; private volatile boolean started; private static final String MASTER_MODULE = "master"; - public RaftRegisterClient(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { this.raftRegistryProperties = raftRegistryProperties; this.rheaKvStore = new DefaultRheaKVStore(); this.raftConnectionStateManager = new RaftConnectionStateManager(raftRegistryProperties); @@ -90,14 +90,16 @@ private void initRheakv() { @Override public void start() { if (this.started) { - log.info("RaftRegisterClient is already started"); + log.info("RaftRegistryClient is already started"); return; } + log.info("starting raft client registry..."); if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) { raftSubscribeDataManager.start(); } raftConnectionStateManager.start(); this.started = true; + log.info("raft client registry started successfully"); } @Override @@ -154,7 +156,7 @@ public Collection getRegistryDataChildren(String key) { } List kvEntries = rheaKvStore.bScan(basePath + Constants.SINGLE_SLASH, basePath + Constants.SINGLE_SLASH + Constants.RAFT_END_KEY); - return getRegisterList(kvEntries); + return getRegistryList(kvEntries); } @Override @@ -162,17 +164,17 @@ public boolean existRaftRegistryDataKey(String key) { return rheaKvStore.bContainsKey(key); } - private Collection getRegisterList(List kvEntries) { + private Collection getRegistryList(List kvEntries) { if (kvEntries == null || kvEntries.isEmpty()) { return new ArrayList<>(); } - List registerList = new ArrayList<>(); + List registryList = new ArrayList<>(); for (KVEntry kvEntry : kvEntries) { String entryKey = readUtf8(kvEntry.getKey()); String childKey = entryKey.substring(entryKey.lastIndexOf(Constants.SINGLE_SLASH) + 1); - registerList.add(childKey); + registryList.add(childKey); } - return registerList; + return registryList; } @Override @@ -182,7 +184,7 @@ public boolean acquireRaftRegistryLock(String lockKey) { } catch (Exception ex) { log.error("acquire raft registry lock error", ex); raftLockManager.releaseLock(lockKey); - throw new RegistryException("acquire raft register lock error: " + lockKey, ex); + throw new RegistryException("acquire raft registry lock error: " + lockKey, ex); } } @@ -193,7 +195,7 @@ public boolean acquireRaftRegistryLock(String lockKey, long timeout) { } catch (Exception ex) { log.error("acquire raft registry lock error", ex); raftLockManager.releaseLock(lockKey); - throw new RegistryException("acquire raft register lock error: " + lockKey, ex); + throw new RegistryException("acquire raft registry lock error: " + lockKey, ex); } } @@ -209,11 +211,11 @@ public boolean releaseRaftRegistryLock(String lockKey) { @Override public void close() { - log.info("start close raft register client"); + log.info("ready to close raft registry client"); if (rheaKvStore != null) { rheaKvStore.shutdown(); } this.started = false; - log.info("closed raft register client"); + log.info("closed raft registry client"); } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java index 2c5ce5f1429e..2a35f96f99c1 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -87,21 +88,24 @@ private class SubscribeCheckTask implements Runnable { public void run() { try { final Map newDataMap = getNodeDataMap(); - if (dataSubScribeMap.isEmpty() || newDataMap.isEmpty()) { + if (dataSubScribeMap.isEmpty() || newDataMap == null || newDataMap.isEmpty()) { return; } // find the different final Map addedData = new HashMap<>(); final Map deletedData = new HashMap<>(); final Map updatedData = new HashMap<>(); - for (Map.Entry entry : newDataMap.entrySet()) { + + Iterator> iterator = newDataMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); final NodeItem oldData = oldDataMap.get(entry.getKey()); if (oldData == null) { addedData.put(entry.getKey(), entry.getValue().getNodeValue()); } else if (NodeType.EPHEMERAL.getName().equals(entry.getValue().getNodeType()) && isUnHealthy(entry.getValue().getNodeValue())) { kvStore.bDelete(entry.getKey()); - newDataMap.remove(entry.getKey(), entry.getValue()); + iterator.remove(); } else if (!oldData.getNodeValue().equals(entry.getValue().getNodeValue())) { updatedData.put(entry.getKey(), entry.getValue().getNodeValue()); } @@ -155,40 +159,35 @@ private void triggerListener(Map addedData, Map } private Map getNodeDataMap() { - final Map nodeItemMap = new HashMap<>(); - final List entryList = kvStore.bScan(RegistryNodeType.ALL_SERVERS.getRegistryPath(), - RegistryNodeType.ALL_SERVERS.getRegistryPath() + Constants.SINGLE_SLASH + Constants.RAFT_END_KEY); - - for (KVEntry kvEntry : entryList) { - final String entryKey = readUtf8(kvEntry.getKey()); - final String compositeValue = readUtf8(kvEntry.getValue()); + try { + final Map nodeItemMap = new HashMap<>(); + final List entryList = kvStore.bScan(RegistryNodeType.ALL_SERVERS.getRegistryPath(), + RegistryNodeType.ALL_SERVERS.getRegistryPath() + Constants.SINGLE_SLASH + + Constants.RAFT_END_KEY); + + for (KVEntry kvEntry : entryList) { + final String entryKey = readUtf8(kvEntry.getKey()); + final String compositeValue = readUtf8(kvEntry.getValue()); + + if (StringUtils.isEmpty(compositeValue) + || !entryKey.startsWith(RegistryNodeType.ALL_SERVERS.getRegistryPath())) { + continue; + } - if (StringUtils.isEmpty(compositeValue) - || !entryKey.startsWith(RegistryNodeType.ALL_SERVERS.getRegistryPath())) { - continue; - } + String[] nodeTypeAndValue = compositeValue.split(Constants.AT_SIGN); + if (nodeTypeAndValue.length < 2) { + continue; + } + String nodeType = nodeTypeAndValue[0]; + String nodeValue = nodeTypeAndValue[1]; - String[] nodeTypeAndValue = parseCompositeValue(compositeValue); - if (nodeTypeAndValue.length < 2) { - continue; + nodeItemMap.put(entryKey, NodeItem.builder().nodeValue(nodeValue).nodeType(nodeType).build()); } - String nodeType = nodeTypeAndValue[0]; - String nodeValue = nodeTypeAndValue[1]; - - nodeItemMap.put(entryKey, NodeItem.builder().nodeValue(nodeValue).nodeType(nodeType).build()); - } - return nodeItemMap; - } - - private String[] parseCompositeValue(String compositeValue) { - String[] nodeTypeAndValue = compositeValue.split(Constants.AT_SIGN); - if (nodeTypeAndValue.length < 2) { - log.error("Invalid compositeValue: {}", compositeValue); - return new String[]{}; + return nodeItemMap; + } catch (Exception ex) { + log.error("Fail to getNodeDataMap", ex); + return null; } - String nodeType = nodeTypeAndValue[0]; - String nodeValue = nodeTypeAndValue[1]; - return new String[]{nodeType, nodeValue}; } private void triggerListener(Map nodeDataMap, String subscribeKey, diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java similarity index 88% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java index bc67d99c796d..74b92b5e5140 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegisterServer.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java @@ -33,12 +33,12 @@ import com.alipay.sofa.jraft.util.Endpoint; @Slf4j -public class RaftRegisterServer { +public class RaftRegistryServer { private final RheaKVStore rheaKVStore; private final RheaKVStoreOptions options; private volatile boolean started; - public RaftRegisterServer(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistryServer(RaftRegistryProperties raftRegistryProperties) { final PlacementDriverOptions pdOpts = PlacementDriverOptionsConfigured.newConfigured() .withFake(true) // use a fake pd .config(); @@ -59,21 +59,21 @@ public RaftRegisterServer(RaftRegistryProperties raftRegistryProperties) { public void start() { if (this.started) { - log.info("raft register server is already started"); + log.info("raft registry server has already started"); return; } - log.info("starting raft register server..."); + log.info("starting raft registry server..."); this.rheaKVStore.init(this.options); - log.info("raft register server started successfully"); + log.info("raft registry server started successfully"); this.started = true; } public void stop() { - log.info("stopping raft register server"); + log.info("stopping raft registry server"); if (this.rheaKVStore != null) { this.rheaKVStore.shutdown(); } this.started = false; - log.info("raft register server stopped successfully"); + log.info("raft registry server stopped successfully"); } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryTestCase.java similarity index 98% rename from dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java rename to dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryTestCase.java index df284c74d2d5..5ccd2311e224 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/register/raft/RaftRegistryTestCase.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryTestCase.java @@ -14,15 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.register.raft; +package org.apache.dolphinscheduler.plugin.registry.raft; import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.dolphinscheduler.common.model.BaseHeartBeat; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistry; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.registry.api.ConnectionState; import org.apache.dolphinscheduler.registry.api.Event; import org.apache.dolphinscheduler.registry.api.RegistryException; From 593dfe0302f55bbba0594959e0c1c63cc4e13e90 Mon Sep 17 00:00:00 2001 From: matthew Date: Sun, 8 Sep 2024 11:24:49 +0800 Subject: [PATCH 6/8] =?UTF-8?q?Adjust=20to=20form=20a=20raft=20cluster=20w?= =?UTF-8?q?ith=20all=20nodes.=EF=BC=88#10874=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dolphinscheduler-registry-raft/README.md | 36 +++---------------- .../raft/RaftRegistryAutoConfiguration.java | 20 +---------- .../registry/raft/RaftRegistryProperties.java | 13 ------- .../raft/client/RaftRegistryClient.java | 15 ++++---- .../manage/RaftConnectionStateManager.java | 25 +++++++++---- .../registry/raft/manage/RaftLockManager.java | 17 +++++---- .../raft/manage/RaftSubscribeDataManager.java | 30 +++++++++------- .../raft/server/RaftRegistryServer.java | 2 +- 8 files changed, 57 insertions(+), 101 deletions(-) diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md index 6d057ae3e75d..7366152760fc 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md @@ -1,9 +1,6 @@ # Introduction -This module is the RAFT consensus algorithm registry plugin module, this plugin will use raft cluster as the registry center. -The Raft registration plugin consists of two parts: -the server and the client. The Master module of DolphinScheduler will form a Raft server cluster -, while the Worker modules and API modules will interact with the Raft server using the Raft client. +This is a registration plugin implemented with the raft algorithm, and the nodes in the cluster will participate in the election as nodes of the raft # How to use @@ -16,7 +13,7 @@ you need to set the registry properties in master/worker/api's appplication.yml, NOTE: In production environment, in order to achieve high availability, the master must be an odd number e.g 3 or 5. -master's properties example +properties example ```yaml registry: type: raft @@ -25,33 +22,10 @@ registry: server-address: 127.0.0.1 server-port: 8181 log-storage-dir: raft-data/ - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributed-lock-retry-interval: 3s - module: master -``` -worker's appplication.yml example -```yaml -registry: - type: raft - cluster-name: dolphinscheduler - server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributed-lock-retry-interval: 3s - module: worker -``` -api's appplication.yml example -```yaml -registry: - type: raft - cluster-name: dolphinscheduler - server-address-list: 127.0.0.1:8181,127.0.0.1:8182,127.0.0.1:8183 - listener-check-interval: 3s - distributed-lock-timeout: 3s - distributed-lock-retry-interval: 3s - module: api ``` +Among them, the "type" must be set to "raft". The "cluster-name" can be set by yourself or use the default one. The "server-address-list" should be set to all addresses of the cluster. +The "server-address" is the IP+PORT where the current application is located. The "server-port" is the port listened to by raft (note that this port is different from the port where the application starts and is specially used for communication by the raft cluster). +The "log-storage-dir" is the storage address of the logs generated by raft. Then you can start your DolphinScheduler cluster, your cluster will use raft cluster as registry center to store server metadata. \ No newline at end of file diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java index 647c665d5f67..0da871c42f15 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java @@ -38,7 +38,6 @@ public RaftRegistryAutoConfiguration() { } @Bean - @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) { RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties); raftRegistryServer.start(); @@ -47,24 +46,7 @@ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistry @Bean @DependsOn("raftRegistryServer") - @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master") - public RaftRegistry masterRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { - RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); - raftRegistry.start(); - return raftRegistry; - } - - @Bean - @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "worker") - public RaftRegistry workerRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { - RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); - raftRegistry.start(); - return raftRegistry; - } - - @Bean - @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "api") - public RaftRegistry apiRaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { + public RaftRegistry raftRegistryClient(RaftRegistryProperties raftRegistryProperties) { RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties); raftRegistry.start(); return raftRegistry; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java index 7a878fd60763..a7d9442ace22 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.plugin.registry.raft; -import java.time.Duration; - import lombok.Data; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -36,16 +34,5 @@ public class RaftRegistryProperties { private String serverAddress; private int serverPort; private String logStorageDir; - private Duration distributedLockTimeout = Duration.ofSeconds(3); - private Duration distributedLockRetryInterval = Duration.ofSeconds(5); - private String module = "master"; - private Duration listenerCheckInterval = Duration.ofSeconds(3); - private int cliMaxRetries = 3; - private Duration cliTimeout = Duration.ofSeconds(5); - private Duration refreshLeaderTimeout = Duration.ofSeconds(2); - private Duration connectStateCheckInterval = Duration.ofSeconds(2); - private Duration heartBeatTimeOut = Duration.ofSeconds(20); - private int subscribeListenerThreadPoolSize = 1; - private int connectionListenerThreadPoolSize = 1; } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java index 525f192b85fa..4c84abcc7ca5 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java @@ -60,13 +60,12 @@ public class RaftRegistryClient implements IRaftRegistryClient { private final IRaftSubscribeDataManager raftSubscribeDataManager; private final IRaftLockManager raftLockManager; private volatile boolean started; - private static final String MASTER_MODULE = "master"; public RaftRegistryClient(RaftRegistryProperties raftRegistryProperties) { this.raftRegistryProperties = raftRegistryProperties; this.rheaKvStore = new DefaultRheaKVStore(); this.raftConnectionStateManager = new RaftConnectionStateManager(raftRegistryProperties); - this.raftSubscribeDataManager = new RaftSubscribeDataManager(raftRegistryProperties, rheaKvStore); - this.raftLockManager = new RaftLockManager(rheaKvStore, raftRegistryProperties); + this.raftSubscribeDataManager = new RaftSubscribeDataManager(rheaKvStore); + this.raftLockManager = new RaftLockManager(rheaKvStore); initRheakv(); } @@ -80,9 +79,9 @@ private void initRheakv() { .withFake(true) .withRegionRouteTableOptionsList(regionRouteTableOptionsList) .config(); - final RheaKVStoreOptions opts = RheaKVStoreOptionsConfigured.newConfigured() // - .withClusterName(raftRegistryProperties.getClusterName()) // - .withPlacementDriverOptions(pdOpts) // + final RheaKVStoreOptions opts = RheaKVStoreOptionsConfigured.newConfigured() + .withClusterName(raftRegistryProperties.getClusterName()) + .withPlacementDriverOptions(pdOpts) .config(); this.rheaKvStore.init(opts); } @@ -94,9 +93,7 @@ public void start() { return; } log.info("starting raft client registry..."); - if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) { - raftSubscribeDataManager.start(); - } + raftSubscribeDataManager.start(); raftConnectionStateManager.start(); this.started = true; log.info("raft client registry started successfully"); diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java index 54c2b8fdc101..93073cf34fc8 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftConnectionStateManager.java @@ -21,7 +21,9 @@ import org.apache.dolphinscheduler.registry.api.ConnectionListener; import org.apache.dolphinscheduler.registry.api.ConnectionState; +import java.time.Duration; import java.util.List; +import java.util.Random; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -39,6 +41,10 @@ public class RaftConnectionStateManager implements IRaftConnectionStateManager { private static final String DEFAULT_REGION_ID = "--1"; + private static final Duration CONNECT_STATE_CHECK_INTERVAL = Duration.ofSeconds(2); + private static final int CONNECT_STATE_REFRESH_THREAD_POOL_SIZE = 1; + private static final Duration REFRESH_LEADER_TIME_OUT = Duration.ofSeconds(2); + private static final int MAX_RANDOM_DELAY_MS = 500; private ConnectionState currentConnectionState; private final RaftRegistryProperties properties; private final List connectionListeners = new CopyOnWriteArrayList<>(); @@ -49,11 +55,9 @@ public class RaftConnectionStateManager implements IRaftConnectionStateManager { public RaftConnectionStateManager(RaftRegistryProperties properties) { this.properties = properties; this.cliOptions = new CliOptions(); - this.cliOptions.setMaxRetry(properties.getCliMaxRetries()); - this.cliOptions.setTimeoutMs((int) properties.getCliTimeout().toMillis()); this.cliClientService = new CliClientServiceImpl(); this.scheduledExecutorService = Executors.newScheduledThreadPool( - properties.getConnectionListenerThreadPoolSize(), + CONNECT_STATE_REFRESH_THREAD_POOL_SIZE, new ThreadFactoryBuilder().setNameFormat("ConnectionStateRefreshThread").setDaemon(true).build()); } @Override @@ -61,10 +65,18 @@ public void start() { cliClientService.init(cliOptions); scheduledExecutorService.scheduleWithFixedDelay( new ConnectionStateRefreshTask(connectionListeners), - properties.getConnectStateCheckInterval().toMillis(), - properties.getConnectStateCheckInterval().toMillis(), + getRandomizedDelay(CONNECT_STATE_CHECK_INTERVAL.toMillis()), + getRandomizedDelay(CONNECT_STATE_CHECK_INTERVAL.toMillis()), TimeUnit.MILLISECONDS); } + + private long getRandomizedDelay(long baseDelay) { + // Add a random value in the range [0, RANDOM_DELAY_RANGE_MS] + Random random = new Random(); + long randomOffset = random.nextInt(MAX_RANDOM_DELAY_MS + 1); + return baseDelay + randomOffset; + } + @Override public void addConnectionListener(ConnectionListener listener) { connectionListeners.add(listener); @@ -113,8 +125,7 @@ private ConnectionState getCurrentConnectionState() { try { String groupId = properties.getClusterName() + DEFAULT_REGION_ID; if (RouteTable.getInstance() - .refreshLeader(cliClientService, groupId, (int) properties.getRefreshLeaderTimeout().toMillis()) - .isOk()) { + .refreshLeader(cliClientService, groupId, (int) REFRESH_LEADER_TIME_OUT.toMillis()).isOk()) { return ConnectionState.CONNECTED; } else { return ConnectionState.DISCONNECTED; diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java index 7eee5c7263a2..f2c32f316cea 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftLockManager.java @@ -20,9 +20,9 @@ import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.plugin.registry.raft.model.RaftLockEntry; +import java.time.Duration; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; @@ -37,13 +37,13 @@ public class RaftLockManager implements IRaftLockManager { private final Map distributedLockMap = new ConcurrentHashMap<>(); private final RheaKVStore rheaKvStore; - private final RaftRegistryProperties raftRegistryProperties; private static final ScheduledExecutorService WATCH_DOG = Executors.newSingleThreadScheduledExecutor(); private static final String LOCK_OWNER_PREFIX = NetUtils.getHost() + "_" + OSUtils.getProcessID() + "_"; + private static final Duration DISTRIBUTE_LOCK_TIME_OUT = Duration.ofSeconds(3); + private static final Duration DISTRIBUTE_LOCK_RETRY_INTERVAL = Duration.ofMillis(50); - public RaftLockManager(RheaKVStore rheaKVStore, RaftRegistryProperties raftRegistryProperties) { + public RaftLockManager(RheaKVStore rheaKVStore) { this.rheaKvStore = rheaKVStore; - this.raftRegistryProperties = raftRegistryProperties; } @Override @@ -54,8 +54,7 @@ public boolean acquireLock(String lockKey) { } final DistributedLock distributedLock = rheaKvStore.getDistributedLock(lockKey, - raftRegistryProperties.getDistributedLockTimeout().toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); - + DISTRIBUTE_LOCK_TIME_OUT.toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); while (true) { if (distributedLock.tryLock()) { distributedLockMap.put(lockKey, RaftLockEntry.builder().distributedLock(distributedLock) @@ -64,7 +63,7 @@ public boolean acquireLock(String lockKey) { return true; } else { // fail to acquire lock - ThreadUtils.sleep(raftRegistryProperties.getDistributedLockRetryInterval().toMillis()); + ThreadUtils.sleep(DISTRIBUTE_LOCK_RETRY_INTERVAL.toMillis()); } } } @@ -77,7 +76,7 @@ public boolean acquireLock(String lockKey, long timeout) { } final long endTime = System.currentTimeMillis() + timeout; final DistributedLock distributedLock = rheaKvStore.getDistributedLock(lockKey, - raftRegistryProperties.getDistributedLockTimeout().toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); + DISTRIBUTE_LOCK_TIME_OUT.toMillis(), TimeUnit.MILLISECONDS, WATCH_DOG); while (System.currentTimeMillis() < endTime) { if (distributedLock.tryLock()) { @@ -87,7 +86,7 @@ public boolean acquireLock(String lockKey, long timeout) { return true; } else { // fail to acquire lock - ThreadUtils.sleep(raftRegistryProperties.getDistributedLockRetryInterval().toMillis()); + ThreadUtils.sleep(DISTRIBUTE_LOCK_RETRY_INTERVAL.toMillis()); } } diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java index 2a35f96f99c1..ff56b231aa65 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/manage/RaftSubscribeDataManager.java @@ -22,7 +22,6 @@ import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.model.BaseHeartBeat; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.plugin.registry.raft.RaftRegistryProperties; import org.apache.dolphinscheduler.plugin.registry.raft.model.NodeItem; import org.apache.dolphinscheduler.plugin.registry.raft.model.NodeType; import org.apache.dolphinscheduler.registry.api.Event; @@ -31,11 +30,13 @@ import org.apache.commons.lang3.StringUtils; +import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -50,29 +51,35 @@ public class RaftSubscribeDataManager implements IRaftSubscribeDataManager { private final Map> dataSubScribeMap = new ConcurrentHashMap<>(); - - private final RaftRegistryProperties properties; - private final RheaKVStore kvStore; - private final ScheduledExecutorService scheduledExecutorService; + private static final Duration LISTENER_CHECK_INTERVAL = Duration.ofSeconds(2); + private static final Duration HEART_BEAT_TIME_OUT = Duration.ofSeconds(20); + private static final int MAX_RANDOM_DELAY_MS = 500; + private static final int SUBSCRIBE_LISTENER_THREAD_POOL_SIZE = 1; - public RaftSubscribeDataManager(RaftRegistryProperties properties, RheaKVStore kvStore) { - this.properties = properties; + public RaftSubscribeDataManager(RheaKVStore kvStore) { this.kvStore = kvStore; this.scheduledExecutorService = Executors.newScheduledThreadPool( - properties.getSubscribeListenerThreadPoolSize(), + SUBSCRIBE_LISTENER_THREAD_POOL_SIZE, new ThreadFactoryBuilder().setNameFormat("SubscribeListenerCheckThread").setDaemon(true).build()); } @Override public void start() { scheduledExecutorService.scheduleWithFixedDelay(new SubscribeCheckTask(), - properties.getListenerCheckInterval().toMillis(), - properties.getListenerCheckInterval().toMillis(), + getRandomizedDelay(LISTENER_CHECK_INTERVAL.toMillis()), + getRandomizedDelay(LISTENER_CHECK_INTERVAL.toMillis()), TimeUnit.MILLISECONDS); } + private long getRandomizedDelay(long baseDelay) { + // Add a random value in the range [0, MAX_RANDOM_DELAY_MS] + Random random = new Random(); + long randomOffset = random.nextInt(MAX_RANDOM_DELAY_MS + 1); + return baseDelay + randomOffset; + } + @Override public void addDataSubscribeListener(String path, SubscribeListener listener) { final List subscribeListeners = @@ -132,8 +139,7 @@ private boolean isUnHealthy(String heartBeat) { } BaseHeartBeat baseHeartBeat = JSONUtils.parseObject(heartBeat, BaseHeartBeat.class); if (baseHeartBeat != null) { - return System.currentTimeMillis() - baseHeartBeat.getReportTime() > properties.getHeartBeatTimeOut() - .toMillis(); + return System.currentTimeMillis() - baseHeartBeat.getReportTime() > HEART_BEAT_TIME_OUT.toMillis(); } } catch (Exception ex) { log.error("Fail to parse heartBeat : {}", heartBeat, ex); diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java index 74b92b5e5140..23c12c6aa008 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/server/RaftRegistryServer.java @@ -64,8 +64,8 @@ public void start() { } log.info("starting raft registry server..."); this.rheaKVStore.init(this.options); - log.info("raft registry server started successfully"); this.started = true; + log.info("raft registry server started successfully"); } public void stop() { From d98caa1f7f816f332132c83ed851fbe250d9f800 Mon Sep 17 00:00:00 2001 From: matthew Date: Wed, 11 Sep 2024 15:34:37 +0800 Subject: [PATCH 7/8] =?UTF-8?q?Remove=20redundant=20configurations=20from?= =?UTF-8?q?=20the=20test=20module.=EF=BC=88#10874=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/resources/application.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml index cdfede7702a1..a0a63940e23b 100644 --- a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml +++ b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml @@ -17,14 +17,10 @@ registry: type: raft - module: master clusterName: dolphinscheduler serverAddressList: 127.0.0.1:8082 serverAddress: 127.0.0.1 serverPort: 8082 logStorageDir: raft-data/ - distributedLockTimeout: 3s - distributedLockRetryInterval: 3s - listenerCheckInterval: 3s From 68a74d005f759d3bce60ca00bb96bfeee34ee18c Mon Sep 17 00:00:00 2001 From: matthew Date: Fri, 13 Sep 2024 15:12:09 +0800 Subject: [PATCH 8/8] =?UTF-8?q?Supplementary=20dependency=20information.?= =?UTF-8?q?=EF=BC=88#10874=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/dependencies/known-dependencies.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/dependencies/known-dependencies.txt b/tools/dependencies/known-dependencies.txt index c6780804d4f1..dea8881f871a 100644 --- a/tools/dependencies/known-dependencies.txt +++ b/tools/dependencies/known-dependencies.txt @@ -529,4 +529,17 @@ tea-1.2.7.jar tea-openapi-0.3.2.jar tea-util-0.2.21.jar tea-xml-0.1.5.jar - +affinity-3.1.7.jar +annotations-12.0.jar +bolt-1.6.4.jar +disruptor-3.3.7.jar +hessian-3.3.6.jar +jctools-core-2.1.1.jar +jraft-core-1.3.14.jar +jraft-rheakv-core-1.3.14.jar +protostuff-api-1.7.2.jar +protostuff-collectionschema-1.7.2.jar +protostuff-core-1.7.2.jar +protostuff-runtime-1.7.2.jar +rocksdbjni-8.8.1.jar +sofa-common-tools-1.0.12.jar \ No newline at end of file