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: migrate the console to the naming server #7157

Merged
merged 19 commits into from
Feb 24, 2025

Conversation

funky-eyes
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@YongGoose
Copy link
Contributor

YongGoose commented Feb 11, 2025

@funky-eyes

If you're not planning to merge it right away, would it be okay if I take a look at the code and leave some comments?
Personally, I’m very interested in Spring. 🙂

@funky-eyes funky-eyes added this to the 2.4.0 milestone Feb 11, 2025
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/server server module module/console module/namingserver labels Feb 11, 2025
@funky-eyes
Copy link
Contributor Author

@funky-eyes

If you're not planning to merge it right away, would it be okay if I take a look at the code and leave some comments? Personally, I’m very interested in Spring. 🙂

Of course

Copy link
Contributor

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

Since I’m not familiar with the overall code of the namingserver module, my comment might not be helpful.

I’d appreciate it if you take it lightly.

Great work! 👍

Result<String> addGroupResult = namingManager.changeGroup(namespace, vGroup, clusterName, unitName);
if (!addGroupResult.isSuccess()) {
return addGroupResult;
}
return new Result<>("200", "change vGroup " + vGroup + "to cluster " + clusterName + " successfully!");
}

@GetMapping("/namespace")
public SingleResult<Map<String, NamespaceVO>> namespaces() {
Copy link
Contributor

Choose a reason for hiding this comment

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

DTO can be a good option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DTO can be a good option.

I think DTO is a transfer object and VO is a presentation object, so I used VO. Maybe my understanding is incorrect, please point it out.

Copy link
Contributor

@YongGoose YongGoose Feb 11, 2025

Choose a reason for hiding this comment

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

My intention was not to replace NamespaceVO with a DTO but rather to replace Map<String, NamespaceVO> with a DTO.

As you mentioned, DTO is meant for transferring data between layers, so I thought it would be appropriate.

I think this website could be helpful for our discussion.

Copy link
Contributor Author

@funky-eyes funky-eyes Feb 11, 2025

Choose a reason for hiding this comment

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

Since the controller layer does not perform any actions and the VO is the data that needs to be displayed on the front end, I believe it is sufficient to use Map<String, NamespaceVO> in the response. If we return a DTO to the controller side, the controller would need to convert it to VO, which I think is redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we return a DTO to the controller side, the controller would need to convert it to VO, which I think is redundant.

Thank you for your opinion.

If the controller layer simply returns what the service layer provides, the DTO might seem unnecessary. However, when transmitting complex objects, I believe using a DTO is appropriate.

Discussions about DTOs and VOs never seem to have a definitive answer. 😅

This time, I think it would be better to follow your suggestion and use a VO to avoid redundancy.

@@ -113,14 +115,18 @@ public Result<String> changeGroup(@RequestParam String namespace,
@RequestParam String clusterName,
@RequestParam String unitName,
@RequestParam String vGroup) {

Result<String> addGroupResult = namingManager.changeGroup(namespace, vGroup, clusterName, unitName);
if (!addGroupResult.isSuccess()) {
return addGroupResult;
}
return new Result<>("200", "change vGroup " + vGroup + "to cluster " + clusterName + " successfully!");
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the constants from Result.

Or how about creating a success API like SingleResult?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it is not within the scope of responsibility of the pr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but it is not within the scope of responsibility of the pr.

I’ll take care of this part.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 21.87500% with 100 lines in your changes missing coverage. Please review.

Project coverage is 52.09%. Comparing base (679a2e0) to head (a871bf0).
Report is 2 commits behind head on 2.x.

Files with missing lines Patch % Lines
...ata/namingserver/filter/ConsoleRemotingFilter.java 10.52% 51 Missing ⚠️
...ache/seata/namingserver/manager/NamingManager.java 0.00% 21 Missing ⚠️
...ingserver/filter/CachedBodyHttpServletRequest.java 0.00% 14 Missing ⚠️
...ache/seata/namingserver/entity/vo/NamespaceVO.java 0.00% 9 Missing ⚠️
...seata/server/console/param/GlobalSessionParam.java 25.00% 3 Missing ⚠️
...eata/namingserver/controller/NamingController.java 50.00% 1 Missing ⚠️
...onsole/impl/file/GlobalSessionFileServiceImpl.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #7157      +/-   ##
============================================
- Coverage     52.20%   52.09%   -0.11%     
- Complexity     6817     6856      +39     
============================================
  Files          1154     1169      +15     
  Lines         41116    41443     +327     
  Branches       4820     4847      +27     
============================================
+ Hits          21464    21591     +127     
- Misses        17611    17797     +186     
- Partials       2041     2055      +14     
Files with missing lines Coverage Δ
...he/seata/namingserver/NamingserverApplication.java 33.33% <ø> (ø)
...rg/apache/seata/namingserver/config/WebConfig.java 100.00% <100.00%> (ø)
...eata/namingserver/controller/NamingController.java 31.81% <50.00%> (-7.08%) ⬇️
...onsole/impl/file/GlobalSessionFileServiceImpl.java 77.77% <0.00%> (-4.58%) ⬇️
...seata/server/console/param/GlobalSessionParam.java 85.00% <25.00%> (-9.12%) ⬇️
...ache/seata/namingserver/entity/vo/NamespaceVO.java 0.00% <0.00%> (ø)
...ingserver/filter/CachedBodyHttpServletRequest.java 0.00% <0.00%> (ø)
...ache/seata/namingserver/manager/NamingManager.java 50.20% <0.00%> (-5.76%) ⬇️
...ata/namingserver/filter/ConsoleRemotingFilter.java 10.52% <10.52%> (ø)

... and 11 files with indirect coverage changes

@YongGoose
Copy link
Contributor

@funky-eyes

The Result object seemed to not effectively utilize the type received from the generic.
What do you think about this?

If you agree with my opinion, I will create an issue after resolving my current PR.

@funky-eyes
Copy link
Contributor Author

@funky-eyes

The Result object seemed to not effectively utilize the type received from the generic. What do you think about this?

If you agree with my opinion, I will create an issue after resolving my current PR.

I agree with you

if (xid !== undefined) {
const { xid,vgroup ,namespace,cluster} = query;
if (xid !== undefined && vgroup !== undefined) {
console.log('query:', query);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line used to debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I should delete it

}

@Bean
public FilterRegistrationBean<Filter> consoleRemotingFilter(NamingManager namingManager,
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the use of consoleRemotingFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used to route console requests to the corresponding seata server


String CONSOLE_PATTERN = "^/api/.*/console/.*";

int DEFAULT_REQUEST_TIMEOUT = 5000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this config can be set by user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this config can be set by user?

Theoretically, it's not necessary. I believe 5 seconds is already quite long, because the naming server and seata-server are on the same internal network, and since it's a paginated query, there isn't much data.

@slievrly slievrly self-assigned this Feb 18, 2025
Copy link
Contributor

@xjlgod xjlgod left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit d667466 into apache:2.x Feb 24, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/console module/namingserver module/server server module type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants