[集群-自动切换过国标级联] 添加检测wvp奔溃与重新注册
This commit is contained in:
@@ -190,4 +190,8 @@ public interface IRedisCatchStorage {
|
||||
void sendPushStreamOnline(SendRtpInfo sendRtpItem);
|
||||
|
||||
ServerInfo queryServerInfo(String serverId);
|
||||
|
||||
String chooseOneServer();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId();
|
||||
Duration duration = Duration.ofSeconds(time);
|
||||
redisTemplate.opsForValue().set(key, serverInfo, duration);
|
||||
//
|
||||
// 设置平台的分数值
|
||||
String setKey = VideoManagerConstants.WVP_SERVER_LIST;
|
||||
// 首次设置就设置为0, 后续值越小说明越是最近启动的
|
||||
redisTemplate.opsForZSet().add(setKey, userSetting.getServerId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -540,4 +543,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
String key = VideoManagerConstants.WVP_SERVER_PREFIX + serverId;
|
||||
return (ServerInfo)redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseOneServer() {
|
||||
String key = VideoManagerConstants.WVP_SERVER_LIST;
|
||||
Set<Object> range = redisTemplate.opsForZSet().range(key, 0, 0);
|
||||
if (range == null || range.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return (String) range.iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user