Skip to content

Commit

Permalink
Merge branch 'seata:2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
PeppaO authored Nov 3, 2023
2 parents 3f5a9e8 + 65fb61b commit 67fd44b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
2 changes: 2 additions & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ The version is updated as follows:
- [[#5930](https://github.com/seata/seata/pull/5930)] fix the issue of missing sentinel password in store redis mode
- [[#5958](https://github.com/seata/seata/pull/5958)] required to be unlocked when a re-election occurs in a commit state
- [[#5971](https://github.com/seata/seata/pull/5971)] fix some configurations that are not deprecated show "Deprecated"
- [[#5977](https://github.com/seata/seata/pull/5977)] fix that rpcserver is not closed when raftServer is closed
- [[#5954](https://github.com/seata/seata/pull/5954)] fix the issue of saved branch session status does not match the actual branch session status


### optimize:
- [[#5966](https://github.com/seata/seata/pull/5966)] decouple saga expression handling and remove evaluator package
- [[#5928](https://github.com/seata/seata/pull/5928)] add Saga statelang semantic validation
Expand Down
2 changes: 2 additions & 0 deletions changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5930](https://github.com/seata/seata/pull/5930)] 修复存储为redis哨兵模式下哨兵密码缺失的问题
- [[#5958](https://github.com/seata/seata/pull/5958)] 在二阶段提交状态下发生重选时需要进行解除全局锁
- [[#5971](https://github.com/seata/seata/pull/5971)] 修复某些未弃用的配置显示"已弃用"
- [[#5977](https://github.com/seata/seata/pull/5977)] 修复当raft server关闭时,rpc server未关闭的问题
- [[#5954](https://github.com/seata/seata/pull/5954)] 修复保存的分支会话状态与实际的分支会话状态不一致的问题


### optimize:
- [[#5966](https://github.com/seata/seata/pull/5966)] Saga 表达式解耦并统一格式
- [[#5928](https://github.com/seata/seata/pull/5928)] 增加Saga模式状态机语义验证阶段
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import com.alipay.sofa.jraft.Node;
import com.alipay.sofa.jraft.RaftGroupService;
Expand Down Expand Up @@ -104,9 +105,7 @@ public void close() {

@Override
public void destroy() {
if (raftGroupService != null) {
raftGroupService.shutdown();
}
Optional.ofNullable(raftGroupService).ifPresent(RaftGroupService::shutdown);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.seata.server.cluster.raft;

import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -37,6 +38,7 @@
import io.seata.common.XID;
import io.seata.common.util.StringUtils;
import io.seata.config.ConfigurationFactory;
import io.seata.core.rpc.Disposable;
import io.seata.discovery.registry.FileRegistryServiceImpl;
import io.seata.discovery.registry.MultiRegistryFactory;
import io.seata.discovery.registry.RegistryService;
Expand All @@ -60,7 +62,7 @@
/**
* @author funkye
*/
public class RaftServerFactory {
public class RaftServerFactory implements Disposable, Closeable {

private static final Logger LOGGER = LoggerFactory.getLogger(RaftServerFactory.class);

Expand Down Expand Up @@ -155,6 +157,20 @@ public void start() {
}
}

@Override
public void destroy() {
this.close();
}

@Override
public void close() {
RAFT_SERVER_MAP.forEach((group, raftServer) -> {
raftServer.close();
LOGGER.info("closed seata server raft cluster, group: {} ", group);
});
Optional.ofNullable(rpcServer).ifPresent(RpcServer::shutdown);
}

public RaftServer getRaftServer(String group) {
return RAFT_SERVER_MAP.get(group);
}
Expand Down
12 changes: 2 additions & 10 deletions server/src/main/java/io/seata/server/session/SessionHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import io.seata.core.store.DistributedLocker;
import io.seata.server.cluster.raft.context.SeataClusterContext;
import io.seata.server.lock.distributed.DistributedLockerFactory;
import io.seata.server.cluster.raft.RaftServer;
import io.seata.server.cluster.raft.RaftServerFactory;
import io.seata.server.store.StoreConfig;
import io.seata.server.store.StoreConfig.SessionMode;
Expand All @@ -50,7 +49,7 @@
import static java.io.File.separator;
import static io.seata.common.DefaultValues.DEFAULT_DISTRIBUTED_LOCK_EXPIRE_TIME;
import static io.seata.common.DefaultValues.DEFAULT_SESSION_STORE_FILE_DIR;
import static io.seata.core.constants.ConfigurationKeys.SERVER_SERVICE_PORT_CAMEL;
import static io.seata.common.ConfigurationKeys.SERVER_SERVICE_PORT_CAMEL;

/**
* The type Session holder.
Expand Down Expand Up @@ -380,14 +379,7 @@ public static boolean distributedLockAndExecute(String key, NoArgsFunc func) {
}

public static void destroy() {
Collection<RaftServer> raftServers = RaftServerFactory.getInstance().getRaftServers();
if (raftServers != null) {
try {
raftServers.forEach(RaftServer::close);
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
RaftServerFactory.getInstance().destroy();
if (ROOT_SESSION_MANAGER != null) {
ROOT_SESSION_MANAGER.destroy();
}
Expand Down

0 comments on commit 67fd44b

Please sign in to comment.