private ActorRef getOrCreateTenantActorByTokenId(String tenantId) { ActorRef tenantActor = tenants.get(tenantId); if (tenantActor == null) { tenantActor = context().actorOf( Props.create(new TenantActor.ActorCreator(context, tenantId)) .withDispatcher(CORE_DISPATCHER_NAME), tenantId); tenants.put(tenantId, tenantActor); } return tenantActor; }
/** * Gets the or create application actor. * * @param appToken the app token * @return the or create application actor */ private ActorRef getOrCreateApplicationActor(String appToken) { ActorRef applicationActor = applications.get(appToken); if (applicationActor == null) { applicationActor = context().actorOf( Props.create(new ApplicationActor.ActorCreator(context, tenantId, appToken)) .withDispatcher(CORE_DISPATCHER_NAME), appToken); applications.put(appToken, applicationActor); } return applicationActor; }
private ActorRef getOrCreateUserActor(String userId) { String localUserId = toLocal(userId); ActorRef userActor = localUsers.get(localUserId); if (userActor == null && userId != null) { userActor = context().actorOf( Props.create(new LocalUserActor.ActorCreator(context, userId, tenantId)) .withDispatcher(USER_DISPATCHER_NAME), localUserId); LOG.debug("Create local user actor with id {}", userId); localUsers.put(localUserId, userActor); context().watch(userActor); } return userActor; }
@Inject public QueueActorRouter( QueueActorRouterProducer queueActorRouterProducer, QakkaFig qakkaFig ) { this.queueActorRouterProducer = queueActorRouterProducer; this.qakkaFig = qakkaFig; this.routerRef = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueActor.class) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
@Inject public QueueSenderRouter() { this.router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueSender.class ) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
@Inject public UniqueValuesRouter() { router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, UniqueValueActor.class) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
@Inject public QueueWriterRouter() { this.router = getContext().actorOf( FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, QueueWriter.class ) .withDispatcher("akka.blocking-io-dispatcher")), "router"); }
private ActorRef getOrCreateGlobalUserActor(String userId) { String globalUserId = toGlobal(userId); ActorRef userActor = globalUsers.get(globalUserId); if (userActor == null && userId != null) { userActor = context().actorOf( Props.create(new GlobalUserActor.ActorCreator(context, userId, tenantId)) .withDispatcher(USER_DISPATCHER_NAME), globalUserId); LOG.debug("Create global user actor with id {}", userId); globalUsers.put(globalUserId, userActor); context().watch(userActor); } return userActor; }
private ActorRef getOrCreateLogActor(String name) { ActorRef logActor = logsSessions.get(name); if (logActor == null) { logActor = context().actorOf( Props.create(new ApplicationLogActor.ActorCreator(context, appToken)) .withDispatcher(LOG_DISPATCHER_NAME) ); context().watch(logActor); logsSessions.put(logActor.path().name(), logActor); } return logActor; }
private ActorRef getOrCreateUserVerifierActor(String name) { ActorRef userVerifierActor = userVerifierSessions.get(name); if (userVerifierActor == null) { userVerifierActor = context() .actorOf( Props.create(new ApplicationUserVerifierActor.ActorCreator(context, appToken)) .withDispatcher(VERIFIER_DISPATCHER_NAME) ); context().watch(userVerifierActor); userVerifierSessions.put(userVerifierActor.path().name(), userVerifierActor); } return userVerifierActor; }
/** * Gets the or create topic. * * @param topicId the topic id * @return the or create topic */ private ActorRef getOrCreateTopic(String topicId) { ActorRef topicActor = topicSessions.get(topicId); if (topicActor == null) { topicActor = context().actorOf( Props.create(new TopicActor.ActorCreator(context.getNotificationDeltaService())) .withDispatcher(TOPIC_DISPATCHER_NAME), buildTopicKey(topicId) ); topicSessions.put(topicId, topicActor); context().watch(topicActor); } return topicActor; }
/** * Inits the actor system. */ @PostConstruct public void initActorSystem() { LOG.info("Initializing Akka system..."); akka = ActorSystem.create(EPS, context.getConfig()); LOG.info("Initializing Akka EPS actor..."); opsActor = akka.actorOf(Props.create( new OperationsServerActor.ActorCreator(context)) .withDispatcher(CORE_DISPATCHER_NAME), EPS); LOG.info("Lookup platform protocols"); Set<String> platformProtocols = PlatformLookup.lookupPlatformProtocols( PlatformLookup.DEFAULT_PROTOCOL_LOOKUP_PACKAGE_NAME); LOG.info("Initializing Akka io router..."); ioRouter = akka.actorOf( new RoundRobinPool(context.getIoWorkerCount()) .withSupervisorStrategy(SupervisionStrategyFactory.createIoRouterStrategy(context)) .props(Props.create(new EncDecActor.ActorCreator(opsActor, context, platformProtocols)) .withDispatcher(IO_DISPATCHER_NAME)), IO_ROUTER_ACTOR_NAME); LOG.info("Initializing Akka event service listener..."); eventListener = new AkkaEventServiceListener(opsActor); context.getEventService().addListener(eventListener); clusterListener = new AkkaClusterServiceListener(opsActor); context.getClusterService().setListener(clusterListener); LOG.info("Initializing Akka system done"); }
private void processEndpointRouteMessage(EndpointRouteMessage msg) { EndpointObjectHash endpointKey = msg.getAddress().getEndpointKey(); GlobalEndpointActorMetaData actorMetaData = globalEndpointSessions.get(endpointKey); if (actorMetaData == null) { String endpointActorId = GlobalEndpointActorCreator.generateActorKey(); LOG.debug("[{}] Creating global endpoint actor for endpointKey: {}", appToken, endpointKey); actorMetaData = new GlobalEndpointActorMetaData( context().actorOf(Props.create( new GlobalEndpointActorCreator(context, endpointActorId, appToken, endpointKey)) .withDispatcher(ENDPOINT_DISPATCHER_NAME), endpointActorId), endpointActorId); globalEndpointSessions.put(endpointKey, actorMetaData); context().watch(actorMetaData.actorRef); } actorMetaData.actorRef.tell(msg, self()); }
/** * Process session endpoint request. * * @param message the message */ private void processEndpointRequest(EndpointAwareMessage message) { LocalEndpointActorMetaData actorMetaData = localEndpointSessions.get(message.getKey()); if (actorMetaData == null) { EndpointObjectHash endpointKey = message.getKey(); String endpointActorId = LocalEndpointActorCreator.generateActorKey(); LOG.debug("[{}] Creating actor with endpointKey: {}", appToken, endpointActorId); String globalActorNodeId = getGlobalEndpointActorNodeId(endpointKey); actorMetaData = new LocalEndpointActorMetaData(context() .actorOf(Props .create(new LocalEndpointActorCreator( context, endpointActorId, message.getAppToken(), message.getKey() )).withDispatcher(ENDPOINT_DISPATCHER_NAME), endpointActorId), endpointActorId, globalActorNodeId); localEndpointSessions.put(message.getKey(), actorMetaData); endpointActorMap.put(endpointActorId, message.getKey()); context().watch(actorMetaData.actorRef); notifyGlobalEndpointActor(endpointKey, globalActorNodeId); } actorMetaData.actorRef.tell(message, self()); }
static Props propsWithOwnDispatcher(final Connection connection, final ExceptionListener exceptionListener, final JmsConnectionFactory jmsConnectionFactory) { return props(connection, exceptionListener, jmsConnectionFactory) .withDispatcher(DISPATCHER_NAME); }
DataTreeCohortRegistrationProxy(ActorContext actorContext, DOMDataTreeIdentifier subtree, C cohort) { super(cohort); this.subtree = Preconditions.checkNotNull(subtree); this.actorContext = Preconditions.checkNotNull(actorContext); this.actor = actorContext.getActorSystem().actorOf( DataTreeCohortActor.props(getInstance()).withDispatcher(actorContext.getNotificationDispatcherPath())); }
public DataTreeChangeListenerProxy(final ActorContext actorContext, final T listener) { super(listener); this.actorContext = Preconditions.checkNotNull(actorContext); this.dataChangeListenerActor = actorContext.getActorSystem().actorOf( DataTreeChangeListenerActor.props(getInstance()).withDispatcher(actorContext.getNotificationDispatcherPath())); }
@VisibleForTesting protected ActorRef newShardActor(final SchemaContext schemaContext, ShardInformation info) { return getContext().actorOf(info.newProps(schemaContext) .withDispatcher(shardDispatcherPath), info.getShardId().toString()); }
public ActorRef actorOf(ActorSystem actorSystem, String actorSpringBeanName, RouterConfig routerConfig, String dispatcher, Parameters actorParameters, String actorLogicalName) { return actorSystem.actorOf(get(actorSystem).props(actorSpringBeanName, actorParameters).withRouter(routerConfig).withDispatcher(dispatcher), actorLogicalName); }
private ActorRef getNotifierActor() { if(notifierActor == null) { LOG.debug("Creating actor {}", actorName); String dispatcher = new Dispatchers(actorContext.system().dispatchers()).getDispatcherPath( Dispatchers.DispatcherType.Notification); notifierActor = actorContext.actorOf(ShardDataTreeNotificationPublisherActor.props(actorName) .withDispatcher(dispatcher).withMailbox( org.opendaylight.controller.cluster.datastore.utils.ActorContext.BOUNDED_MAILBOX), actorName); } return notifierActor; } }