You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "MatthewAden (via GitHub)" <gi...@apache.org> on 2024/07/20 12:49:05 UTC
[PR] [Feature-10874][registry]add raft registration plugin [dolphinscheduler]
MatthewAden opened a new pull request, #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352
## Purpose of the pull request
This is a project for the [OSPP](https://summer-ospp.ac.cn/org/prodetail/24a2d0370?lang=zh&list=pro) 2024. This PR is related to Issue [#10874 ](https://github.com/apache/dolphinscheduler/issues/10874)
## Brief change log
- Added a new module: /dolphinscheduler-registry/dolphinscheduler-plugins/dolphinscheduler-registry-raft
- Added raft's dependency in dolphinscheduler-bom/pom.xml
- Added dolphinscheduler-registry-raft dependency in dolphinscheduler-registry/dolphinscheduler-registry-all/pom.xml
## Verify this pull request
Directly running RaftRegistryTestCase yields the following results.

<!--*(example:)*
- *Added dolphinscheduler-dao tests for end-to-end.*
- *Added CronUtilsTest to verify the change.*
- *Manually verified the change by testing locally.* -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "wujiajian1 (via GitHub)" <gi...@apache.org>.
wujiajian1 commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2643223107
If the master cluster fails, then the worker still uses the original logic. Why is there a problem? What's the problem? If you want to think about the big picture, we also want to get rid of zookeeper
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2295823659
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1721277554
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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);
+ 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;
Review Comment:
Why we need to exposed so many configurations to user. Is there any doc related to these config?
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
The plugin shouldn't care about the server type.
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.RaftRegistryProperties;
+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;
+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 RaftRegistryClient implements IRaftRegistryClient {
+
+ 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 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);
+
+ initRheakv();
+ }
+
+ private void initRheakv() {
+ final List<RegionRouteTableOptions> 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("RaftRegistryClient is already started");
+ return;
+ }
+ log.info("starting raft client registry...");
+ if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) {
+ raftSubscribeDataManager.start();
+ }
Review Comment:
Why only master start the `raftSubscribeDataManager`, this is strange.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "zhuxt2015 (via GitHub)" <gi...@apache.org>.
zhuxt2015 commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1802474689
##########
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
Review Comment:
The raft plugin depends on alipay jraft's rheakv, and other raft implementations do not have this kv store, if can't rely on alipay's jar, then this pr can't be continued, do you want to terminate this pr?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1805997321
##########
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
Review Comment:
> The raft plugin depends on alipay jraft's rheakv, and other raft implementations do not have this kv store, if can't rely on alipay's jar, then this pr can't be continued, do you want to terminate this pr?
Open source projects are submitted to PR voluntarily and free of charge. Please notice that not all PR will be accepted and must be merged.
> Why not accept Alipay's dependency?
Registry is the core component of DS. So that it must be robust and maintainable. The alipay's `jraft-rheakv-core` dependency obviously do not have these conditions and it has a lot of CVE. After using this dependency, every time you fix a problem and CVE in the future, you need to rely on its upgrade, and there may be incompatible updates during the upgrade process. This is unacceptable for the core components.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1695277134
##########
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.
+ * <p>
+ * 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);
Review Comment:
done
##########
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<ConnectionListener> 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);
Review Comment:
sorry to make you repeat the same thing twice. I have finished modifying all the magic numbers in the file.
##########
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<String, LockEntry> distributedLockMap = new ConcurrentHashMap<>();
+ private final RheaKVStore rheaKvStore;
+ private final RaftRegistryProperties raftRegistryProperties;
+ private static final ScheduledExecutorService WATCH_DOG = Executors.newSingleThreadScheduledExecutor();
Review Comment:
This is an automatic lease renewal scheduler, and calling it watchdog might be more appropriate in this context. JRaft also refers to it as WatchDog.
##########
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
Review Comment:
We introduced this direct dependency.
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>jraft-rheakv-core</artifactId>
<version>${jraft.version}</version>
</dependency>
</dependencies>
These are all transitive dependencies. I'm not sure if these need to be written in the license.
##########
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<ConnectionListener> 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) {
Review Comment:
updated
##########
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<String, LockEntry> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> distributedLock;
+ private String lockOwner;
+ }
Review Comment:
done
##########
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<ConnectionListener> 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());
+ }
+ @Override
+ public void start() {
+ cliClientService.init(cliOptions);
+ scheduledExecutorService.scheduleWithFixedDelay(
+ new ConnectionStateRefreshTask(connectionListeners),
+ CONNECT_STATE_CHECK_INTERVENE.toMillis(),
+ CONNECT_STATE_CHECK_INTERVENE.toMillis(),
+ TimeUnit.MILLISECONDS);
+ }
+ @Override
+ public void addConnectionListener(ConnectionListener listener) {
+ connectionListeners.add(listener);
+ }
+
+ @Override
+ public ConnectionState getConnectionState() {
+ return currentConnectionState;
+ }
+
+ class ConnectionStateRefreshTask implements Runnable {
+
+ private final List<ConnectionListener> connectionListeners;
+ ConnectionStateRefreshTask(List<ConnectionListener> 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()) {
Review Comment:
done
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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);
+ 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;
Review Comment:
The following configurations are the JRaft component use.
private String clusterName;
private String serverAddressList;
private String serverAddress;
private int serverPort;
private String logStorageDir;
private Duration distributedLockTimeout = Duration.ofSeconds(3);
private int cliMaxRetries = 3;
private Duration cliTimeout = Duration.ofSeconds(5);
private Duration refreshLeaderTimeout = Duration.ofSeconds(2);
The following are some configurations we used ourselves. The previous CodeReview said not to use so many image numbers, so I put all of them here in the configuration.
private Duration distributedLockRetryInterval = Duration.ofSeconds(5);
private String module = "master";
private Duration heartBeatTimeOut = Duration.ofSeconds(20);
private Duration listenerCheckInterval = Duration.ofSeconds(3);
private Duration connectStateCheckInterval = Duration.ofSeconds(2);
private int subscribeListenerThreadPoolSize = 1;
private int connectionListenerThreadPoolSize = 1;
What should be done to make it better?
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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 static final long RECONNECT_WAIT_TIME_MS = 50L;
Review Comment:
it has been defined as a constant and then used.
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
I want to achieve is that the master start the client and server of raft, while other modules only need to start the client of raft. Is there a better way to achieve this?
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.RaftRegistryProperties;
+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;
+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 RaftRegistryClient implements IRaftRegistryClient {
+
+ 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 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);
+
+ initRheakv();
+ }
+
+ private void initRheakv() {
+ final List<RegionRouteTableOptions> 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("RaftRegistryClient is already started");
+ return;
+ }
+ log.info("starting raft client registry...");
+ if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) {
+ raftSubscribeDataManager.start();
+ }
Review Comment:
In my understanding, only the master listens for changes in the registered instances
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1749057994
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryProperties.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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);
+ 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;
Review Comment:
Some of these configurations have put into classes. Only the configurations that users must set are retained.
```
private String clusterName;
private String serverAddressList;
private String serverAddress;
private int serverPort;
private String logStorageDir;
```
At the same time, explanations of the configurations are added in the markdown of the plugin.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #16352: [DSIP-9][registry] add raft registration plugin
URL: https://github.com/apache/dolphinscheduler/pull/16352
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2342971301
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [D Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "zhuxt2015 (via GitHub)" <gi...@apache.org>.
zhuxt2015 commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1802515341
##########
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
Review Comment:
> We should remove all dependencies from alipay.
Why not accept Alipay's dependency?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1721283638
##########
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
Review Comment:
why we need to import so many dependencies from alipay?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry]add raft registration plugin [dolphinscheduler]
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1685445080
##########
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<String, List<SubscribeListener>> 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() {
Review Comment:
## Missing Override annotation
This method overrides [IRaftSubscribeDataManager.start](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4250)
##########
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.
+ * <p>
+ * 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);
Review Comment:
## Useless parameter
The parameter 'deleteOnDisconnect' is never used.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4247)
##########
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<ConnectionListener> 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) {
Review Comment:
## Missing Override annotation
This method overrides [IRaftConnectionStateManager.addConnectionListener](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4248)
##########
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<ConnectionListener> 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() {
Review Comment:
## Missing Override annotation
This method overrides [IRaftConnectionStateManager.start](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4249)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1686136910
##########
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
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2294691674
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [54.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16352&metric=new_coverage&view=list) (required ≥ 60%)
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1749056948
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
The modification has been completed. All nodes will form nodes in the raft cluster instead of only the master forming the raft cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2348296324
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [D Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry]add raft registration plugin [dolphinscheduler]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2241142778
Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2255482757
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2342972664
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [D Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "wujiajian1 (via GitHub)" <gi...@apache.org>.
wujiajian1 commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2643232065
> > This plugin does not reduce the stability and availability of the ds cluster, and will maintain the same impact on the cluster as other plugins.
>
> > If the cluster does have master, then the cluster will not work.
>
> This is against zk and jdbc registry since neither of these two types will cause the worker server and alert server to fail to operate normally because of the downtime of the master server.
If the master cluster fails, then the worker still uses the original logic. Why is there a problem? What's the problem? If you want to think about the big picture, we also want to get rid of zookeeper
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2998380142
This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1686136570
##########
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);
Review Comment:
Thanks,updated
##########
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<String, List<SubscribeListener>> 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,
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry]add raft registration plugin [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1685430568
##########
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
Review Comment:
Same here.
##########
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
Review Comment:
Please keep 4 indent in yaml file.
##########
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);
Review Comment:
Please avoid using magic number. Adding it to constant.
##########
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<String, List<SubscribeListener>> 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,
Review Comment:
Avoid magic number here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2294690621
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [54.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16352&metric=new_coverage&view=list) (required ≥ 60%)
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2374020066
Please add mysql and postgresql with raft registry cluster test in CI. You can refer to https://github.com/apache/dolphinscheduler/tree/dev/.github/workflows/cluster-test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-3021281959
This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2255483146
Please retry analysis of this Pull-Request directly on SonarCloud
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1749056484
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/RaftRegistryClient.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.RaftRegistryProperties;
+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;
+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 RaftRegistryClient implements IRaftRegistryClient {
+
+ 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 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);
+
+ initRheakv();
+ }
+
+ private void initRheakv() {
+ final List<RegionRouteTableOptions> 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("RaftRegistryClient is already started");
+ return;
+ }
+ log.info("starting raft client registry...");
+ if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) {
+ raftSubscribeDataManager.start();
+ }
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2295823306
## [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) **Quality Gate failed**
Failed conditions
 [C Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352) (required ≥ A)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16352)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "zhuxt2015 (via GitHub)" <gi...@apache.org>.
zhuxt2015 commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1738315725
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
we can start raft registry in a separate process like other server
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "zhuxt2015 (via GitHub)" <gi...@apache.org>.
zhuxt2015 commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1738608954
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
> > we can start raft registry in a separate process like other server
>
>
>
> The main purpose of this feature is to reduce dependence on third-party components. Starting raft registry in a separate process is exactly the opposite of what we wanted. We should add to each server and be insensitive to existing users as the service starts.
YES,We will add raft registry server to master server and worker server. All the server node participate in the election of the raft leader node.This will also make the cluster more rubust.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2296085107
> If there are no master can this work? We should select the leader from the whole cluster rather than select the leader from master, I didn't see any design related to this PR, you should provide the newly design doc related to this PR.
Hi, this is an OSPP project. My mentor is @zhuxt2015. The design plan for the raft plugin has been discussed. The design link is [Add new registry plugin based on raft](https://github.com/apache/dolphinscheduler/issues/10874). According to the discussed plan, masters will form a raft cluster, and the leader will only be elected among the masters, just like in ZK. For the three master nodes, at least two must be alive to provide services normally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1687454776
##########
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<ConnectionListener> 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);
Review Comment:
Too many magic numbers. We should avoid this.
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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 static final long RECONNECT_WAIT_TIME_MS = 50L;
Review Comment:
Magic number.
##########
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<ConnectionListener> 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());
+ }
+ @Override
+ public void start() {
+ cliClientService.init(cliOptions);
+ scheduledExecutorService.scheduleWithFixedDelay(
+ new ConnectionStateRefreshTask(connectionListeners),
+ CONNECT_STATE_CHECK_INTERVENE.toMillis(),
+ CONNECT_STATE_CHECK_INTERVENE.toMillis(),
+ TimeUnit.MILLISECONDS);
+ }
+ @Override
+ public void addConnectionListener(ConnectionListener listener) {
+ connectionListeners.add(listener);
+ }
+
+ @Override
+ public ConnectionState getConnectionState() {
+ return currentConnectionState;
+ }
+
+ class ConnectionStateRefreshTask implements Runnable {
+
+ private final List<ConnectionListener> connectionListeners;
+ ConnectionStateRefreshTask(List<ConnectionListener> 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()) {
Review Comment:
Same here.
##########
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<String, LockEntry> distributedLockMap = new ConcurrentHashMap<>();
+ private final RheaKVStore rheaKvStore;
+ private final RaftRegistryProperties raftRegistryProperties;
+ private static final ScheduledExecutorService WATCH_DOG = Executors.newSingleThreadScheduledExecutor();
Review Comment:
```suggestion
private static final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
```
##########
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<String, LockEntry> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> distributedLock;
+ private String lockOwner;
+ }
Review Comment:
It's better to split into individual files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2348296662
Please retry analysis of this Pull-Request directly on SonarCloud
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1738303785
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
The plugin doesn't need to care about the server type, we will +/- server type in the future.
And if only the master start the server, this means if the cluster doesn't exist masters, then the registry will died? this is not accepted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1738568563
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistryAutoConfiguration.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.RaftRegistryServer;
+
+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;
+import org.springframework.context.annotation.DependsOn;
+
+@Slf4j
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = "raft")
+@EnableConfigurationProperties(RaftRegistryProperties.class)
+public class RaftRegistryAutoConfiguration {
+
+ public RaftRegistryAutoConfiguration() {
+ log.info("Load RaftRegistryAutoConfiguration");
+ }
+
+ @Bean
+ @ConditionalOnProperty(prefix = "registry", name = "module", havingValue = "master")
+ public RaftRegistryServer raftRegistryServer(RaftRegistryProperties raftRegistryProperties) {
+ RaftRegistryServer raftRegistryServer = new RaftRegistryServer(raftRegistryProperties);
+ raftRegistryServer.start();
+ return raftRegistryServer;
+ }
+
+ @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) {
+ RaftRegistry raftRegistry = new RaftRegistry(raftRegistryProperties);
+ raftRegistry.start();
+ return raftRegistry;
+ }
Review Comment:
> we can start raft registry in a separate process like other server
The main purpose of this feature is to reduce dependence on third-party components. Starting raft registry in a separate process is exactly the opposite of what we wanted. We should add to each server and be insensitive to existing users as the service starts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [DSIP-9][registry] add raft registration plugin [dolphinscheduler]
Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#issuecomment-2644418705
> > > This plugin does not reduce the stability and availability of the ds cluster, and will maintain the same impact on the cluster as other plugins.
> >
> >
> > > If the cluster does have master, then the cluster will not work.
> >
> >
> > This is against zk and jdbc registry since neither of these two types will cause the worker server and alert server to fail to operate normally because of the downtime of the master server.
>
> If the master cluster fails, then the worker still uses the original logic. Why is there a problem? What's the problem? If you want to think about the big picture, we also want to get rid of zookeeper
You should get more background about this, the origin design of this PR will only store data on master, if all master crash, then all server rely on registry will crash. This is why `If the cluster does not have master, then the whole cluster will not work`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10874][registry] add raft registration plugin [dolphinscheduler]
Posted by "MatthewAden (via GitHub)" <gi...@apache.org>.
MatthewAden commented on code in PR #16352:
URL: https://github.com/apache/dolphinscheduler/pull/16352#discussion_r1686137586
##########
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<String, List<SubscribeListener>> 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() {
Review Comment:
updated
##########
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<ConnectionListener> 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() {
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org