|
|
|
@ -53,7 +53,6 @@ import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldCtx; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldState; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.SingleValueArgumentEntry; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.aggregation.RelatedEntitiesAggregationCalculatedFieldState; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.aggregation.single.EntityAggregationCalculatedFieldState; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.alarm.AlarmCalculatedFieldState; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.geofencing.GeofencingArgumentEntry; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.geofencing.GeofencingCalculatedFieldState; |
|
|
|
@ -124,12 +123,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
if (state != null) { |
|
|
|
state.setCtx(msg.getCtx(), actorCtx); |
|
|
|
state.setPartition(msg.getPartition()); |
|
|
|
if (state instanceof RelatedEntitiesAggregationCalculatedFieldState relatedEntitiesAggState) { |
|
|
|
relatedEntitiesAggState.scheduleReevaluation(); |
|
|
|
} |
|
|
|
if (state instanceof EntityAggregationCalculatedFieldState entityAggState) { |
|
|
|
entityAggState.fillMissingIntervals(); |
|
|
|
} |
|
|
|
state.init(true); |
|
|
|
states.put(cfId, state); |
|
|
|
} else { |
|
|
|
removeState(cfId); |
|
|
|
@ -140,7 +134,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
log.debug("Processing CF state partition restore msg: {}", msg); |
|
|
|
for (CalculatedFieldState state : states.values()) { |
|
|
|
if (msg.getPartition().equals(state.getPartition())) { |
|
|
|
state.init(); |
|
|
|
state.init(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -455,7 +449,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
|
|
|
|
private void initState(CalculatedFieldState state, CalculatedFieldCtx ctx) { |
|
|
|
state.setCtx(ctx, actorCtx); |
|
|
|
state.init(); |
|
|
|
state.init(false); |
|
|
|
|
|
|
|
if (ctx.getCfType() == CalculatedFieldType.GEOFENCING && ctx.isRelationQueryDynamicArguments()) { |
|
|
|
GeofencingCalculatedFieldState geofencingState = (GeofencingCalculatedFieldState) state; |
|
|
|
@ -504,7 +498,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM |
|
|
|
} else { |
|
|
|
if (DebugModeUtil.isDebugFailuresAvailable(ctx.getCalculatedField())) { |
|
|
|
String errorMsg = ctx.isInitialized() ? state.getReadinessStatus().errorMsg() : "Calculated field state is not initialized!"; |
|
|
|
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, null, errorMsg); |
|
|
|
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, null, errorMsg); |
|
|
|
} |
|
|
|
callback.onSuccess(); |
|
|
|
} |
|
|
|
|