Browse Source

fixed--多节点管理zlm,wvp重启之后节点中的redis在线状态bug修复

pull/365/head
chenjialing 3 years ago
parent
commit
b225b53510
  1. 1
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
  3. 9
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

1
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java

@ -92,6 +92,7 @@ public class ZLMRunner implements CommandLineRunner {
// 获取所有的zlm, 并开启主动连接 // 获取所有的zlm, 并开启主动连接
List<MediaServerItem> all = mediaServerService.getAllFromDatabase(); List<MediaServerItem> all = mediaServerService.getAllFromDatabase();
mediaServerService.updateVmServer(all);
if (all.size() == 0) { if (all.size() == 0) {
all.add(mediaConfig.getMediaSerItem()); all.add(mediaConfig.getMediaSerItem());
} }

2
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java

@ -42,6 +42,8 @@ public interface IMediaServerService {
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart); void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);
void updateVmServer(List<MediaServerItem> mediaServerItemList);
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId); SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId);
SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback); SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback);

9
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@ -46,8 +46,7 @@ import java.util.*;
* 媒体服务器节点管理 * 媒体服务器节点管理
*/ */
@Service @Service
@Order(value=2) public class MediaServerServiceImpl implements IMediaServerService {
public class MediaServerServiceImpl implements IMediaServerService, CommandLineRunner {
private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class); private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class);
@ -102,9 +101,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
* 初始化 * 初始化
*/ */
@Override @Override
public void run(String... args) throws Exception { public void updateVmServer(List<MediaServerItem> mediaServerItemList) {
logger.info("[缓存初始化] Media Server "); logger.info("[缓存初始化] Media Server ");
List<MediaServerItem> mediaServerItemList = mediaServerMapper.queryAll();
for (MediaServerItem mediaServerItem : mediaServerItemList) { for (MediaServerItem mediaServerItem : mediaServerItemList) {
if (StringUtils.isEmpty(mediaServerItem.getId())) { if (StringUtils.isEmpty(mediaServerItem.getId())) {
continue; continue;
@ -224,7 +222,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR
String key = (String) mediaServerKey; String key = (String) mediaServerKey;
MediaServerItem mediaServerItem = (MediaServerItem) redisUtil.get(key); MediaServerItem mediaServerItem = (MediaServerItem) redisUtil.get(key);
// 检查状态 // 检查状态
if (redisUtil.zScore(onlineKey, mediaServerItem.getId()) != null) { Double aDouble = redisUtil.zScore(onlineKey, mediaServerItem.getId());
if (aDouble != null) {
mediaServerItem.setStatus(true); mediaServerItem.setStatus(true);
} }
result.add(mediaServerItem); result.add(mediaServerItem);

Loading…
Cancel
Save