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: Raft mode supports access outside the cluster #7069

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

PeppaO
Copy link
Contributor

@PeppaO PeppaO commented Dec 23, 2024

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

现有raft sdk如果在k8s环境下,客户端集群外访问,无法通过域名方式链接raft node,造成无法通信。

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

@funky-eyes funky-eyes added this to the 2.4.0 milestone Dec 23, 2024
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/discovery discovery module module/server server module store: raft labels Dec 23, 2024

private static InetSocketAddress selectEndpoint(String type, Node node) {
if (StringUtils.isBlank(PREFERRED_NETWORKS)) {
// 采取默认的方式,直接使用node.control node.transaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 采取默认的方式,直接使用node.control node.transaction
// Use the default method, directly using node.control and node.transaction

@@ -366,7 +366,7 @@ public RaftClusterMetadata changeOrInitRaftClusterMetadata() {
Integer.parseInt(
((Environment)ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT))
.getProperty("server.port", String.valueOf(7091))),
group, Collections.emptyMap());
group, new HashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change to new HashMap < > ()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

因为Collections.emptyMap()返回的集合使用了final修饰,导致我进行put操作时,报错,unsupoort...

@@ -406,7 +406,7 @@ private void syncCurrentNodeInfo(PeerId leaderPeerId) {
Integer.parseInt(
((Environment)ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT))
.getProperty("server.port", String.valueOf(7091))),
group, Collections.emptyMap());
group, new HashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same

@@ -55,6 +58,10 @@ public Node createNode(String host, int txPort, int internalPort, int controlPor
node.setGroup(group);
node.setVersion(Version.getCurrent());
node.setInternal(node.createEndpoint(host, internalPort, "raft"));
String serverRegistryMetadataExternalValue = System.getProperty("SERVER_REGISTRY_METADATA_EXTERNAL_VALUE");
Copy link
Contributor

Choose a reason for hiding this comment

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

不应该这样读取,如果有用户直接使用properties配置文件去配置怎么办?应该通过下面这样的方式读取
It should not be read like this. What if a user directly uses the properties configuration file to configure it? It should be read in the following way

ConfigurableEnvironment environment=ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT);
environment.resolvePlaceholders("${seata.registry.metadata.external:${registry.metadata.external:}}")

Comment on lines +302 to +316
private static String selectTransactionEndpointStr(Node node) {
InetSocketAddress transaction = selectTransactionEndpoint( node);
return NetUtil.toStringAddress(transaction);
}

private static InetSocketAddress selectControlEndpoint(Node node) {
return selectEndpoint("control", node);
}

private static InetSocketAddress selectTransactionEndpoint(Node node) {
return selectEndpoint("transaction", node);
}

private static InetSocketAddress selectEndpoint(String type, Node node) {
if (StringUtils.isBlank(PREFERRED_NETWORKS)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

请增加这些方法的测试用例
Please add test cases for these methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/discovery discovery module module/server server module store: raft type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants