From b225b535102ca8d917a4a64765a04566211a7c0a Mon Sep 17 00:00:00 2001 From: chenjialing <595168663@qq.com> Date: Thu, 3 Mar 2022 12:09:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fixed--=E5=A4=9A=E8=8A=82=E7=82=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86zlm,wvp=E9=87=8D=E5=90=AF=E4=B9=8B=E5=90=8E=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=B8=AD=E7=9A=84redis=E5=9C=A8=E7=BA=BF=E7=8A=B6?= =?UTF-8?q?=E6=80=81bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 1 + .../genersoft/iot/vmp/service/IMediaServerService.java | 2 ++ .../iot/vmp/service/impl/MediaServerServiceImpl.java | 9 ++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index de5d4832..9d0e354c 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -92,6 +92,7 @@ public class ZLMRunner implements CommandLineRunner { // 获取所有的zlm, 并开启主动连接 List all = mediaServerService.getAllFromDatabase(); + mediaServerService.updateVmServer(all); if (all.size() == 0) { all.add(mediaConfig.getMediaSerItem()); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index ec2714fd..5eb1e81b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -42,6 +42,8 @@ public interface IMediaServerService { void setZLMConfig(MediaServerItem mediaServerItem, boolean restart); + void updateVmServer(List mediaServerItemList); + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId); SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 159cd055..0306a273 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -46,8 +46,7 @@ import java.util.*; * 媒体服务器节点管理 */ @Service -@Order(value=2) -public class MediaServerServiceImpl implements IMediaServerService, CommandLineRunner { +public class MediaServerServiceImpl implements IMediaServerService { private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class); @@ -102,9 +101,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR * 初始化 */ @Override - public void run(String... args) throws Exception { + public void updateVmServer(List mediaServerItemList) { logger.info("[缓存初始化] Media Server "); - List mediaServerItemList = mediaServerMapper.queryAll(); for (MediaServerItem mediaServerItem : mediaServerItemList) { if (StringUtils.isEmpty(mediaServerItem.getId())) { continue; @@ -224,7 +222,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR String key = (String) mediaServerKey; 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); } result.add(mediaServerItem); From af885ca4d9f2836567505bb41a3f677ef4827aca Mon Sep 17 00:00:00 2001 From: chenjialing <595168663@qq.com> Date: Wed, 2 Mar 2022 18:29:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=AE=A1=E7=90=86--?= =?UTF-8?q?=E6=9F=90=E4=B8=AAzlm=E8=8A=82=E7=82=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E4=BB=8D=E6=9C=89=E6=95=B0=E6=8D=AE=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=86=8D=E6=AC=A1=E6=B7=BB=E5=8A=A0=E8=AF=A5zlm=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/genersoft/iot/vmp/service/IMediaServerService.java | 2 ++ .../iot/vmp/service/impl/MediaServerServiceImpl.java | 5 +++++ .../genersoft/iot/vmp/vmanager/server/ServerController.java | 1 + 3 files changed, 8 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index 5eb1e81b..f636a87e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -76,6 +76,8 @@ public interface IMediaServerService { void delete(String id); + void deleteDb(String id); + MediaServerItem getDefaultMediaServer(); void updateMediaServerKeepalive(String mediaServerId, JSONObject data); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 0306a273..5a3f4679 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -608,6 +608,11 @@ public class MediaServerServiceImpl implements IMediaServerService { String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + id; redisUtil.del(key); } + @Override + public void deleteDb(String id){ + //同步删除数据库中的数据 + mediaServerMapper.delOne(id); + } @Override public void updateMediaServerKeepalive(String mediaServerId, JSONObject data) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index c27fb0e1..1500f351 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -158,6 +158,7 @@ public class ServerController { public WVPResult deleteMediaServer(@RequestParam String id){ if (mediaServerService.getOne(id) != null) { mediaServerService.delete(id); + mediaServerService.deleteDb(id); }else { WVPResult result = new WVPResult<>(); result.setCode(-1);