Search in sources :

Example 1 with TbActorException

use of org.thingsboard.server.actors.TbActorException in project thingsboard by thingsboard.

the class DeviceActor method init.

@Override
public void init(TbActorCtx ctx) throws TbActorException {
    super.init(ctx);
    log.debug("[{}][{}] Starting device actor.", processor.tenantId, processor.deviceId);
    try {
        processor.init(ctx);
        log.debug("[{}][{}] Device actor started.", processor.tenantId, processor.deviceId);
    } catch (Exception e) {
        log.warn("[{}][{}] Unknown failure", processor.tenantId, processor.deviceId, e);
        throw new TbActorException("Failed to initialize device actor", e);
    }
}
Also used : TbActorException(org.thingsboard.server.actors.TbActorException) TbActorException(org.thingsboard.server.actors.TbActorException)

Example 2 with TbActorException

use of org.thingsboard.server.actors.TbActorException in project thingsboard by thingsboard.

the class TenantActor method init.

@Override
public void init(TbActorCtx ctx) throws TbActorException {
    super.init(ctx);
    log.debug("[{}] Starting tenant actor.", tenantId);
    try {
        Tenant tenant = systemContext.getTenantService().findTenantById(tenantId);
        if (tenant == null) {
            cantFindTenant = true;
            log.info("[{}] Started tenant actor for missing tenant.", tenantId);
        } else {
            // This Service may be started for specific tenant only.
            Optional<TenantId> isolatedTenantId = systemContext.getServiceInfoProvider().getIsolatedTenant();
            TenantProfile tenantProfile = systemContext.getTenantProfileCache().get(tenant.getTenantProfileId());
            isCore = systemContext.getServiceInfoProvider().isService(ServiceType.TB_CORE);
            isRuleEngine = systemContext.getServiceInfoProvider().isService(ServiceType.TB_RULE_ENGINE);
            if (isRuleEngine) {
                try {
                    if (isolatedTenantId.map(id -> id.equals(tenantId)).orElseGet(() -> !tenantProfile.isIsolatedTbRuleEngine())) {
                        if (getApiUsageState().isReExecEnabled()) {
                            log.debug("[{}] Going to init rule chains", tenantId);
                            initRuleChains();
                        } else {
                            log.info("[{}] Skip init of the rule chains due to API limits", tenantId);
                        }
                    } else {
                        isRuleEngine = false;
                    }
                } catch (Exception e) {
                    cantFindTenant = true;
                }
            }
            log.debug("[{}] Tenant actor started.", tenantId);
        }
    } catch (Exception e) {
        log.warn("[{}] Unknown failure", tenantId, e);
    }
}
Also used : 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) TenantId(org.thingsboard.server.common.data.id.TenantId) Tenant(org.thingsboard.server.common.data.Tenant) TenantProfile(org.thingsboard.server.common.data.TenantProfile) TbActorNotRegisteredException(org.thingsboard.server.actors.TbActorNotRegisteredException) RuleEngineException(org.thingsboard.server.common.msg.queue.RuleEngineException) TbActorException(org.thingsboard.server.actors.TbActorException)

Example 3 with TbActorException

use of org.thingsboard.server.actors.TbActorException in project thingsboard by thingsboard.

the class ComponentActor method initProcessor.

protected void initProcessor(TbActorCtx ctx) throws TbActorException {
    try {
        log.debug("[{}][{}][{}] Starting processor.", tenantId, id, id.getEntityType());
        processor.start(ctx);
        logLifecycleEvent(ComponentLifecycleEvent.STARTED);
        if (systemContext.isStatisticsEnabled()) {
            scheduleStatsPersistTick();
        }
    } catch (Exception e) {
        log.debug("[{}][{}] Failed to start {} processor.", tenantId, id, id.getEntityType(), e);
        logAndPersist("OnStart", e, true);
        logLifecycleEvent(ComponentLifecycleEvent.STARTED, e);
        throw new TbActorException("Failed to init actor", e);
    }
}
Also used : TbActorException(org.thingsboard.server.actors.TbActorException) TbRuleNodeUpdateException(org.thingsboard.server.actors.TbRuleNodeUpdateException) TbActorException(org.thingsboard.server.actors.TbActorException)

Aggregations

TbActorException (org.thingsboard.server.actors.TbActorException)3 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 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 TbRuleNodeUpdateException (org.thingsboard.server.actors.TbRuleNodeUpdateException)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