From cba2e6b90b50c208e3354d4561b40576a251c370 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期六, 04 六月 2022 23:18:01 +0800
Subject: [PATCH] 优化wasm播放器内存占用问题
---
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java | 33 +++++----------------------------
1 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
index ae7647f..39daeda 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -14,13 +14,13 @@
import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
+import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.text.SimpleDateFormat;
import java.util.*;
@SuppressWarnings("rawtypes")
@@ -37,8 +37,6 @@
@Autowired
private UserSetting userSetting;
-
- private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public Long getCSEQ(String method) {
@@ -470,26 +468,6 @@
}
@Override
- public void outlineForAll() {
- List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + "*" );
- for (int i = 0; i < onlineDevices.size(); i++) {
- String key = (String) onlineDevices.get(i);
- redis.del(key);
- }
- }
-
- @Override
- public List<String> getOnlineForAll() {
- List<String> result = new ArrayList<>();
- List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + "*" );
- for (int i = 0; i < onlineDevices.size(); i++) {
- String key = (String) onlineDevices.get(i);
- result.add((String) redis.get(key));
- }
- return result;
- }
-
- @Override
public void updateWVPInfo(JSONObject jsonObject, int time) {
String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId();
redis.set(key, jsonObject, time);
@@ -638,7 +616,7 @@
public void addCpuInfo(double cpuInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId();
SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
- systemInfoDto.setTime(format.format(System.currentTimeMillis()));
+ systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(cpuInfo);
redis.lSet(key, systemInfoDto);
// 姣忕涓�涓紝鏈�澶氬彧瀛�30涓�
@@ -653,7 +631,7 @@
public void addMemInfo(double memInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetting.getServerId();
SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
- systemInfoDto.setTime(format.format(System.currentTimeMillis()));
+ systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(memInfo);
redis.lSet(key, systemInfoDto);
// 姣忕涓�涓紝鏈�澶氬彧瀛�30涓�
@@ -668,7 +646,7 @@
public void addNetInfo(Map<String, String> networkInterfaces) {
String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId();
SystemInfoDto<Map<String, String>> systemInfoDto = new SystemInfoDto<>();
- systemInfoDto.setTime(format.format(System.currentTimeMillis()));
+ systemInfoDto.setTime(DateUtil.getNow());
systemInfoDto.setData(networkInterfaces);
redis.lSet(key, systemInfoDto);
// 姣忕涓�涓紝鏈�澶氬彧瀛�30涓�
@@ -702,7 +680,6 @@
@Override
public boolean deviceIsOnline(String deviceId) {
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId;
- return redis.hasKey(key);
+ return getDevice(deviceId).getOnline() == 1;
}
}
--
Gitblit v1.8.0