-
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
optimize: support instance registration to the registry center #7089
Conversation
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
NetUtil.validAddress(address); | ||
Instance instance = Instance.getInstance(); | ||
instance.setTransaction(new Node.Endpoint(address.getAddress().getHostAddress(), address.getPort(), "netty")); | ||
register(Instance.getInstance()); |
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.
The IP address should be checked to ensure that it is not a loopback address.
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.
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(); |
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.
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; |
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 specific meaning of Node.Endpoint control
?
Ⅰ. 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