国标录像无法查询下级平台录像问题排查:

初步定位 因 RecordEndEventListener.handlerMap
时间触发完成时 handlerMap.get 时 null 导致
待后续排查/解决
This commit is contained in:
zxb 2023-08-07 17:19:51 +08:00
parent 15641114ef
commit f0cba184fe
2 changed files with 18 additions and 13 deletions

View File

@ -6,6 +6,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import java.util.Map;
@ -22,7 +24,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class);
private Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>();
private final static Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>();
public interface RecordEndEventHandler{
void handler(RecordInfo recordInfo);
}
@ -35,11 +37,13 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
int sumNum = event.getRecordInfo().getSumNum();
logger.info("录像查询完成事件触发deviceId{}, channelId: {}, 录像数量{}/{}条", event.getRecordInfo().getDeviceId(),
event.getRecordInfo().getChannelId(), count,sumNum);
logger.debug("handlerMap.size => {}", handlerMap.size());
if (handlerMap.size() > 0) {
RecordEndEventHandler handler = handlerMap.get(deviceId + channelId);
if (handler !=null){
logger.debug("handler => {}", handler);
if (handler != null){
handler.handler(event.getRecordInfo());
if (count ==sumNum){
if (count == sumNum){
handlerMap.remove(deviceId + channelId);
}
}
@ -53,6 +57,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
* @param recordEndEventHandler
*/
public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) {
logger.debug("RecordEndEventListener addEndEventHandler => deviceId: {}, channelId: {}", device,channelId);
handlerMap.put(device + channelId, recordEndEventHandler);
}
/**
@ -61,6 +66,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
* @param channelId
*/
public void delEndEventHandler(String device, String channelId) {
logger.debug("RecordEndEventListener delEndEventHandler => deviceId: {}, channelId: {}", device,channelId);
handlerMap.remove(device + channelId);
}

View File

@ -13,9 +13,8 @@ import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -27,10 +26,9 @@ import javax.sip.message.Response;
import java.text.ParseException;
import java.util.List;
@Slf4j
@Component
public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
private Logger logger = LoggerFactory.getLogger(RecordInfoQueryMessageHandler.class);
private final String cmdType = "RecordInfo";
@Autowired
@ -99,12 +97,13 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
// 向国标设备请求录像数据
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId);
log.debug("deviceId => {}, channelId => {}", deviceChannel.getDeviceId(),channelId);
// 接收录像数据
recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{
try {
cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, request.getFromTag(), recordInfo);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage());
log.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage());
}
});
try {
@ -114,18 +113,18 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
try {
responseAck(request, Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}),(eventResult -> {
// 查询失败
try {
responseAck(request, eventResult.statusCode, eventResult.msg);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
log.error("[命令发送失败] 录像查询回复: {}", e.getMessage());
}
}));
} catch (InvalidArgumentException | ParseException | SipException e) {
logger.error("[命令发送失败] 录像查询: {}", e.getMessage());
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
}
}else if (channelSources.get(1).getCount() > 0) { // 直播流
@ -133,13 +132,13 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
try {
responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 录像查询: {}", e.getMessage());
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
}
}else { // 错误的请求
try {
responseAck(request, Response.BAD_REQUEST);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 录像查询: {}", e.getMessage());
log.error("[命令发送失败] 录像查询: {}", e.getMessage());
}
}
}