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

[Feature][Registry] Support etcd as registry #10981

Merged
merged 43 commits into from
Sep 6, 2022

Conversation

wjf222
Copy link
Contributor

@wjf222 wjf222 commented Jul 15, 2022

Purpose of the pull request

Close #8975

Brief change log

Add CRUD
Add Subscribe
Add Lock
Add ConnectStateListener

Verify this pull request

This change added tests and can be verified as follows:
Add persistTest to test for CRUD
Add lockTest for lock

TODO add connectStateListener Test

Comment on lines 25 to 26
private Long retryDelay=60L;
private Long retryMaxDelay=300L;
Copy link
Member

Choose a reason for hiding this comment

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

Consider also using Duration type, and format the codes please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The time unit for these two parameters is set by the ChronUnitRetry in jetcd. The type of these two parameters is long, but the type of retryMaxDuration is Duration.

You can see the reference of these three parameters in EtcdRegistry.java line 51 to 54.

Copy link
Member

Choose a reason for hiding this comment

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

The time unit for these two parameters is set by the ChronUnitRetry in jetcd. The type of these two parameters is long, but the type of retryMaxDuration is Duration.

You can see the reference of these three parameters in EtcdRegistry.java line 51 to 54.

Hi, you don't have to just copy the type from JETCD client, using Duration as type in our own configurations is for users' convenient, they can just set something like 1s, 500ms, without knowing what's the time unit of the config. Also, users don't care what types we pass into EtcdRegistry.java, let's provide simplicity to users

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The time unit for these two parameters is set by the ChronUnitRetry in jetcd. The type of these two parameters is long, but the type of retryMaxDuration is Duration.
You can see the reference of these three parameters in EtcdRegistry.java line 51 to 54.

Hi, you don't have to just copy the type from JETCD client, using Duration as type in our own configurations is for users' convenient, they can just set something like 1s, 500ms, without knowing what's the time unit of the config. Also, users don't care what types we pass into EtcdRegistry.java, let's provide simplicity to users

You are right,I fix this in Modify the type of delay

// RetryPolicy
private Long retryDelay=60L;
private Long retryMaxDelay=300L;
private Duration retryMaxDuration=Duration.ofMillis(1500);;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private Duration retryMaxDuration=Duration.ofMillis(1500);;
private Duration retryMaxDuration=Duration.ofMillis(1500);

Comment on lines 33 to 36
<dependency>
<groupId>io.etcd</groupId>
<artifactId>jetcd-test</artifactId>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

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

This should be test scope

Comment on lines 14 to 17
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
Copy link
Member

Choose a reason for hiding this comment

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

Don't set this here


# How to use

If you want to set the registry center as mysql,You need to set the registry properties in master/worker/api's appplication.yml
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If you want to set the registry center as mysql,You need to set the registry properties in master/worker/api's appplication.yml
If you want to set the registry center as mysql, you need to set the registry properties in master/worker/api's appplication.yml

Comment on lines 25 to 26
private Long retryDelay=60L;
private Long retryMaxDelay=300L;
Copy link
Member

Choose a reason for hiding this comment

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

The time unit for these two parameters is set by the ChronUnitRetry in jetcd. The type of these two parameters is long, but the type of retryMaxDuration is Duration.

You can see the reference of these three parameters in EtcdRegistry.java line 51 to 54.

Hi, you don't have to just copy the type from JETCD client, using Duration as type in our own configurations is for users' convenient, they can just set something like 1s, 500ms, without knowing what's the time unit of the config. Also, users don't care what types we pass into EtcdRegistry.java, let's provide simplicity to users

public void put(String key, String value, boolean deleteOnDisconnect) {
try{
if(deleteOnDisconnect) {
// keep the key by lease, if disconnected, the lease will ,the key will delete
Copy link
Member

Choose a reason for hiding this comment

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

This sentence is not complete...

Comment on lines 60 to 73
try {
Field connectField =client.getClass().getDeclaredField("connectManager");
if(!connectField.isAccessible()){
connectField.setAccessible(true);
}
Object connection = connectField.get(client);
Method channel = connection.getClass().getDeclaredMethod("getChannel");
if (!channel.isAccessible()) {
channel.setAccessible(true);
}
return (ManagedChannel) channel.invoke(connection);
} catch (Exception e) {
throw new RegistryException("Failed to get the etcd client channel", e);
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a good way to implement the connectivity state listener, why do you choose to use reflection instead of some native method of jetcd client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will try to use keepalive in lease client to listen for connection status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is a good way to implement the connectivity state listener, why do you choose to use reflection instead of some native method of jetcd client?

I made the problem complicated. I only need to periodically try to connect to Etcd, and the connection status can be judged by the connection result.
I have removed the reflection related code. Now, i use the client to apply for a lease to determine whether the connection is successful in Using the lease to listen connection state

@kezhenxu94
Copy link
Member

Many files are missing license headers

@caishunfeng
Copy link
Contributor

Hi @wjf222 please add the doc of the registry together.

@github-actions github-actions bot removed the document label Jul 15, 2022
@wjf222
Copy link
Contributor Author

wjf222 commented Jul 15, 2022

Many files are missing license headers

I fixed this in the Add license header

@wjf222
Copy link
Contributor Author

wjf222 commented Jul 15, 2022

Hi @wjf222 please add the doc of the registry together.

I add the doc in [Document] Add readme and comments.Do you need to add other documents here?

@wjf222
Copy link
Contributor Author

wjf222 commented Aug 14, 2022

@kezhenxu94 @caishunfeng @ruanwenjun Please help continue to review. Thank you very much

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

Generally looks good to me, please fix conflict

wjf222 and others added 3 commits August 16, 2022 19:36
…lphinscheduler-registry-etcd/src/main/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistry.java

Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
…lphinscheduler-registry-etcd/src/main/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdConnectionStateListener.java

Co-authored-by: kezhenxu94 <kezhenxu94@apache.org>
@wjf222
Copy link
Contributor Author

wjf222 commented Aug 17, 2022

Generally looks good to me, please fix conflict

@kezhenxu94 Thanks, I have fixed the conflict

kezhenxu94
kezhenxu94 previously approved these changes Aug 17, 2022
@caishunfeng
Copy link
Contributor

@wjf222 Please fix the conflicts.

@wjf222
Copy link
Contributor Author

wjf222 commented Aug 23, 2022

Thanks, I have fixed the conflict

@caishunfeng I have fixed the conflict. Test bugs are due to new 3rd party packages introduced in other commits

@wjf222
Copy link
Contributor Author

wjf222 commented Aug 25, 2022

@caishunfeng Please pass the review, I have fixed the conflict. Thank you.

@wjf222
Copy link
Contributor Author

wjf222 commented Aug 29, 2022

@kezhenxu94 @caishunfeng @ruanwenjun Due to previous conflicts, modifications have been made, and I hope to pass this review again. Thank you very much.

@ruanwenjun
Copy link
Member

@wjf222 Please resolve the dependency check failure.

@sonarcloud
Copy link

sonarcloud bot commented Aug 31, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

44.8% 44.8% Coverage
2.0% 2.0% Duplication

@wjf222
Copy link
Contributor Author

wjf222 commented Aug 31, 2022

@wjf222 Please resolve the dependency check failure.

@ruanwenjun I have fixed the conflict. Thank you.

@wjf222
Copy link
Contributor Author

wjf222 commented Sep 3, 2022

@kezhenxu94 @caishunfeng @ruanwenjun I have passed the test.Please apprve the review.Thank you.

1 similar comment
@wjf222
Copy link
Contributor Author

wjf222 commented Sep 5, 2022

@kezhenxu94 @caishunfeng @ruanwenjun I have passed the test.Please apprve the review.Thank you.

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.

LGTM, I will merged this to dev branch, and this feature will be released at 3.1.0, thanks for your contribution. @wjf222

@ruanwenjun ruanwenjun merged commit 2eb8b9f into apache:dev Sep 6, 2022
fengjian1129 pushed a commit to fengjian1129/dolphinscheduler that referenced this pull request Sep 13, 2022
ruanwenjun pushed a commit to ruanwenjun/dolphinscheduler that referenced this pull request Sep 16, 2022
caishunfeng pushed a commit that referenced this pull request Sep 17, 2022
(cherry picked from commit 2eb8b9f)

Co-authored-by: wjf <jffwang@qq.com>
@caishunfeng caishunfeng added the release cherry-pick Mark this issue/PR had cherry-pick for release version label Sep 17, 2022
fengjian1129 pushed a commit to fengjian1129/dolphinscheduler that referenced this pull request Sep 29, 2022
xdu-chenrj pushed a commit to xdu-chenrj/dolphinscheduler that referenced this pull request Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend gsoc release cherry-pick Mark this issue/PR had cherry-pick for release version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DSIP-17][Feature][Registry] Support etcd as registry
6 participants