|
@@ -139,7 +139,7 @@ public abstract class RefreshableOfflineCheckTask implements EnvironmentAware, A
|
|
|
int timeoutMinutes = effectiveOfflineTimeoutMinutes();
|
|
int timeoutMinutes = effectiveOfflineTimeoutMinutes();
|
|
|
log.info("离线巡检开始: collector={}, timeoutMinutes={}, memoryDevices={}", collector(), timeoutMinutes, deviceLastReceiveTimeMap.size());
|
|
log.info("离线巡检开始: collector={}, timeoutMinutes={}, memoryDevices={}", collector(), timeoutMinutes, deviceLastReceiveTimeMap.size());
|
|
|
if (lastReceiptService != null) {
|
|
if (lastReceiptService != null) {
|
|
|
- lastReceiptService.restore(collector(), deviceLastReceiveTimeMap, offlineDeviceSet);
|
|
|
|
|
|
|
+ lastReceiptService.restore(collector(), deviceLastReceiveTimeMap);
|
|
|
}
|
|
}
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
|
long timeoutMs = (long) timeoutMinutes * 60 * 1000;
|
|
long timeoutMs = (long) timeoutMinutes * 60 * 1000;
|
|
@@ -147,7 +147,21 @@ public abstract class RefreshableOfflineCheckTask implements EnvironmentAware, A
|
|
|
synchronized (deviceLock(entry.getKey())) {
|
|
synchronized (deviceLock(entry.getKey())) {
|
|
|
// 与在线恢复串行,且重新读取时间,避免旧快照把刚收到上报的设备置离线。
|
|
// 与在线恢复串行,且重新读取时间,避免旧快照把刚收到上报的设备置离线。
|
|
|
Date latest = deviceLastReceiveTimeMap.get(entry.getKey());
|
|
Date latest = deviceLastReceiveTimeMap.get(entry.getKey());
|
|
|
- if (latest == null || now.getTime() - latest.getTime() <= timeoutMs) continue;
|
|
|
|
|
|
|
+ if (latest == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (now.getTime() - latest.getTime() <= timeoutMs) {
|
|
|
|
|
+ // 离线设备若最后采集时间仍在超时窗口内(如超时参数调大),自动恢复在线。
|
|
|
|
|
+ if (offlineDeviceSet.remove(entry.getKey())) {
|
|
|
|
|
+ if (updateDeviceOnlineStatus(entry.getKey(), 1)) {
|
|
|
|
|
+ onlineDeviceSet.add(entry.getKey());
|
|
|
|
|
+ log.info("设备 {} 已恢复在线(最后采集时间在{}分钟超时窗口内)", entry.getKey(), timeoutMinutes);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ offlineDeviceSet.add(entry.getKey());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
if (offlineDeviceSet.add(entry.getKey())) {
|
|
if (offlineDeviceSet.add(entry.getKey())) {
|
|
|
if (!updateDeviceOnlineStatus(entry.getKey(), 0)) {
|
|
if (!updateDeviceOnlineStatus(entry.getKey(), 0)) {
|
|
|
offlineDeviceSet.remove(entry.getKey());
|
|
offlineDeviceSet.remove(entry.getKey());
|