-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DSIP-9][registry] add raft registration plugin #16352
base: dev
Are you sure you want to change the base?
Conversation
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) |
...cheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-raft/README.md
Outdated
Show resolved
Hide resolved
...gistry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java
Outdated
Show resolved
Hide resolved
...cheduler-registry-plugins/dolphinscheduler-registry-raft/src/test/resources/application.yaml
Outdated
Show resolved
Hide resolved
21f6409
to
da9a816
Compare
da9a816
to
b477fce
Compare
...c/main/java/org/apache/dolphinscheduler/plugin/registry/raft/client/IRaftRegisterClient.java
Fixed
Show resolved
Hide resolved
...c/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java
Fixed
Show resolved
Hide resolved
...c/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java
Fixed
Show resolved
Hide resolved
...src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftSubscribeDataManager.java
Fixed
Show resolved
Hide resolved
...c/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftConnectionStateManager.java
Outdated
Show resolved
Hide resolved
...try-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java
Outdated
Show resolved
Hide resolved
...try-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftLockManager.java
Outdated
Show resolved
Hide resolved
...gistry-raft/src/main/java/org/apache/dolphinscheduler/plugin/registry/raft/RaftRegistry.java
Show resolved
Hide resolved
6f299ab
to
71de6b2
Compare
71de6b2
to
c638010
Compare
if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) { | ||
raftSubscribeDataManager.start(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only master start the raftSubscribeDataManager
, this is strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding, only the master listens for changes in the registered instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin shouldn't care about the server type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can start raft registry in a separate process like other server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modification has been completed. All nodes will form nodes in the raft cluster instead of only the master forming the raft cluster.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to exposed so many configurations to user. Is there any doc related to these config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need to import so many dependencies from alipay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 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. |
c638010
to
9f50e1c
Compare
9f50e1c
to
d98caa1
Compare
Please retry analysis of this Pull-Request directly on SonarCloud |
Purpose of the pull request
This is a project for the OSPP 2024. This PR is close #10874
Brief change log
Verify this pull request
Unit Test Results:
Pseudo-Cluster Deployment Status:
Cluster Test
Test conditions:
2 master nodes, 1 worker node
OS: mac
Steps:
Start node1, node2, and node3 in sequence