Commit 9ff1613d3b39475a72b1f5ed10db525bb9f5db6e

Authored by 648540858
1 parent 50240b4e

修复web端管理节点负载不显示国标收流 #871

src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java
... ... @@ -65,4 +65,9 @@ public interface IInviteStreamService {
65 65 * 清空一个设备的所有invite信息
66 66 */
67 67 void clearInviteInfo(String deviceId);
  68 +
  69 + /**
  70 + * 统计同一个zlm下的国标收流个数
  71 + */
  72 + int getStreamInfoCount(String mediaServerId);
68 73 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
... ... @@ -179,4 +179,23 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
179 179 public void clearInviteInfo(String deviceId) {
180 180 removeInviteInfo(null, deviceId, null, null);
181 181 }
  182 +
  183 + @Override
  184 + public int getStreamInfoCount(String mediaServerId) {
  185 + int count = 0;
  186 + String key = VideoManagerConstants.INVITE_PREFIX + "_*_*_*_*";
  187 + List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
  188 + if (scanResult.size() == 0) {
  189 + return 0;
  190 + }else {
  191 + for (Object keyObj : scanResult) {
  192 + String keyStr = (String) keyObj;
  193 + InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(keyStr);
  194 + if (inviteInfo != null && inviteInfo.getStreamInfo() != null && inviteInfo.getStreamInfo().getMediaServerId().equals(mediaServerId)) {
  195 + count++;
  196 + }
  197 + }
  198 + }
  199 + return count;
  200 + }
182 201 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
... ... @@ -17,6 +17,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
17 17 import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
18 18 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
19 19 import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
  20 +import com.genersoft.iot.vmp.service.IInviteStreamService;
20 21 import com.genersoft.iot.vmp.service.IMediaServerService;
21 22 import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
22 23 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
... ... @@ -98,6 +99,9 @@ public class MediaServerServiceImpl implements IMediaServerService {
98 99 private IRedisCatchStorage redisCatchStorage;
99 100  
100 101 @Autowired
  102 + private IInviteStreamService inviteStreamService;
  103 +
  104 + @Autowired
101 105 private RedisTemplate<Object, Object> redisTemplate;
102 106  
103 107  
... ... @@ -735,7 +739,8 @@ public class MediaServerServiceImpl implements IMediaServerService {
735 739 result.setId(mediaServerItem.getId());
736 740 result.setPush(redisCatchStorage.getPushStreamCount(mediaServerItem.getId()));
737 741 result.setProxy(redisCatchStorage.getProxyStreamCount(mediaServerItem.getId()));
738   - result.setGbReceive(redisCatchStorage.getGbReceiveCount(mediaServerItem.getId()));
  742 +
  743 + result.setGbReceive(inviteStreamService.getStreamInfoCount(mediaServerItem.getId()));
739 744 result.setGbSend(redisCatchStorage.getGbSendCount(mediaServerItem.getId()));
740 745 return result;
741 746 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
... ... @@ -191,8 +191,6 @@ public interface IRedisCatchStorage {
191 191  
192 192 int getProxyStreamCount(String id);
193 193  
194   - int getGbReceiveCount(String id);
195   -
196 194 int getGbSendCount(String id);
197 195  
198 196 void addDiskInfo(List<Map<String, Object>> diskInfo);
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
... ... @@ -587,15 +587,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
587 587 }
588 588  
589 589 @Override
590   - public int getGbReceiveCount(String id) {
591   - String playKey = VideoManagerConstants.PLAYER_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*";
592   - String playBackKey = VideoManagerConstants.PLAY_BLACK_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*";
593   - String downloadKey = VideoManagerConstants.DOWNLOAD_PREFIX + "_" + userSetting.getServerId() + "_" + id + "_*";
594   -
595   - return RedisUtil.scan(redisTemplate, playKey).size() + RedisUtil.scan(redisTemplate, playBackKey).size() + RedisUtil.scan(redisTemplate, downloadKey).size();
596   - }
597   -
598   - @Override
599 590 public int getGbSendCount(String id) {
600 591 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
601 592 + userSetting.getServerId() + "_*_" + id + "_*";
... ...