Skip to content

Commit

Permalink
Merge branch '2.x' into feature-fury-serialize
Browse files Browse the repository at this point in the history
# Conflicts:
#	changes/en-us/2.x.md
#	changes/zh-cn/2.x.md
  • Loading branch information
GoodBoyCoder committed Jan 3, 2025
2 parents 65922de + 5b31862 commit ccaf454
Show file tree
Hide file tree
Showing 38 changed files with 604 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ 2.x, develop, master ]

jobs:
# job 1: Test based on java 8 and 17. Do not checkstyle.
# job 1: Test based on java 8, 17 and 21. Do not checkstyle.
build:
name: "build"
services:
Expand All @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 8, 17 ]
java: [ 8, 17, 21 ]
steps:
# step 1
- name: "Checkout"
Expand Down
9 changes: 8 additions & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Add changes here for all PR submitted to the 2.x branch.

### feature:

- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] support fury undolog parser
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft cluster mode supports address translation
- [[#7038](https://github.com/apache/incubator-seata/pull/7038)] support fury serializer

### bugfix:
Expand All @@ -15,14 +17,16 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6828](https://github.com/apache/incubator-seata/pull/6828)] spring boot compatible with file.conf and registry.conf
- [[#7012](https://github.com/apache/incubator-seata/pull/7012)] When the number of primary keys exceeds 1000, use union to concatenate the SQL
- [[#7075](https://github.com/apache/incubator-seata/pull/7075)] fast fail when channel is null
- [[#7089](https://github.com/apache/incubator-seata/pull/7089)] support instance registration to the registry center
- [[#7093](https://github.com/apache/incubator-seata/pull/7093)] add a test workflow for JDK 21

### security:

- [[#PR_NO](https://github.com/apache/incubator-seata/pull/PR_NO)] upgrade XXX

### test:

- [[#PR_NO](https://github.com/apache/incubator-seata/pull/PR_NO)] test XXX
- [[#7092](https://github.com/apache/incubator-seata/pull/7092)] fix the issue of NacosMockTest failing to run

### refactor:

Expand All @@ -36,5 +40,8 @@ Thanks to these contributors for their code commits. Please report an unintended
- [lyl2008dsg](https://github.com/lyl2008dsg)
- [remind](https://github.com/remind)
- [GoodBoyCoder](https://github.com/GoodBoyCoder)
- [PeppaO](https://github.com/PeppaO)
- [funky-eyes](https://github.com/funky-eyes)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
8 changes: 7 additions & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### feature:

- [[#7037](https://github.com/apache/incubator-seata/pull/7037)] 支持UndoLog的fury序列化方式
- [[#7069](https://github.com/apache/incubator-seata/pull/7069)] Raft集群模式支持地址转换
- [[#7038](https://github.com/apache/incubator-seata/pull/7038)] 支持Fury序列化器

### bugfix:
Expand All @@ -15,14 +17,16 @@
- [[#6828](https://github.com/apache/incubator-seata/pull/6828)] seata-spring-boot-starter兼容file.conf和registry.conf
- [[#7012](https://github.com/apache/incubator-seata/pull/7012)] 当主键超过1000个时,使用union拼接sql,可以使用索引
- [[#7075](https://github.com/apache/incubator-seata/pull/7075)] 当channel为空时,快速失败,以便于减少不必要的等待
- [[#7089](https://github.com/apache/incubator-seata/pull/7089)] 新增instance注册到注册中心的接口
- [[#7093](https://github.com/apache/incubator-seata/pull/7093)] 增加jdk21的工作流测试

### security:

- [[#PR_NO](https://github.com/apache/incubator-seata/pull/PR_NO)] 升级XXX

### test:

- [[#PR_NO](https://github.com/apache/incubator-seata/pull/PR_NO)] 测试XXX
- [[#7092](https://github.com/apache/incubator-seata/pull/7092)] 修复NacosMockTest测试方法并行导致测试结果被干扰失败的问题

### refactor:

Expand All @@ -36,5 +40,7 @@
- [lyl2008dsg](https://github.com/lyl2008dsg)
- [remind](https://github.com/remind)
- [GoodBoyCoder](https://github.com/GoodBoyCoder)
- [PeppaO](https://github.com/PeppaO)
- [funky-eyes](https://github.com/funky-eyes)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -1110,4 +1110,15 @@ public interface ConfigurationKeys {
* The constant META_PREFIX
*/
String META_PREFIX = SEATA_FILE_ROOT_CONFIG + FILE_CONFIG_SPLIT_CHAR + FILE_ROOT_REGISTRY + FILE_CONFIG_SPLIT_CHAR + "metadata.";

/**
* The constant SERVER_REGISTRY_METADATA_PREFIX
*/
String SERVER_REGISTRY_METADATA_PREFIX = SERVER_PREFIX + FILE_ROOT_REGISTRY + ".metadata";

/**
* The constant SERVER_REGISTRY_METADATA_EXTERNAL
*/
String SERVER_REGISTRY_METADATA_EXTERNAL = SERVER_REGISTRY_METADATA_PREFIX + ".external";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.common.exception;

public class ParseEndpointException extends RuntimeException {
public ParseEndpointException() {
}

public ParseEndpointException(String message) {
super(message);
}

public ParseEndpointException(String message, Throwable cause) {
super(message, cause);
}

public ParseEndpointException(Throwable cause) {
super(cause);
}

public ParseEndpointException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.common.metadata.namingserver;
package org.apache.seata.common.metadata;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.seata.common.metadata.ClusterRole;
import org.apache.seata.common.metadata.Node;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import static org.apache.seata.common.util.CollectionUtils.mapToJsonString;


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;
private Node.Endpoint transaction;
private double weight = 1.0;
private boolean healthy = true;
private long term;
Expand Down Expand Up @@ -169,25 +164,6 @@ public String toJsonString(ObjectMapper objectMapper) {
}
}


public Map<String, String> toMap() {
Map<String, String> resultMap = new HashMap<>();


resultMap.put("namespace", namespace);
resultMap.put("clusterName", clusterName);
resultMap.put("unit", unit);
resultMap.put("control", control.toString());
resultMap.put("transaction", transaction.toString());
resultMap.put("weight", String.valueOf(weight));
resultMap.put("healthy", String.valueOf(healthy));
resultMap.put("term", String.valueOf(term));
resultMap.put("timestamp", String.valueOf(timestamp));
resultMap.put("metadata", mapToJsonString(metadata));

return resultMap;
}

private static class SingletonHolder {
private static final Instance SERVER_INSTANCE = new Instance();
}
Expand Down
86 changes: 84 additions & 2 deletions common/src/main/java/org/apache/seata/common/metadata/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.seata.common.exception.ParseEndpointException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import java.util.List;
import java.util.ArrayList;

public class Node {

Expand Down Expand Up @@ -195,4 +196,85 @@ public String toString() {
}
}

private Node.ExternalEndpoint createExternalEndpoint(String host, int controllerPort, int transactionPort) {
return new Node.ExternalEndpoint(host, controllerPort, transactionPort);
}

public List<ExternalEndpoint> createExternalEndpoints(String external) {
List<Node.ExternalEndpoint> externalEndpoints = new ArrayList<>();
String[] split = external.split(",");

for (String s : split) {
String[] item = s.split(":");
if (item.length == 3) {
try {
String host = item[0];
int controllerPort = Integer.parseInt(item[1]);
int transactionPort = Integer.parseInt(item[2]);
externalEndpoints.add(createExternalEndpoint(host, controllerPort, transactionPort));
} catch (NumberFormatException e) {
throw new ParseEndpointException("Invalid port number in: " + s);
}
} else {
throw new ParseEndpointException("Invalid format for endpoint: " + s);
}
}
return externalEndpoints;
}

public Map<String, Object> updateMetadataWithExternalEndpoints(Map<String, Object> metadata, List<Node.ExternalEndpoint> externalEndpoints) {
Object obj = metadata.get("external");
if (obj == null) {
if (!externalEndpoints.isEmpty()) {
Map<String, Object> metadataMap = new HashMap<>(metadata);
metadataMap.put("external", externalEndpoints);
return metadataMap;
}
return metadata;
}
if (obj instanceof List) {
List<Node.ExternalEndpoint> oldList = (List<Node.ExternalEndpoint>) obj;
oldList.addAll(externalEndpoints);
return metadata;
} else {
throw new ParseEndpointException("Metadata 'external' is not a List.");
}
}

public static class ExternalEndpoint {

private String host;
private int controlPort;
private int transactionPort;

public ExternalEndpoint(String host, int controlPort, int transactionPort) {
this.host = host;
this.controlPort = controlPort;
this.transactionPort = transactionPort;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public int getControlPort() {
return controlPort;
}

public void setControlPort(int controlPort) {
this.controlPort = controlPort;
}

public int getTransactionPort() {
return transactionPort;
}

public void setTransactionPort(int transactionPort) {
this.transactionPort = transactionPort;
}
}
}
16 changes: 16 additions & 0 deletions common/src/main/java/org/apache/seata/common/util/NetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,25 @@ public static String toIpAddress(SocketAddress address) {
* @return the string
*/
public static String toStringAddress(InetSocketAddress address) {
if (address.getAddress() == null) {
return address.getHostString() + ":" + address.getPort();
}
return address.getAddress().getHostAddress() + ":" + address.getPort();
}

/**
* To string host string.
*
* @param address the address
* @return the string
*/
public static String toStringHost(InetSocketAddress address) {
if (address.getAddress() == null) {
return address.getHostString();
}
return address.getAddress().getHostAddress();
}

/**
* To inet socket address inet socket address.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.seata.common.metadata.ClusterRole;
import org.apache.seata.common.metadata.Instance;
import org.apache.seata.common.metadata.Node;
import org.junit.jupiter.api.Test;

Expand Down
Loading

0 comments on commit ccaf454

Please sign in to comment.