Skip to content
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

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

MatthewAden
Copy link

@MatthewAden MatthewAden commented Jul 20, 2024

Purpose of the pull request

This is a project for the OSPP 2024. This PR is close #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

Unit Test Results:

image

Pseudo-Cluster Deployment Status:

3081722177424_ pic
3091722177435_ pic

Cluster Test

Test conditions:
2 master nodes, 1 worker node
OS: mac
Steps:
Start node1, node2, and node3 in sequence

  • Be able to normally elect a Leader
  • When the Leader of the cluster crashes, be able to normally elect a new Leader
  • The original crashed Leader re-joins the cluster and is automatically downgraded to a Follower

Copy link

boring-cyborg bot commented Jul 20, 2024

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)

@MatthewAden MatthewAden changed the title [Feature-10874][registry]add raft registration plugin [Feature-10874][registry] add raft registration plugin Jul 21, 2024
Comment on lines 97 to 99
if (raftRegistryProperties.getModule().equals(MASTER_MODULE)) {
raftSubscribeDataManager.start();
}
Copy link
Member

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.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

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

done

Comment on lines 48 to 53
@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;
}
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

Copy link
Contributor

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

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Author

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.

Comment on lines 34 to 49
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;
Copy link
Member

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?

Copy link
Author

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?

Copy link
Author

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.

Comment on lines +575 to +591
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
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

@ruanwenjun ruanwenjun left a 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.

@MatthewAden
Copy link
Author

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.

@SbloodyS SbloodyS added the DSIP label Aug 30, 2024
@SbloodyS SbloodyS changed the title [Feature-10874][registry] add raft registration plugin [DSIP-9][registry] add raft registration plugin Aug 30, 2024
Copy link

sonarcloud bot commented Sep 13, 2024

Please retry analysis of this Pull-Request directly on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DSIP-9][Feature][Server] Add new registry plugin based on raft
4 participants