本文整理了Java中akka.actor.Props.withDispatcher()
方法的一些代码示例,展示了Props.withDispatcher()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Props.withDispatcher()
方法的具体详情如下:
包路径:akka.actor.Props
类名称:Props
方法名:withDispatcher
暂无
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: kaaproject/kaa
/**
* 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;
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: apache/usergrid
@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");
}
代码示例来源:origin: apache/usergrid
@Inject
public QueueSenderRouter() {
this.router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, QueueSender.class )
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: apache/usergrid
@Inject
public UniqueValuesRouter() {
router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, UniqueValueActor.class)
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: apache/usergrid
@Inject
public QueueWriterRouter() {
this.router = getContext().actorOf( FromConfig.getInstance().props(
Props.create( GuiceActorProducer.class, QueueWriter.class )
.withDispatcher("akka.blocking-io-dispatcher")), "router");
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: kaaproject/kaa
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;
}
代码示例来源:origin: kaaproject/kaa
/**
* 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;
}
代码示例来源:origin: kaaproject/kaa
/**
* 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");
}
代码示例来源:origin: kaaproject/kaa
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());
}
代码示例来源:origin: kaaproject/kaa
/**
* 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());
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-connectivity-messaging
static Props propsWithOwnDispatcher(final Connection connection, final ExceptionListener exceptionListener,
final JmsConnectionFactory jmsConnectionFactory) {
return props(connection, exceptionListener, jmsConnectionFactory)
.withDispatcher(DISPATCHER_NAME);
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
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()));
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
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()));
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
@VisibleForTesting
protected ActorRef newShardActor(final SchemaContext schemaContext, ShardInformation info) {
return getContext().actorOf(info.newProps(schemaContext)
.withDispatcher(shardDispatcherPath), info.getShardId().toString());
}
代码示例来源:origin: ajmalbabu/distributed-computing
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);
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
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;
}
}
内容来源于网络,如有侵权,请联系作者删除!