/** Returns the actors to broadcast trace events to. */ private List<Routee> makeRoutes() { return Registry.policies(settings).stream().map(policy -> { ActorRef actorRef = context().actorOf(Props.create(PolicyActor.class, policy)); context().watch(actorRef); return new ActorRefRoutee(actorRef); }).collect(toList()); }
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; }
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 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; }
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; }
/** * 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; }
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()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
public ActorRef actorRef(String actorId, ActorContext context) { return context.actorOf(create(actorId)); }
ActorRef actorFor(DOMEntityOwnershipListener listener) { if(actorRef == null) { actorRef = actorContext.actorOf(EntityOwnershipListenerActor.props(listener)); LOG.debug("{}: Created EntityOwnershipListenerActor {} for listener {}", logId, actorRef, listener); } return actorRef; }
@Override public void onReceive(Object message) throws Exception { if (message instanceof DeadLetter) { System.out.println("DEAD LETTER x_x "+message); } else { if ("born".equals(message)) { child = context().actorOf(Props.create(MyChildActor.class),"childActor"); } else { child.tell(message, self()); } } }
/** Returns the actors to broadcast trace events to. */ private List<Routee> makeRoutes() { return Registry.policies(settings).stream().map(policy -> { ActorRef actorRef = context().actorOf(Props.create(PolicyActor.class, policy)); context().watch(actorRef); return new ActorRefRoutee(actorRef); }).collect(toList()); }
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; } }
static ShardSnapshotCohort create(final ActorContext actorContext, final MemberName memberName, final ShardDataTree store, final Logger log, final String logId) { final LocalHistoryIdentifier applyHistoryId = new LocalHistoryIdentifier(ClientIdentifier.create( FrontendIdentifier.create(memberName, SNAPSHOT_APPLY), 0), 0); final String snapshotActorName = "shard-" + memberName.getName() + ':' + "snapshot-read"; // Create a snapshot actor. This actor will act as a worker to offload snapshot serialization for all // requests. final ActorRef snapshotActor = actorContext.actorOf(ShardSnapshotActor.props(), snapshotActorName); return new ShardSnapshotCohort(applyHistoryId, snapshotActor, store, log, logId); }