Search in sources :

Example 1 with RuleNodeInfo

use of org.thingsboard.server.common.msg.queue.RuleNodeInfo in project thingsboard by thingsboard.

the class RuleNodeActorMessageProcessor method onUpdate.

@Override
public void onUpdate(TbActorCtx context) throws Exception {
    RuleNode newRuleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
    this.info = new RuleNodeInfo(entityId, ruleChainName, newRuleNode != null ? newRuleNode.getName() : "Unknown");
    boolean restartRequired = state != ComponentLifecycleState.ACTIVE || !(ruleNode.getType().equals(newRuleNode.getType()) && ruleNode.getConfiguration().equals(newRuleNode.getConfiguration()));
    this.ruleNode = newRuleNode;
    this.defaultCtx.updateSelf(newRuleNode);
    if (restartRequired) {
        if (tbNode != null) {
            tbNode.destroy();
        }
        try {
            start(context);
        } catch (Exception e) {
            throw new TbRuleNodeUpdateException("Failed to update rule node", e);
        }
    }
}
Also used : RuleNodeInfo(org.thingsboard.server.common.msg.queue.RuleNodeInfo) RuleNode(org.thingsboard.server.common.data.rule.RuleNode) TbRuleNodeUpdateException(org.thingsboard.server.actors.TbRuleNodeUpdateException) TbRuleNodeUpdateException(org.thingsboard.server.actors.TbRuleNodeUpdateException) RuleNodeException(org.thingsboard.server.common.msg.queue.RuleNodeException)

Example 2 with RuleNodeInfo

use of org.thingsboard.server.common.msg.queue.RuleNodeInfo in project thingsboard by thingsboard.

the class DefaultTbRuleEngineConsumerService method printFirstOrAll.

private void printFirstOrAll(TbRuleEngineQueueConfiguration configuration, TbMsgPackProcessingContext ctx, Map<UUID, TbProtoQueueMsg<ToRuleEngineMsg>> map, String prefix) {
    boolean printAll = log.isTraceEnabled();
    log.info("{} to process [{}] messages", prefix, map.size());
    for (Map.Entry<UUID, TbProtoQueueMsg<ToRuleEngineMsg>> pending : map.entrySet()) {
        ToRuleEngineMsg tmp = pending.getValue().getValue();
        TbMsg tmpMsg = TbMsg.fromBytes(configuration.getName(), tmp.getTbMsg().toByteArray(), TbMsgCallback.EMPTY);
        RuleNodeInfo ruleNodeInfo = ctx.getLastVisitedRuleNode(pending.getKey());
        if (printAll) {
            log.trace("[{}] {} to process message: {}, Last Rule Node: {}", TenantId.fromUUID(new UUID(tmp.getTenantIdMSB(), tmp.getTenantIdLSB())), prefix, tmpMsg, ruleNodeInfo);
        } else {
            log.info("[{}] {} to process message: {}, Last Rule Node: {}", TenantId.fromUUID(new UUID(tmp.getTenantIdMSB(), tmp.getTenantIdLSB())), prefix, tmpMsg, ruleNodeInfo);
            break;
        }
    }
}
Also used : RuleNodeInfo(org.thingsboard.server.common.msg.queue.RuleNodeInfo) TbProtoQueueMsg(org.thingsboard.server.queue.common.TbProtoQueueMsg) UUID(java.util.UUID) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) QueueToRuleEngineMsg(org.thingsboard.server.common.msg.queue.QueueToRuleEngineMsg) ToRuleEngineMsg(org.thingsboard.server.gen.transport.TransportProtos.ToRuleEngineMsg) TbMsg(org.thingsboard.server.common.msg.TbMsg)

Aggregations

RuleNodeInfo (org.thingsboard.server.common.msg.queue.RuleNodeInfo)2 Map (java.util.Map)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 TbRuleNodeUpdateException (org.thingsboard.server.actors.TbRuleNodeUpdateException)1 RuleNode (org.thingsboard.server.common.data.rule.RuleNode)1 TbMsg (org.thingsboard.server.common.msg.TbMsg)1 QueueToRuleEngineMsg (org.thingsboard.server.common.msg.queue.QueueToRuleEngineMsg)1 RuleNodeException (org.thingsboard.server.common.msg.queue.RuleNodeException)1 ToRuleEngineMsg (org.thingsboard.server.gen.transport.TransportProtos.ToRuleEngineMsg)1 TbProtoQueueMsg (org.thingsboard.server.queue.common.TbProtoQueueMsg)1