Search in sources :

Example 1 with RuleChainAwareMsg

use of org.thingsboard.server.common.msg.aware.RuleChainAwareMsg in project thingsboard by thingsboard.

the class TenantActor method doProcess.

@Override
protected boolean doProcess(TbActorMsg msg) {
    if (cantFindTenant) {
        log.info("[{}] Processing missing Tenant msg: {}", tenantId, msg);
        if (msg.getMsgType().equals(MsgType.QUEUE_TO_RULE_ENGINE_MSG)) {
            QueueToRuleEngineMsg queueMsg = (QueueToRuleEngineMsg) msg;
            queueMsg.getMsg().getCallback().onSuccess();
        } else if (msg.getMsgType().equals(MsgType.TRANSPORT_TO_DEVICE_ACTOR_MSG)) {
            TransportToDeviceActorMsgWrapper transportMsg = (TransportToDeviceActorMsgWrapper) msg;
            transportMsg.getCallback().onSuccess();
        }
        return true;
    }
    switch(msg.getMsgType()) {
        case PARTITION_CHANGE_MSG:
            PartitionChangeMsg partitionChangeMsg = (PartitionChangeMsg) msg;
            ServiceType serviceType = partitionChangeMsg.getServiceQueueKey().getServiceType();
            if (ServiceType.TB_RULE_ENGINE.equals(serviceType)) {
                // To Rule Chain Actors
                broadcast(msg);
            } else if (ServiceType.TB_CORE.equals(serviceType)) {
                List<TbActorId> deviceActorIds = ctx.filterChildren(new TbEntityTypeActorIdPredicate(EntityType.DEVICE) {

                    @Override
                    protected boolean testEntityId(EntityId entityId) {
                        return super.testEntityId(entityId) && !isMyPartition(entityId);
                    }
                });
                deviceActorIds.forEach(id -> ctx.stop(id));
            }
            break;
        case COMPONENT_LIFE_CYCLE_MSG:
            onComponentLifecycleMsg((ComponentLifecycleMsg) msg);
            break;
        case QUEUE_TO_RULE_ENGINE_MSG:
            onQueueToRuleEngineMsg((QueueToRuleEngineMsg) msg);
            break;
        case TRANSPORT_TO_DEVICE_ACTOR_MSG:
            onToDeviceActorMsg((DeviceAwareMsg) msg, false);
            break;
        case DEVICE_ATTRIBUTES_UPDATE_TO_DEVICE_ACTOR_MSG:
        case DEVICE_CREDENTIALS_UPDATE_TO_DEVICE_ACTOR_MSG:
        case DEVICE_NAME_OR_TYPE_UPDATE_TO_DEVICE_ACTOR_MSG:
        case DEVICE_EDGE_UPDATE_TO_DEVICE_ACTOR_MSG:
        case DEVICE_RPC_REQUEST_TO_DEVICE_ACTOR_MSG:
        case DEVICE_RPC_RESPONSE_TO_DEVICE_ACTOR_MSG:
        case SERVER_RPC_RESPONSE_TO_DEVICE_ACTOR_MSG:
        case REMOVE_RPC_TO_DEVICE_ACTOR_MSG:
            onToDeviceActorMsg((DeviceAwareMsg) msg, true);
            break;
        case SESSION_TIMEOUT_MSG:
            ctx.broadcastToChildrenByType(msg, EntityType.DEVICE);
            break;
        case RULE_CHAIN_INPUT_MSG:
        case RULE_CHAIN_OUTPUT_MSG:
        case RULE_CHAIN_TO_RULE_CHAIN_MSG:
            onRuleChainMsg((RuleChainAwareMsg) msg);
            break;
        case EDGE_EVENT_UPDATE_TO_EDGE_SESSION_MSG:
            onToEdgeSessionMsg((EdgeEventUpdateMsg) msg);
            break;
        default:
            return false;
    }
    return true;
}
Also used : EntityId(org.thingsboard.server.common.data.id.EntityId) TransportToDeviceActorMsgWrapper(org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper) Edge(org.thingsboard.server.common.data.edge.Edge) TbMsg(org.thingsboard.server.common.msg.TbMsg) RuleChainManagerActor(org.thingsboard.server.actors.ruleChain.RuleChainManagerActor) EdgeEventUpdateMsg(org.thingsboard.server.common.msg.edge.EdgeEventUpdateMsg) Tenant(org.thingsboard.server.common.data.Tenant) TenantId(org.thingsboard.server.common.data.id.TenantId) DeviceActorCreator(org.thingsboard.server.actors.device.DeviceActorCreator) DefaultActorService(org.thingsboard.server.actors.service.DefaultActorService) TbActorId(org.thingsboard.server.actors.TbActorId) TbActorNotRegisteredException(org.thingsboard.server.actors.TbActorNotRegisteredException) MsgType(org.thingsboard.server.common.msg.MsgType) TenantProfile(org.thingsboard.server.common.data.TenantProfile) ActorSystemContext(org.thingsboard.server.actors.ActorSystemContext) ServiceType(org.thingsboard.server.common.msg.queue.ServiceType) QueueToRuleEngineMsg(org.thingsboard.server.common.msg.queue.QueueToRuleEngineMsg) EntityId(org.thingsboard.server.common.data.id.EntityId) TbEntityTypeActorIdPredicate(org.thingsboard.server.actors.TbEntityTypeActorIdPredicate) EntityType(org.thingsboard.server.common.data.EntityType) DeviceAwareMsg(org.thingsboard.server.common.msg.aware.DeviceAwareMsg) EdgeId(org.thingsboard.server.common.data.id.EdgeId) TbEntityActorId(org.thingsboard.server.actors.TbEntityActorId) DeviceId(org.thingsboard.server.common.data.id.DeviceId) ComponentLifecycleMsg(org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg) RuleChainType(org.thingsboard.server.common.data.rule.RuleChainType) TbActorCtx(org.thingsboard.server.actors.TbActorCtx) ComponentLifecycleEvent(org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent) ApiUsageState(org.thingsboard.server.common.data.ApiUsageState) PartitionChangeMsg(org.thingsboard.server.common.msg.queue.PartitionChangeMsg) EdgeRpcService(org.thingsboard.server.service.edge.rpc.EdgeRpcService) RuleEngineException(org.thingsboard.server.common.msg.queue.RuleEngineException) Slf4j(lombok.extern.slf4j.Slf4j) TbActorException(org.thingsboard.server.actors.TbActorException) List(java.util.List) TbActorMsg(org.thingsboard.server.common.msg.TbActorMsg) RuleChain(org.thingsboard.server.common.data.rule.RuleChain) Optional(java.util.Optional) ContextBasedCreator(org.thingsboard.server.actors.service.ContextBasedCreator) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) RuleChainAwareMsg(org.thingsboard.server.common.msg.aware.RuleChainAwareMsg) TbActor(org.thingsboard.server.actors.TbActor) TbActorRef(org.thingsboard.server.actors.TbActorRef) QueueToRuleEngineMsg(org.thingsboard.server.common.msg.queue.QueueToRuleEngineMsg) ServiceType(org.thingsboard.server.common.msg.queue.ServiceType) PartitionChangeMsg(org.thingsboard.server.common.msg.queue.PartitionChangeMsg) List(java.util.List) TransportToDeviceActorMsgWrapper(org.thingsboard.server.service.transport.msg.TransportToDeviceActorMsgWrapper) TbEntityTypeActorIdPredicate(org.thingsboard.server.actors.TbEntityTypeActorIdPredicate)

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 Slf4j (lombok.extern.slf4j.Slf4j)1 ActorSystemContext (org.thingsboard.server.actors.ActorSystemContext)1 TbActor (org.thingsboard.server.actors.TbActor)1 TbActorCtx (org.thingsboard.server.actors.TbActorCtx)1 TbActorException (org.thingsboard.server.actors.TbActorException)1 TbActorId (org.thingsboard.server.actors.TbActorId)1 TbActorNotRegisteredException (org.thingsboard.server.actors.TbActorNotRegisteredException)1 TbActorRef (org.thingsboard.server.actors.TbActorRef)1 TbEntityActorId (org.thingsboard.server.actors.TbEntityActorId)1 TbEntityTypeActorIdPredicate (org.thingsboard.server.actors.TbEntityTypeActorIdPredicate)1 DeviceActorCreator (org.thingsboard.server.actors.device.DeviceActorCreator)1 RuleChainManagerActor (org.thingsboard.server.actors.ruleChain.RuleChainManagerActor)1 ContextBasedCreator (org.thingsboard.server.actors.service.ContextBasedCreator)1 DefaultActorService (org.thingsboard.server.actors.service.DefaultActorService)1 ApiUsageState (org.thingsboard.server.common.data.ApiUsageState)1 EntityType (org.thingsboard.server.common.data.EntityType)1 Tenant (org.thingsboard.server.common.data.Tenant)1 TenantProfile (org.thingsboard.server.common.data.TenantProfile)1