Merge branch 'master' into edqs
This commit is contained in:
commit
9bbcef515d
@ -644,6 +644,10 @@ public class ActorSystemContext {
|
|||||||
@Getter
|
@Getter
|
||||||
private String deviceStateNodeRateLimitConfig;
|
private String deviceStateNodeRateLimitConfig;
|
||||||
|
|
||||||
|
@Value("${actors.calculated_fields.calculation_timeout:5}")
|
||||||
|
@Getter
|
||||||
|
private long cfCalculationResultTimeout;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private TbActorSystem actorSystem;
|
private TbActorSystem actorSystem;
|
||||||
|
|||||||
@ -274,32 +274,30 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
|||||||
|
|
||||||
private void processStateIfReady(CalculatedFieldCtx ctx, List<CalculatedFieldId> cfIdList, CalculatedFieldState state, UUID tbMsgId, TbMsgType tbMsgType, TbCallback callback) throws CalculatedFieldException {
|
private void processStateIfReady(CalculatedFieldCtx ctx, List<CalculatedFieldId> cfIdList, CalculatedFieldState state, UUID tbMsgId, TbMsgType tbMsgType, TbCallback callback) throws CalculatedFieldException {
|
||||||
CalculatedFieldEntityCtxId ctxId = new CalculatedFieldEntityCtxId(tenantId, ctx.getCfId(), entityId);
|
CalculatedFieldEntityCtxId ctxId = new CalculatedFieldEntityCtxId(tenantId, ctx.getCfId(), entityId);
|
||||||
boolean stateSizeOk;
|
boolean stateSizeChecked = false;
|
||||||
if (ctx.isInitialized() && state.isReady()) {
|
try {
|
||||||
try {
|
if (ctx.isInitialized() && state.isReady()) {
|
||||||
CalculatedFieldResult calculationResult = state.performCalculation(ctx).get(5, TimeUnit.SECONDS);
|
CalculatedFieldResult calculationResult = state.performCalculation(ctx).get(systemContext.getCfCalculationResultTimeout(), TimeUnit.SECONDS);
|
||||||
state.checkStateSize(ctxId, ctx.getMaxStateSize());
|
state.checkStateSize(ctxId, ctx.getMaxStateSize());
|
||||||
stateSizeOk = state.isSizeOk();
|
stateSizeChecked = true;
|
||||||
if (stateSizeOk) {
|
if (state.isSizeOk()) {
|
||||||
cfService.pushMsgToRuleEngine(tenantId, entityId, calculationResult, cfIdList, callback);
|
cfService.pushMsgToRuleEngine(tenantId, entityId, calculationResult, cfIdList, callback);
|
||||||
if (DebugModeUtil.isDebugAllAvailable(ctx.getCalculatedField())) {
|
if (DebugModeUtil.isDebugAllAvailable(ctx.getCalculatedField())) {
|
||||||
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, JacksonUtil.writeValueAsString(calculationResult.getResult()), null);
|
systemContext.persistCalculatedFieldDebugEvent(tenantId, ctx.getCfId(), entityId, state.getArguments(), tbMsgId, tbMsgType, JacksonUtil.writeValueAsString(calculationResult.getResult()), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).msgId(tbMsgId).msgType(tbMsgType).arguments(state.getArguments()).cause(e).build();
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
state.checkStateSize(ctxId, ctx.getMaxStateSize());
|
throw CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).msgId(tbMsgId).msgType(tbMsgType).arguments(state.getArguments()).cause(e).build();
|
||||||
stateSizeOk = state.isSizeOk();
|
} finally {
|
||||||
if (stateSizeOk) {
|
if (!stateSizeChecked) {
|
||||||
callback.onSuccess(); // State was updated but no calculation performed;
|
state.checkStateSize(ctxId, ctx.getMaxStateSize());
|
||||||
|
}
|
||||||
|
if (state.isSizeOk()) {
|
||||||
|
cfStateService.persistState(ctxId, state, callback);
|
||||||
|
} else {
|
||||||
|
removeStateAndRaiseSizeException(ctxId, CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).errorMessage(ctx.getSizeExceedsLimitMessage()).build(), callback);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (stateSizeOk) {
|
|
||||||
cfStateService.persistState(ctxId, state, callback);
|
|
||||||
} else {
|
|
||||||
removeStateAndRaiseSizeException(ctxId, CalculatedFieldException.builder().ctx(ctx).eventEntity(entityId).errorMessage(ctx.getSizeExceedsLimitMessage()).build(), callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,10 +100,6 @@ public class SingleValueArgumentEntry implements ArgumentEntry {
|
|||||||
if (newVersion == null || this.version == null || newVersion > this.version) {
|
if (newVersion == null || this.version == null || newVersion > this.version) {
|
||||||
this.ts = singleValueEntry.getTs();
|
this.ts = singleValueEntry.getTs();
|
||||||
this.version = newVersion;
|
this.version = newVersion;
|
||||||
BasicKvEntry newValue = singleValueEntry.getKvEntryValue();
|
|
||||||
if (this.kvEntryValue != null && this.kvEntryValue.getValue().equals(newValue.getValue())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.kvEntryValue = singleValueEntry.getKvEntryValue();
|
this.kvEntryValue = singleValueEntry.getKvEntryValue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -436,7 +436,9 @@ public class DefaultTbEntityDataSubscriptionService implements TbEntityDataSubsc
|
|||||||
ctx.sendWsMsg(update);
|
ctx.sendWsMsg(update);
|
||||||
} else {
|
} else {
|
||||||
ctx.doFetchAlarmCount();
|
ctx.doFetchAlarmCount();
|
||||||
ctx.createAlarmSubscriptions();
|
if (entitiesIds != null) {
|
||||||
|
ctx.createAlarmSubscriptions();
|
||||||
|
}
|
||||||
TbAlarmCountSubCtx finalCtx = ctx;
|
TbAlarmCountSubCtx finalCtx = ctx;
|
||||||
ScheduledFuture<?> task = scheduler.scheduleWithFixedDelay(
|
ScheduledFuture<?> task = scheduler.scheduleWithFixedDelay(
|
||||||
() -> refreshDynamicQuery(finalCtx),
|
() -> refreshDynamicQuery(finalCtx),
|
||||||
|
|||||||
@ -512,6 +512,8 @@ actors:
|
|||||||
enabled: "${ACTORS_CALCULATED_FIELD_DEBUG_MODE_RATE_LIMITS_PER_TENANT_ENABLED:true}"
|
enabled: "${ACTORS_CALCULATED_FIELD_DEBUG_MODE_RATE_LIMITS_PER_TENANT_ENABLED:true}"
|
||||||
# The value of DEBUG mode rate limit. By default, no more than 50 thousand events per hour
|
# The value of DEBUG mode rate limit. By default, no more than 50 thousand events per hour
|
||||||
configuration: "${ACTORS_CALCULATED_FIELD_DEBUG_MODE_RATE_LIMITS_PER_TENANT_CONFIGURATION:50000:3600}"
|
configuration: "${ACTORS_CALCULATED_FIELD_DEBUG_MODE_RATE_LIMITS_PER_TENANT_CONFIGURATION:50000:3600}"
|
||||||
|
# Time in seconds to receive calculation result.
|
||||||
|
calculation_timeout: "${ACTORS_CALCULATION_TIMEOUT_SEC:5}"
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
settings:
|
settings:
|
||||||
|
|||||||
@ -83,7 +83,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@DaoSqlTest
|
@DaoSqlTest
|
||||||
@TestPropertySource(properties = {
|
@TestPropertySource(properties = {
|
||||||
"server.ws.alarms_per_alarm_status_subscription_cache_size=5"
|
"server.ws.alarms_per_alarm_status_subscription_cache_size=5",
|
||||||
|
"server.ws.dynamic_page_link.refresh_interval=15"
|
||||||
})
|
})
|
||||||
public class WebsocketApiTest extends AbstractControllerTest {
|
public class WebsocketApiTest extends AbstractControllerTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@ -71,6 +71,6 @@ public class SingleValueArgumentEntryTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateEntryWhenValueWasNotChanged() {
|
void testUpdateEntryWhenValueWasNotChanged() {
|
||||||
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts + 18, new LongDataEntry("key", 11L), 237L))).isFalse();
|
assertThat(entry.updateEntry(new SingleValueArgumentEntry(ts + 18, new LongDataEntry("key", 11L), 364L))).isTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user