-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Conversation
…and TransactionInfo pages
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? |
Of course |
namingserver/src/main/java/org/apache/seata/namingserver/filter/ConsoleRemotingFilter.java
Fixed
Show fixed
Hide fixed
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.
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() { |
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.
DTO can be a good option.
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.
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.
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.
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.
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.
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.
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 we return a
DTO
to the controller side, the controller would need to convert it toVO
, 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.
namingserver/src/main/java/org/apache/seata/namingserver/config/WebConfig.java
Outdated
Show resolved
Hide resolved
namingserver/src/main/java/org/apache/seata/namingserver/config/WebConfig.java
Outdated
Show resolved
Hide resolved
namingserver/src/main/java/org/apache/seata/namingserver/controller/NamingController.java
Show resolved
Hide resolved
@@ -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!"); |
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.
You can use the constants from Result
.
public static final String SUCCESS_CODE = "200";
Or how about creating a success
API like SingleResult
?
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.
Yes, but it is not within the scope of responsibility of the pr.
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.
Yes, but it is not within the scope of responsibility of the pr.
I’ll take care of this part.
namingserver/src/main/java/org/apache/seata/namingserver/filter/ConsoleRemotingFilter.java
Outdated
Show resolved
Hide resolved
The If you agree with my opinion, I will create an issue after resolving my current |
I agree with you |
if (xid !== undefined) { | ||
const { xid,vgroup ,namespace,cluster} = query; | ||
if (xid !== undefined && vgroup !== undefined) { | ||
console.log('query:', query); |
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.
Is this line used to debug?
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.
Yes, I should delete it
} | ||
|
||
@Bean | ||
public FilterRegistrationBean<Filter> consoleRemotingFilter(NamingManager namingManager, |
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.
what is the use of consoleRemotingFilter
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.
It is used to route console requests to the corresponding seata server
console/src/main/resources/static/console-fe/src/pages/GlobalLockInfo/GlobalLockInfo.tsx
Outdated
Show resolved
Hide resolved
…ockInfo/GlobalLockInfo.tsx
|
||
String CONSOLE_PATTERN = "^/api/.*/console/.*"; | ||
|
||
int DEFAULT_REQUEST_TIMEOUT = 5000; |
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.
Should this config can be set by user?
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.
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.
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.
LGTM
Ⅰ. 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