优化级联时的异常处理
This commit is contained in:
@@ -39,8 +39,8 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
|
||||
// 获取失效的key
|
||||
String expiredKey = message.toString();
|
||||
logger.info(expiredKey);
|
||||
if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_PREFIX)){
|
||||
logger.info("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_PREFIX+",忽略");
|
||||
if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX)){
|
||||
logger.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX+",忽略");
|
||||
return;
|
||||
}
|
||||
// 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线
|
||||
@@ -49,7 +49,6 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
|
||||
|
||||
publisher.platformKeepaliveExpireEventPublish(platformGBId);
|
||||
}else if (expiredKey.startsWith(VideoManagerConstants.PLATFORM_REGISTER_PREFIX)) {
|
||||
logger.info("11111111111111");
|
||||
String platformGBId = expiredKey.substring(VideoManagerConstants.PLATFORM_REGISTER_PREFIX.length(),expiredKey.length());
|
||||
|
||||
publisher.platformNotRegisterEventPublish(platformGBId);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
|
||||
// 获取失效的key
|
||||
String expiredKey = message.toString();
|
||||
if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){
|
||||
logger.info("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
|
||||
logger.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener<P
|
||||
if (parentPlatformCatch.getKeepAliveReply() >= 3) {
|
||||
// 有3次未收到心跳回复, 设置平台状态为离线, 开始重新注册
|
||||
logger.warn("有3次未收到心跳回复,标记设置平台状态为离线, 并重新注册 平台国标ID:" + event.getPlatformGbID());
|
||||
storager.updateParentPlatformStatus(event.getPlatformGbID(), false);
|
||||
publisher.platformNotRegisterEventPublish(event.getPlatformGbID());
|
||||
parentPlatformCatch.setKeepAliveReply(0);
|
||||
}else {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -9,6 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 平台未注册事件,来源有二:
|
||||
* 1、平台新添加
|
||||
@@ -23,23 +30,53 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private SIPCommanderFroPlatform sipCommanderFroPlatform;
|
||||
|
||||
@Autowired
|
||||
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||
|
||||
// @Autowired
|
||||
// private RedisUtil redis;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(PlatformNotRegisterEvent event) {
|
||||
|
||||
logger.debug("平台未注册事件触发,平台国标ID:" + event.getPlatformGbID());
|
||||
logger.info("平台未注册事件触发,平台国标ID:" + event.getPlatformGbID());
|
||||
|
||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
|
||||
if (parentPlatform == null) {
|
||||
logger.debug("平台未注册事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||
logger.info("平台未注册事件触发,但平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||
return;
|
||||
}
|
||||
// 查询是否有推流, 如果有则都停止
|
||||
List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServer(event.getPlatformGbID());
|
||||
logger.info("停止[ {} ]的所有推流size", sendRtpItems.size());
|
||||
if (sendRtpItems != null && sendRtpItems.size() > 0) {
|
||||
logger.info("停止[ {} ]的所有推流", event.getPlatformGbID());
|
||||
StringBuilder app = new StringBuilder();
|
||||
StringBuilder stream = new StringBuilder();
|
||||
for (int i = 0; i < sendRtpItems.size(); i++) {
|
||||
if (app.length() != 0) {
|
||||
app.append(",");
|
||||
}
|
||||
app.append(sendRtpItems.get(i).getApp());
|
||||
if (stream.length() != 0) {
|
||||
stream.append(",");
|
||||
}
|
||||
stream.append(sendRtpItems.get(i).getStreamId());
|
||||
redisCatchStorage.deleteSendRTPServer(event.getPlatformGbID(), sendRtpItems.get(i).getChannelId());
|
||||
}
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("vhost","__defaultVhost__");
|
||||
param.put("app", app.toString());
|
||||
param.put("stream", stream.toString());
|
||||
zlmrtpServerFactory.stopSendRtpStream(param);
|
||||
|
||||
}
|
||||
sipCommanderFroPlatform.register(parentPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user