updated check for single value argument size
This commit is contained in:
parent
7600401b86
commit
93090af2ee
@ -301,7 +301,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeStateAndRaiseSizeException(CalculatedFieldEntityCtxId ctxId, CalculatedFieldException ex, TbCallback callback) {
|
private void removeStateAndRaiseSizeException(CalculatedFieldEntityCtxId ctxId, CalculatedFieldException ex, TbCallback callback) throws CalculatedFieldException {
|
||||||
// We remove the state, but remember that it is over-sized in a local map.
|
// We remove the state, but remember that it is over-sized in a local map.
|
||||||
cfStateService.removeState(ctxId, new TbCallback() {
|
cfStateService.removeState(ctxId, new TbCallback() {
|
||||||
@Override
|
@Override
|
||||||
@ -314,6 +314,7 @@ public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareM
|
|||||||
callback.onFailure(ex);
|
callback.onFailure(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ArgumentEntry> mapToArguments(CalculatedFieldCtx ctx, List<TsKvProto> data) {
|
private Map<String, ArgumentEntry> mapToArguments(CalculatedFieldCtx ctx, List<TsKvProto> data) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
package org.thingsboard.server.actors.calculatedField;
|
package org.thingsboard.server.actors.calculatedField;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.thingsboard.common.util.DebugModeUtil;
|
|
||||||
import org.thingsboard.server.actors.ActorSystemContext;
|
import org.thingsboard.server.actors.ActorSystemContext;
|
||||||
import org.thingsboard.server.actors.TbActorCtx;
|
import org.thingsboard.server.actors.TbActorCtx;
|
||||||
import org.thingsboard.server.actors.TbActorRef;
|
import org.thingsboard.server.actors.TbActorRef;
|
||||||
@ -51,8 +50,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import static org.thingsboard.server.utils.CalculatedFieldUtils.fromProto;
|
import static org.thingsboard.server.utils.CalculatedFieldUtils.fromProto;
|
||||||
|
|||||||
@ -117,11 +117,6 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache {
|
|||||||
CalculatedField calculatedField = getCalculatedField(calculatedFieldId);
|
CalculatedField calculatedField = getCalculatedField(calculatedFieldId);
|
||||||
if (calculatedField != null) {
|
if (calculatedField != null) {
|
||||||
ctx = new CalculatedFieldCtx(calculatedField, tbelInvokeService, apiLimitService);
|
ctx = new CalculatedFieldCtx(calculatedField, tbelInvokeService, apiLimitService);
|
||||||
try {
|
|
||||||
ctx.init();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("Failed to initialize CF context.");
|
|
||||||
}
|
|
||||||
calculatedFieldsCtx.put(calculatedFieldId, ctx);
|
calculatedFieldsCtx.put(calculatedFieldId, ctx);
|
||||||
log.debug("[{}] Put calculated field ctx into cache: {}", calculatedFieldId, ctx);
|
log.debug("[{}] Put calculated field ctx into cache: {}", calculatedFieldId, ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,10 +91,12 @@ public abstract class BaseCalculatedFieldState implements CalculatedFieldState {
|
|||||||
if (entry instanceof TsRollingArgumentEntry) {
|
if (entry instanceof TsRollingArgumentEntry) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ctx.getMaxSingleValueArgumentSize() > 0 && toSingleValueArgumentProto(name, (SingleValueArgumentEntry) entry).getSerializedSize() > ctx.getMaxSingleValueArgumentSize()) {
|
if (entry instanceof SingleValueArgumentEntry singleValueArgumentEntry) {
|
||||||
|
if (ctx.getMaxSingleValueArgumentSize() > 0 && toSingleValueArgumentProto(name, singleValueArgumentEntry).getSerializedSize() > ctx.getMaxSingleValueArgumentSize()) {
|
||||||
throw new IllegalArgumentException("Single value size exceeds the maximum allowed limit. The argument will not be used for calculation.");
|
throw new IllegalArgumentException("Single value size exceeds the maximum allowed limit. The argument will not be used for calculation.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void validateNewEntry(ArgumentEntry newEntry);
|
protected abstract void validateNewEntry(ArgumentEntry newEntry);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user