Add clear of agg data before subscription update

This commit is contained in:
Andrii Shvaika 2022-09-23 13:10:38 +03:00
parent 7c4d408085
commit b1a234eba2
2 changed files with 13 additions and 2 deletions

View File

@ -343,7 +343,7 @@ public class DefaultTbEntityDataSubscriptionService implements TbEntityDataSubsc
ctx.createTimeSeriesSubscriptions(lastTsEntityMap, startTs, endTs, true);
}
ctx.sendWsMsg(update);
entityDataList.forEach(ed -> ed.getTimeseries().clear());
entityDataList.forEach(EntityData::clearTsAndAggData);
} finally {
ctx.getWsLock().unlock();
}
@ -594,7 +594,7 @@ public class DefaultTbEntityDataSubscriptionService implements TbEntityDataSubsc
ctx.createTimeSeriesSubscriptions(lastTsEntityMap, cmd.getStartTs(), cmd.getEndTs());
}
ctx.sendWsMsg(update);
entityDataList.forEach(ed -> ed.getTimeseries().clear());
entityDataList.forEach(EntityData::clearTsAndAggData);
} finally {
ctx.getWsLock().unlock();
}

View File

@ -15,6 +15,7 @@
*/
package org.thingsboard.server.common.data.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.thingsboard.server.common.data.id.EntityId;
@ -33,4 +34,14 @@ public class EntityData {
public EntityData(EntityId entityId, Map<EntityKeyType, Map<String, TsValue>> latest, Map<String, TsValue[]> timeseries) {
this(entityId, latest, timeseries, null);
}
@JsonIgnore
public void clearTsAndAggData() {
if (timeseries != null) {
timeseries.clear();
}
if (aggLatest != null) {
aggLatest.clear();
}
}
}