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

optimize: support instance registration to the registry center #7089

Merged
merged 19 commits into from
Jan 3, 2025

Conversation

funky-eyes
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

support instance registration to the registry center
支持通过传递实例注册至注册中心,由于未来要扩展元数据,而先前注册时使用的InetSocketAddress入参已经不满足需求了,故进行修改为全局实例来满足该需求,后续可通过该实例中的metadata进行注册元数据至注册中心

Ⅱ. 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

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 51.11111% with 22 lines in your changes missing coverage. Please review.

Project coverage is 52.65%. Comparing base (61f420b) to head (32d4523).
Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...ache/seata/discovery/registry/RegistryService.java 0.00% 8 Missing ⚠️
...e/seata/server/instance/ServerInstanceFactory.java 74.07% 4 Missing and 3 partials ⚠️
.../namingserver/NamingserverRegistryServiceImpl.java 0.00% 4 Missing ⚠️
...che/seata/core/rpc/netty/NettyServerBootstrap.java 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #7089      +/-   ##
============================================
+ Coverage     52.60%   52.65%   +0.05%     
- Complexity     6686     6689       +3     
============================================
  Files          1132     1132              
  Lines         40290    40286       -4     
  Branches       4721     4724       +3     
============================================
+ Hits          21193    21214      +21     
+ Misses        17071    17041      -30     
- Partials       2026     2031       +5     
Files with missing lines Coverage Δ
...ava/org/apache/seata/common/metadata/Instance.java 79.24% <ø> (ø)
.../src/main/java/org/apache/seata/server/Server.java 71.87% <100.00%> (-0.86%) ⬇️
...ata/server/controller/VGroupMappingController.java 9.52% <ø> (ø)
...ge/db/store/DataBaseVGroupMappingStoreManager.java 6.25% <ø> (ø)
...ver/storage/db/store/VGroupMappingDataBaseDAO.java 0.00% <ø> (ø)
...ge/redis/store/RedisVGroupMappingStoreManager.java 71.87% <ø> (ø)
.../seata/server/store/VGroupMappingStoreManager.java 0.00% <ø> (ø)
...che/seata/core/rpc/netty/NettyServerBootstrap.java 59.55% <40.00%> (+0.45%) ⬆️
.../namingserver/NamingserverRegistryServiceImpl.java 0.00% <0.00%> (ø)
...e/seata/server/instance/ServerInstanceFactory.java 61.11% <74.07%> (ø)
... and 1 more

... and 4 files with indirect coverage changes

Copy link
Member

@xingfudeshi xingfudeshi 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 added this to the 2.4.0 milestone Jan 3, 2025
@funky-eyes funky-eyes merged commit 5b31862 into apache:2.x Jan 3, 2025
7 checks passed
NetUtil.validAddress(address);
Instance instance = Instance.getInstance();
instance.setTransaction(new Node.Endpoint(address.getAddress().getHostAddress(), address.getPort(), "netty"));
register(Instance.getInstance());
Copy link
Member

Choose a reason for hiding this comment

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

The IP address should be checked to ensure that it is not a loopback address.

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

https://github.com/apache/incubator-seata/pull/7089/files#diff-769bc40736ea7e87dd6b0dc2e3c5e04e5f1794d58dbf5e69aa21bb44082367baR161
Note that there may be vulnerabilities when deserializing, and the simple structure recommends serializing itself.

@@ -170,9 +172,13 @@ public void initChannel(SocketChannel ch) {
try {
this.serverBootstrap.bind(port).sync();
LOGGER.info("Server started, service listen port: {}", getListenPort());
InetSocketAddress address = new InetSocketAddress(XID.getIpAddress(), XID.getPort());
Instance instance = Instance.getInstance();
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 it makes sense for Instance to be designed as a singleton.

public class Instance {
private String namespace;
private String clusterName;
private String unit;
private Node.Endpoint control = new Node.Endpoint();
private Node.Endpoint transaction = new Node.Endpoint();
private Node.Endpoint control;
Copy link
Member

Choose a reason for hiding this comment

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

What is the specific meaning of Node.Endpoint control?

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

Successfully merging this pull request may close these issues.

3 participants