Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7282](https://github.com/apache/incubator-seata/pull/7282)] optimize unexpected NullPointerException in lookup method in FileRegistryServiceImpl class
- [[#7310](https://github.com/seata/seata/pull/7310)] Optimize minor issues in the naming-server
- [[#7329](https://github.com/apache/incubator-seata/pull/7329)] upgrade tomcat to 9.0.100
- [[#7344](https://github.com/apache/incubator-seata/pull/7344)] raft mode performs transaction size check in advance
- [[#7337](https://github.com/apache/incubator-seata/pull/7337)] Add ChannelEventListener support to prevent memory leaks
- [[#7344](https://github.com/apache/incubator-seata/pull/7344)] raft mode performs transaction size check in advance
- [[#7345](https://github.com/apache/incubator-seata/pull/7345)] add empty check and duplicate type check to RegistryFactory
- [[#7350](https://github.com/apache/incubator-seata/pull/7350)] optimize codecov.yml
- [[#7360](https://github.com/apache/incubator-seata/pull/7360)] Update resource cleanup logic for channel disconnection

Expand Down Expand Up @@ -70,6 +71,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7205](https://github.com/apache/incubator-seata/issues/7205)] add UT for namingserver module
- [[#7359](https://github.com/apache/incubator-seata/issues/7359)] merge submodule test reports


### refactor:

- [[#7315](https://github.com/apache/incubator-seata/pull/7315)] Refactor log testing to use ListAppender for more accurate and efficient log capture
Expand Down
3 changes: 2 additions & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
- [[#7282](https://github.com/apache/incubator-seata/pull/7282)] 优化FileRegistryServiceImpl类lookup的NullPointerException问题
- [[#7310](https://github.com/seata/seata/pull/7310)] 优化naming-server中的一些小问题
- [[#7329](https://github.com/apache/incubator-seata/pull/7329)] 将 tomcat 升级到 9.0.100
- [[#7344](https://github.com/apache/incubator-seata/pull/7344)] raft模式提前检查事务大小
- [[#7337](https://github.com/apache/incubator-seata/pull/7337)] 添加 ChannelEventListener 支持以防止内存泄漏
- [[#7344](https://github.com/apache/incubator-seata/pull/7344)] raft模式提前检查事务大小
- [[#7345](https://github.com/apache/incubator-seata/pull/7345)] 为 RegistryFactory 增加空校验与重复类型检查
- [[#7350](https://github.com/apache/incubator-seata/pull/7350)] 优化单测覆盖配置
- [[#7360](https://github.com/apache/incubator-seata/pull/7360)] 更新通道断开连接时的资源清理逻辑

Expand Down
6 changes: 6 additions & 0 deletions discovery/seata-discovery-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@
<artifactId>seata-config-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package org.apache.seata.discovery.registry;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;

import org.apache.seata.common.ConfigurationKeys;
import org.apache.seata.common.Constants;
import org.apache.seata.common.exception.NotSupportYetException;
import org.apache.seata.common.loader.EnhancedServiceLoader;
import org.apache.seata.common.util.StringUtils;
import org.apache.seata.config.ConfigurationFactory;
Expand All @@ -31,7 +33,6 @@

/**
* The type multiple Registry factory.
*
*/
public class MultiRegistryFactory {

Expand All @@ -48,25 +49,27 @@ public static List<RegistryService> getInstances() {

private static List<RegistryService> buildRegistryServices() {
List<RegistryService> registryServices = new ArrayList<>();
String registryTypeNamesStr =
ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig(ConfigurationKeys.FILE_ROOT_REGISTRY
+ ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + ConfigurationKeys.FILE_ROOT_TYPE);

String registryTypeNamesStr = ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig(
ConfigurationKeys.FILE_ROOT_REGISTRY + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + ConfigurationKeys.FILE_ROOT_TYPE);

// If blank, use default configuration
if (StringUtils.isBlank(registryTypeNamesStr)) {
registryTypeNamesStr = RegistryType.File.name();
}
String[] registryTypeNames = registryTypeNamesStr.split(Constants.REGISTRY_TYPE_SPLIT_CHAR);
if (registryTypeNames.length > 1) {
LOGGER.info("use multi registry center type: {}", registryTypeNamesStr);

Set<String> registryTypeNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
registryTypeNames.addAll(Arrays.asList(registryTypeNamesStr.split(Constants.REGISTRY_TYPE_SPLIT_CHAR)));

if (registryTypeNames.size() > 1) {
LOGGER.info("use multi registry center type: {}", registryTypeNames);
}

for (String registryTypeName : registryTypeNames) {
RegistryType registryType;
try {
registryType = RegistryType.getType(registryTypeName);
} catch (Exception exx) {
throw new NotSupportYetException("not support registry type: " + registryTypeName);
}
RegistryType registryType = RegistryType.getType(registryTypeName);

RegistryService registryService = EnhancedServiceLoader
.load(RegistryProvider.class, Objects.requireNonNull(registryType).name()).provide();
.load(RegistryProvider.class, Objects.requireNonNull(registryType).name()).provide();
registryServices.add(registryService);
}
return registryServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@

import java.util.Objects;

import org.apache.seata.common.exception.NotSupportYetException;
import org.apache.seata.common.loader.EnhancedServiceLoader;
import org.apache.seata.common.util.StringUtils;
import org.apache.seata.config.ConfigurationFactory;
import org.apache.seata.config.ConfigurationKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The type Registry factory.
*
*/
public class RegistryFactory {

Expand All @@ -43,16 +42,17 @@ public static RegistryService getInstance() {
}

private static RegistryService buildRegistryService() {
RegistryType registryType;
String registryTypeName = ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig(
ConfigurationKeys.FILE_ROOT_REGISTRY + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR
+ ConfigurationKeys.FILE_ROOT_TYPE);
LOGGER.info("use registry center type: {}", registryTypeName);
try {
registryType = RegistryType.getType(registryTypeName);
} catch (Exception exx) {
throw new NotSupportYetException("not support registry type: " + registryTypeName);
ConfigurationKeys.FILE_ROOT_REGISTRY + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + ConfigurationKeys.FILE_ROOT_TYPE);

// If blank, use default configuration
if (StringUtils.isBlank(registryTypeName)) {
registryTypeName = RegistryType.File.name();
}

LOGGER.info("use registry center type: {}", registryTypeName);

RegistryType registryType = RegistryType.getType(registryTypeName);
return EnhancedServiceLoader.load(RegistryProvider.class, Objects.requireNonNull(registryType).name()).provide();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.seata.discovery.registry;

import org.apache.seata.common.exception.NotSupportYetException;

/**
* The enum Registry type.
*
Expand Down Expand Up @@ -78,6 +80,6 @@ public static RegistryType getType(String name) {
return registryType;
}
}
throw new IllegalArgumentException("not support registry type: " + name);
throw new NotSupportYetException("not support registry type: " + name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.discovery.registry;

import org.apache.seata.common.loader.LoadLevel;

/**
* the mock nacos RegistryProvider
*/
@LoadLevel(name = "Nacos", order = 1)
public class MockNacosRegistryProvider implements RegistryProvider {
@Override
public RegistryService provide() {
return new MockNacosRegistryService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.discovery.registry;

import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;

/**
* the mock nacos RegistryService
*/
public class MockNacosRegistryService implements RegistryService<Object> {

@Override
public void register(InetSocketAddress address) throws Exception {

}

@Override
public void unregister(InetSocketAddress address) throws Exception {

}

@Override
public void subscribe(String cluster, Object listener) throws Exception {

}

@Override
public void unsubscribe(String cluster, Object listener) throws Exception {

}

@Override
public List<InetSocketAddress> lookup(String key) throws Exception {
return new ArrayList<>();
}

@Override
public void close() throws Exception {

}
}
Loading
Loading