[集群-自动切换过国标级联] 修复BUG
parent
ea2ef923ac
commit
0566bf916f
|
@ -95,6 +95,6 @@ public interface PlatformMapper {
|
||||||
@Select("SELECT server_id FROM wvp_platform WHERE enable=true and server_id != #{serverId} group by server_id")
|
@Select("SELECT server_id FROM wvp_platform WHERE enable=true and server_id != #{serverId} group by server_id")
|
||||||
List<String> queryServerIdsWithEnableAndNotInServer(@Param("serverId") String serverId);
|
List<String> queryServerIdsWithEnableAndNotInServer(@Param("serverId") String serverId);
|
||||||
|
|
||||||
@Select("SELECT * FROM wvp_platform WHERE server_id == #{serverId}")
|
@Select("SELECT * FROM wvp_platform WHERE server_id = #{serverId}")
|
||||||
List<Platform> queryByServerId(@Param("serverId") String serverId);
|
List<Platform> queryByServerId(@Param("serverId") String serverId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,13 +120,14 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||||
log.info("[集群] 检测到 {} 已离线", serverId);
|
log.info("[集群] 检测到 {} 已离线", serverId);
|
||||||
// 检查每个是否存活
|
// 检查每个是否存活
|
||||||
ServerInfo serverInfo = redisCatchStorage.queryServerInfo(serverId);
|
ServerInfo serverInfo = redisCatchStorage.queryServerInfo(serverId);
|
||||||
if (serverInfo == null && userSetting.getServerId().equals(redisCatchStorage.chooseOneServer())) {
|
if (serverInfo == null && userSetting.getServerId().equals(redisCatchStorage.chooseOneServer(serverId))) {
|
||||||
// 此平台需要选择新平台处理, 确定由当前平台即开始处理
|
// 此平台需要选择新平台处理, 确定由当前平台即开始处理
|
||||||
List<Platform> platformList = platformMapper.queryByServerId(serverId);
|
List<Platform> platformList = platformMapper.queryByServerId(serverId);
|
||||||
platformList.forEach(platform -> {
|
platformList.forEach(platform -> {
|
||||||
log.info("[集群] 由本平台开启上级平台{}({})的注册", platform.getName(), platform.getServerGBId());
|
log.info("[集群] 由本平台开启上级平台{}({})的注册", platform.getName(), platform.getServerGBId());
|
||||||
// 设置平台使用当前平台的IP
|
// 设置平台使用当前平台的IP
|
||||||
platform.setAddress(getIpWithSameNetwork(platform.getAddress()));
|
platform.setAddress(getIpWithSameNetwork(platform.getAddress()));
|
||||||
|
platform.setServerId(userSetting.getServerId());
|
||||||
platformMapper.update(platform);
|
platformMapper.update(platform);
|
||||||
// 更新redis
|
// 更新redis
|
||||||
redisCatchStorage.delPlatformCatchInfo(platform.getServerGBId());
|
redisCatchStorage.delPlatformCatchInfo(platform.getServerGBId());
|
||||||
|
|
|
@ -191,7 +191,7 @@ public interface IRedisCatchStorage {
|
||||||
|
|
||||||
ServerInfo queryServerInfo(String serverId);
|
ServerInfo queryServerInfo(String serverId);
|
||||||
|
|
||||||
String chooseOneServer();
|
String chooseOneServer(String serverId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -545,8 +545,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String chooseOneServer() {
|
public String chooseOneServer(String serverId) {
|
||||||
String key = VideoManagerConstants.WVP_SERVER_LIST;
|
String key = VideoManagerConstants.WVP_SERVER_LIST;
|
||||||
|
redisTemplate.opsForZSet().remove(key, serverId);
|
||||||
Set<Object> range = redisTemplate.opsForZSet().range(key, 0, 0);
|
Set<Object> range = redisTemplate.opsForZSet().range(key, 0, 0);
|
||||||
if (range == null || range.isEmpty()) {
|
if (range == null || range.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue