Skip to content

[improve-10506] [server] add MasterHeartBeat and WorkerHeartBeat to extend HeartBeat#10563

Closed
guoshupei wants to merge 12 commits intoapache:devfrom
guoshupei:Improvement-10506
Closed

[improve-10506] [server] add MasterHeartBeat and WorkerHeartBeat to extend HeartBeat#10563
guoshupei wants to merge 12 commits intoapache:devfrom
guoshupei:Improvement-10506

Conversation

@guoshupei
Copy link
Copy Markdown
Contributor

  • Add MasterHeartBeat to module of dolphinscheduler-master
  • Add WorkerHeartBeat to module of dolphinscheduler-worker

this closes #10506

@SbloodyS SbloodyS assigned SbloodyS and guoshupei and unassigned SbloodyS Jun 23, 2022
@SbloodyS SbloodyS added improvement make more easy to user or prompt friendly backend labels Jun 23, 2022
@SbloodyS SbloodyS added this to the 3.1.0-alpha milestone Jun 23, 2022
List<Server> serverList = new ArrayList<>();
for (Map.Entry<String, String> entry : serverMaps.entrySet()) {
HeartBeat heartBeat = HeartBeat.decodeHeartBeat(entry.getValue());
HeartBeatModel heartBeat = HeartBeatUtils.decodeHeartBeat(entry.getValue(), nodeType);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can make HeartBeatUtil.decodeHeartBeat return AbstractHeartBeat , then the HeartBeatModel can be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Worker fields are needed in some places. like host manager, Of course, it can also be obtained by split string of heartbeat ,but it is not graceful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You can make HeartBeatUtil.decodeHeartBeat return AbstractHeartBeat , then the HeartBeatModel can be removed.

When I designed WorkerHeartBeat and MasterHeartBeat, I have a dependency cycle problem, so I defined HeartBeatModel in module dolphinscheduler-common that contains all heartbeatInfo, which also avoids the need to hard code the worker's Heartbeat in the master, For example, the workWaitingTaskCount attribute is used in HostManager.

current design:
MasterHeartBeat in dolphinscheduler-master
WorkerHeartBeat in dolphinscheduler-worker
AbstractHeartBeat in dolphinscheduler-server (move into dolphinscheduler-common is also ok)
HeartBeatModel in dolphinscheduler-common

ps:
WorkerHeartBeat dependency injection WorkerManagerThread of dolphinscheduler-worker
HostWeight of dolphinscheduler-master use workWaitingTaskCount of WorkerHeartBeat

I don't have any good ideas right now. I need your help.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any problem if you remove the HeartBeatModel and only keep AbstractHeart/MasterHeartBeat/WorkHeartBeat ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When we get a HeartBeatInfo, we need to know this HeartBeatInfo is represent to worker or master, rather than use a big pojo to contains all fields. If we use a big pojo to represent the HeartBeatInfo, it's hard to know which field is available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

First, we need to reach a consensus that WorkerHeartBeat must autowared WorkerManagerThread in order to get WorkerWaitingTaskCount.

As you said,WorkerHeartBeat in common module, but worker module depend common module and WorkerManagerThread in worker module.
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WorkHeartBeat is just a pojo, it should not depend anything, if I have any misunderstand, please let me know.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The worker needs to update workWaitingTaskCount to report the heartbeat information.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, the worker will schedule a WorkerHeartbeatTask to update the info in WorkHeartBeat, there seems no problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have some questions to confirm.

    1. Do we need to define a WorkerHeartbeatTask ?
    1. What do you mean WorkerHeartbeatTask autowared WorkerManagerThread ?
    1. Which module is WorkerHeartbeatTask in ?

@guoshupei
Copy link
Copy Markdown
Contributor Author

guoshupei commented Jun 23, 2022 via email

Copy link
Copy Markdown
Contributor

@caishunfeng caishunfeng left a comment

Choose a reason for hiding this comment

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

LGTM overall

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 24, 2022

Codecov Report

Merging #10563 (b9bbc8a) into dev (393cb64) will increase coverage by 0.15%.
The diff coverage is 73.56%.

@@             Coverage Diff              @@
##                dev   #10563      +/-   ##
============================================
+ Coverage     40.92%   41.08%   +0.15%     
- Complexity     4874     4896      +22     
============================================
  Files           895      899       +4     
  Lines         36201    36242      +41     
  Branches       3986     3986              
============================================
+ Hits          14817    14889      +72     
+ Misses        19919    19890      -29     
+ Partials       1465     1463       -2     
Impacted Files Coverage Δ
.../org/apache/dolphinscheduler/common/Constants.java 81.81% <ø> (ø)
...server/master/dispatch/host/CommonHostManager.java 74.07% <0.00%> (ø)
...r/master/dispatch/host/LowerWeightHostManager.java 0.00% <0.00%> (ø)
...inscheduler/server/registry/AbstractHeartBeat.java 0.00% <0.00%> (ø)
...olphinscheduler/server/registry/HeartBeatTask.java 0.00% <0.00%> (ø)
...phinscheduler/service/registry/RegistryClient.java 0.79% <0.00%> (ø)
.../dolphinscheduler/common/utils/HeartBeatUtils.java 95.12% <95.12%> (ø)
...eduler/server/worker/registry/WorkerHeartBeat.java 95.23% <95.23%> (ø)
.../dolphinscheduler/common/model/HeartBeatModel.java 100.00% <100.00%> (ø)
...eduler/server/master/registry/MasterHeartBeat.java 100.00% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 393cb64...b9bbc8a. Read the comment docs.

@guoshupei guoshupei requested a review from caishunfeng June 24, 2022 13:17
@sonarqubecloud
Copy link
Copy Markdown

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 3 Code Smells

77.5% 77.5% Coverage
8.7% 8.7% Duplication

@guoshupei guoshupei requested a review from ruanwenjun June 25, 2022 03:13
@caishunfeng caishunfeng removed this from the 3.1.0 milestone Sep 27, 2022
@caishunfeng caishunfeng added this to the 3.2.0 milestone Sep 27, 2022
@caishunfeng
Copy link
Copy Markdown
Contributor

caishunfeng commented Feb 2, 2023

I close this pr because it had been implemented by #11702

@caishunfeng caishunfeng closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][Server] Refactor HeartBeatTask and HeartBeat

5 participants