Skip to content

Commit

Permalink
Merge branch '2.x' into feature/2.x-saga-test
Browse files Browse the repository at this point in the history
  • Loading branch information
xjlgod authored May 16, 2024
2 parents ec867ea + ec47baa commit 78e3996
Show file tree
Hide file tree
Showing 13 changed files with 1,061 additions and 321 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: "test"
on:
push:
branches: [ test*, "*.*.*" ]

jobs:
# job 1
test:
Expand Down Expand Up @@ -43,12 +42,11 @@ jobs:
- name: "Test with Maven on '${{ matrix.os }}' OS"
if: matrix.os != 'windows'
run: |
./mvnw -version;
./mvnw -T 4C clean test \
-P args-for-client-test \
-Dspring-boot.version=${{ matrix.springboot }} \
-Dmaven.git-commit-id.skip=true \
-e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
if [ "${{ matrix.os }}" == "macos" ]; then
./mvnw -T 4C clean test -P args-for-client-test -P arrch64 -Dspring-boot.version=${{ matrix.springboot }} -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
else
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
fi
## step 3.2: for Windows
- name: "Build with Maven on 'windows' OS (Skip tests)"
if: matrix.os == 'windows'
Expand Down Expand Up @@ -89,12 +87,11 @@ jobs:
- name: "Test with Maven on '${{ matrix.os }}' OS"
if: matrix.os != 'windows'
run: |
./mvnw -version;
./mvnw -T 4C clean install \
-P args-for-client-test \
-Dspring-boot.version=${{ matrix.springboot }} \
-Dmaven.git-commit-id.skip=true \
-e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
if [ "${{ matrix.os }}" == "macos" ]; then
./mvnw -T 4C clean test -P args-for-client-test -P arrch64 -Dspring-boot.version=${{ matrix.springboot }} -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
else
./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
fi
## step 3.2: for Windows
- name: "Build with Maven on 'windows' OS (Skip tests)"
if: matrix.os == 'windows'
Expand Down
926 changes: 922 additions & 4 deletions LICENSE

Large diffs are not rendered by default.

39 changes: 5 additions & 34 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>19</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.seata</groupId>
<artifactId>seata-build</artifactId>
<packaging>pom</packaging>
Expand Down Expand Up @@ -133,9 +137,6 @@
<maven.git-commit-id.skip>false</maven.git-commit-id.skip>
<maven.surefire.argLine></maven.surefire.argLine>
<maven.surefire.excludes></maven.surefire.excludes>
<gpg.keyname>37F181C60AACE24BD5C1D3925583F79497E8E293</gpg.keyname>
<gpg.arg1/>
<gpg.arg2/>

<!-- For docker image-->
<image.publish.skip>true</image.publish.skip>
Expand Down Expand Up @@ -372,18 +373,6 @@
</execution>
</executions>
</plugin>
<!-- Staging -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>oss_seata</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -396,29 +385,11 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>${gpg.keyname}</keyname>
<gpgArguments>
<arg>${gpg.arg1}</arg>
<arg>${gpg.arg2}</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- distribution management -->
<distributionManagement>
<repository>
<id>oss_seata</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>oss_seata</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>

<!-- profile: release-by-github-actions -->
Expand Down
7 changes: 7 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6405](https://github.com/apache/incubator-seata/pull/6405)] fix kotlin compile failure
- [[#6412](https://github.com/apache/incubator-seata/pull/6412)] optimize core compatible module
- [[#6429](https://github.com/apache/incubator-seata/pull/6429)] remove repetitive words
- [[#6518](https://github.com/apache/incubator-seata/pull/6518)] optimize ConfigurationCache proxy method
- [[#6458](https://github.com/apache/incubator-seata/pull/6458)] add null value check for MAC address
- [[#6516](https://github.com/apache/incubator-seata/pull/6516)] optimize code format
- [[#6529](https://github.com/apache/incubator-seata/pull/6529)] optimize release maven plugin
- [[#6548](https://github.com/apache/incubator-seata/pull/6548)] upgrade the byte-buddy version to 1.14.15
- [[#6539](https://github.com/apache/incubator-seata/pull/6539)] add subcomponents license
- [[#6540](https://github.com/apache/incubator-seata/pull/6540)] exclude com.google.guava:listenablefuture
- [[#6549](https://github.com/apache/incubator-seata/pull/6549)] macos workflow support arm testing

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities
Expand All @@ -153,6 +159,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6466](https://github.com/apache/incubator-seata/pull/6466)] support redis integration testing
- [[#6484](https://github.com/apache/incubator-seata/pull/6484)] fix FileConfigurationTest and MockServerTest fail
- [[#6519](https://github.com/apache/incubator-seata/pull/6484)] 增加saga模块的测试用例覆盖率
- [[#6545](https://github.com/apache/incubator-seata/pull/6545)] fix TestConfigCustomSPI compatibility test fail

### refactor:
- [[#6280](https://github.com/apache/incubator-seata/pull/6280)] refactor Saga designer using diagram-js
Expand Down
7 changes: 7 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
- [[#6429](https://github.com/apache/incubator-seata/pull/6429)] 移除重复注释
- [[#6405](https://github.com/apache/incubator-seata/pull/6405)] 修复 kotlin 编译失败
- [[#6412](https://github.com/apache/incubator-seata/pull/6412)] 优化 core 兼容模块
- [[#6518](https://github.com/apache/incubator-seata/pull/6518)] 优化 ConfigurationCache 代理方法
- [[#6529](https://github.com/apache/incubator-seata/pull/6529)] 优化发布插件
- [[#6548](https://github.com/apache/incubator-seata/pull/6548)] 升级byte-buddy版本至1.14.15
- [[#6539](https://github.com/apache/incubator-seata/pull/6539)] 增加组件 license
- [[#6540](https://github.com/apache/incubator-seata/pull/6540)] 排除 com.google.guava:listenablefuture 依赖
- [[#6549](https://github.com/apache/incubator-seata/pull/6549)] 支持macos arm架构单测

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
Expand All @@ -150,6 +156,7 @@
- [[#6466](https://github.com/apache/incubator-seata/pull/6466)] 支持redis的集成测试
- [[#6484](https://github.com/apache/incubator-seata/pull/6484)] 修复FileConfigurationTest和MockServerTest失败
- [[#6519](https://github.com/apache/incubator-seata/pull/6484)] 增加saga模块的测试用例覆盖率
- [[#6545](https://github.com/apache/incubator-seata/pull/6545)] 修复 TestConfigCustomSPI 兼容性测试失败

### refactor:
- [[#6280](https://github.com/apache/incubator-seata/pull/6280)] 使用diagram-js重构Saga设计器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.seata.config;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -31,10 +32,9 @@
*/
public class ConfigurationCache implements ConfigurationChangeListener {

private static final String METHOD_PREFIX = "get";

private static final String METHOD_LATEST_CONFIG = METHOD_PREFIX + "LatestConfig";
private static final String PROXY_METHOD_PREFIX = "get";

private static final String[] NOT_PROXY_METHOD_NAMES = new String[] {PROXY_METHOD_PREFIX + "LatestConfig", PROXY_METHOD_PREFIX + "ConfigListeners"};
private static final Map<String, ObjectWrapper> CONFIG_CACHE = new ConcurrentHashMap<>();

private static final Set<String> DATA_ID_CACHED = new HashSet<>();
Expand Down Expand Up @@ -72,12 +72,11 @@ public void onChangeEvent(ConfigurationChangeEvent event) {
public Configuration proxy(Configuration originalConfiguration) throws Exception {
return (Configuration)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Configuration.class}
, (proxy, method, args) -> {
String methodName = method.getName();
if (methodName.startsWith(METHOD_PREFIX) && !methodName.equalsIgnoreCase(METHOD_LATEST_CONFIG)) {
if (isProxyTargetMethod(method)) {
String rawDataId = (String)args[0];
ObjectWrapper wrapper = CONFIG_CACHE.get(rawDataId);
ObjectWrapper.ConfigType type =
ObjectWrapper.getTypeByName(methodName.substring(METHOD_PREFIX.length()));
ObjectWrapper.getTypeByName(method.getName().substring(PROXY_METHOD_PREFIX.length()));
Object defaultValue = null;
if (args.length > 1
&& method.getParameterTypes()[1].getSimpleName().equalsIgnoreCase(type.name())) {
Expand All @@ -102,6 +101,19 @@ public Configuration proxy(Configuration originalConfiguration) throws Exception
);
}

private boolean isProxyTargetMethod(Method method) {
String methodName = method.getName();
if (!methodName.startsWith(PROXY_METHOD_PREFIX)) {
return false;
}
for (String name : NOT_PROXY_METHOD_NAMES) {
if (methodName.equalsIgnoreCase(name)) {
return false;
}
}
return true;
}

private static class ConfigurationCacheInstance {
private static final ConfigurationCache INSTANCE = new ConfigurationCache();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ private static Configuration buildConfiguration() {
if (null != configurationCache) {
extConfiguration = configurationCache;
}
} catch (EnhancedServiceNotFoundException ignore) {

} catch (Exception e) {
LOGGER.error("failed to load configurationCacheProvider:{}", e.getMessage(), e);
}
Expand Down Expand Up @@ -225,7 +223,7 @@ private static Configuration getNonSpringConfiguration(String configTypeName) {
return null;
}

protected static void reload() {
public static void reload() {
ConfigurationCache.clear();
initOriginConfiguraction();
load();
Expand Down Expand Up @@ -298,13 +296,15 @@ private ConfigurationChangeEvent convert(io.seata.config.ConfigurationChangeEven
ConfigurationChangeEvent newEvent = new ConfigurationChangeEvent();
newEvent.setDataId(event.getDataId()).setOldValue(event.getOldValue()).setNewValue(event.getNewValue())
.setNamespace(event.getNamespace());
newEvent.setChangeType(ConfigurationChangeType.values()[event.getChangeType().ordinal()]);
if (event.getChangeType() != null) {
newEvent.setChangeType(ConfigurationChangeType.values()[event.getChangeType().ordinal()]);
}
return newEvent;
}

@Override
public void onChangeEvent(io.seata.config.ConfigurationChangeEvent event) {
listener.onChangeEvent(convert(event));
onProcessEvent(event);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
Expand Down Expand Up @@ -198,7 +200,7 @@ public Set<ConfigurationChangeListener> getConfigListeners(String dataId) {
}
}

private static Properties getConfigProperties() {
protected static Properties getConfigProperties() {
Properties properties = new Properties();
properties.setProperty(ConfigurationKeys.IS_USE_CLOUD_NAMESPACE_PARSING, USE_PARSE_RULE);
properties.setProperty(ConfigurationKeys.IS_USE_ENDPOINT_PARSING_RULE, USE_PARSE_RULE);
Expand Down Expand Up @@ -278,7 +280,6 @@ public String getTypeName() {
* Non-blocking subscriptions prohibit adding subscriptions in the thread pool to prevent thread termination
*/
public static class NacosListener extends AbstractSharedListener {
private final String dataId;
private final ConfigurationChangeListener listener;

/**
Expand All @@ -288,7 +289,6 @@ public static class NacosListener extends AbstractSharedListener {
* @param listener the listener
*/
public NacosListener(String dataId, ConfigurationChangeListener listener) {
this.dataId = dataId;
this.listener = listener;
}

Expand All @@ -303,42 +303,45 @@ public ConfigurationChangeListener getTargetListener() {

@Override
public void innerReceive(String dataId, String group, String configInfo) {
//The new configuration method to puts all configurations into a dateId
if (getNacosDataId().equals(dataId)) {
Properties seataConfigNew = new Properties();
if (StringUtils.isNotBlank(configInfo)) {
try {
seataConfigNew = ConfigProcessor.processConfig(configInfo, getNacosDataType());
} catch (IOException e) {
LOGGER.error("load config properties error", e);
return;
try {
//The new configuration method to puts all configurations into a dateId
if (getNacosDataId().equals(dataId)) {
Properties seataConfigNew = new Properties();
if (StringUtils.isNotBlank(configInfo)) {
try {
seataConfigNew = ConfigProcessor.processConfig(configInfo, getNacosDataType());
} catch (IOException e) {
LOGGER.error("load config properties error", e);
return;
}
}
}

//Get all the monitored dataids and judge whether it has been modified
for (Map.Entry<String, ConcurrentMap<ConfigurationChangeListener, NacosListener>> entry :
CONFIG_LISTENERS_MAP.entrySet()) {
String listenedDataId = entry.getKey();
String propertyOld = seataConfig.getProperty(listenedDataId, "");
String propertyNew = seataConfigNew.getProperty(listenedDataId, "");
if (!propertyOld.equals(propertyNew)) {
ConfigurationChangeEvent event = new ConfigurationChangeEvent().setDataId(listenedDataId)
.setNewValue(propertyNew).setNamespace(group);

ConcurrentMap<ConfigurationChangeListener, NacosListener> configListeners = entry.getValue();
for (ConfigurationChangeListener configListener : configListeners.keySet()) {
configListener.onProcessEvent(event);
//Get all the monitored dataids and judge whether it has been modified
for (Map.Entry<String, ConcurrentMap<ConfigurationChangeListener, NacosListener>> entry : CONFIG_LISTENERS_MAP.entrySet()) {
String listenedDataId = entry.getKey();
String propertyOld = seataConfig.getProperty(listenedDataId, "");
String propertyNew = seataConfigNew.getProperty(listenedDataId, "");
if (!propertyOld.equals(propertyNew)) {
ConfigurationChangeEvent event =
new ConfigurationChangeEvent().setDataId(listenedDataId).setNewValue(propertyNew)
.setNamespace(group);

ConcurrentMap<ConfigurationChangeListener, NacosListener> configListeners =
entry.getValue();
for (ConfigurationChangeListener configListener : configListeners.keySet()) {
configListener.onProcessEvent(event);
}
}
}
}

seataConfig = seataConfigNew;
return;
seataConfig = seataConfigNew;
return;
}
} catch (Exception e) {
LOGGER.error("innerReceive error: {}", e.getMessage(), e);
}

//Compatible with old writing
ConfigurationChangeEvent event = new ConfigurationChangeEvent().setDataId(dataId).setNewValue(configInfo)
.setNamespace(group);
ConfigurationChangeEvent event =
new ConfigurationChangeEvent().setDataId(dataId).setNewValue(configInfo).setNamespace(group);
listener.onProcessEvent(event);
}
}
Expand Down
Loading

0 comments on commit 78e3996

Please sign in to comment.