当前位置: 首页>>代码示例>>Java>>正文


Java ActorRefRoutee类代码示例

本文整理汇总了Java中akka.routing.ActorRefRoutee的典型用法代码示例。如果您正苦于以下问题:Java ActorRefRoutee类的具体用法?Java ActorRefRoutee怎么用?Java ActorRefRoutee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActorRefRoutee类属于akka.routing包,在下文中一共展示了ActorRefRoutee类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: partitionAndCreateRouter

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
/** partitions the market by product ID and creates an actor encapsulating an engine, per 
 * partition. returns a router containing all the kids together with the suitable logic 
 * to route to the correct engine. */
private Router partitionAndCreateRouter() {
	Map<String, ActorRef> kids = new HashMap<>();
	java.util.List<Routee> routees = new ArrayList<Routee>();
	int chunk = Constants.PRODUCT_IDS.length / NUM_KIDS;
	for (int i = 0, j = Constants.PRODUCT_IDS.length; i < j; i += chunk) {
	    String[] temparray = Arrays.copyOfRange(Constants.PRODUCT_IDS, i, i + chunk);
	    LOGGER.info("created engine for products " + temparray);
	    ActorRef actor = getContext().actorOf(Props.create(EngineActor.class));
	    getContext().watch(actor);
	    routees.add(new ActorRefRoutee(actor));

	    for (int k = 0; k < temparray.length; k++) {
	    	LOGGER.debug("mapping productId '" + temparray[k] + "' to engine " + i);
	    	kids.put(temparray[k], actor);
	    }
	    LOGGER.info("---started trading");
	    actor.tell(EngineActor.RUN, ActorRef.noSender());
	}			
	Router router = new Router(new PartitioningRoutingLogic(kids), routees);
	return router;
}
 
开发者ID:maxant,项目名称:akkaTrader,代码行数:25,代码来源:Main.java

示例2: select

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public Routee select(Object message, IndexedSeq<Routee> routees) {

	//find which product ID is relevant here
	String productId = null;
	if(message instanceof PurchaseOrder){
		productId = ((PurchaseOrder) message).getProductId();
	}else if(message instanceof SalesOrder){
		productId = ((SalesOrder) message).getProductId();
	}
	ActorRef actorHandlingProduct = kids.get(productId);

	//no go find the routee for the relevant actor
	for(Routee r : JavaConversions.asJavaIterable(routees)){
		ActorRef a = ((ActorRefRoutee) r).ref(); //cast ok, since the are by definition in this program all routees to ActorRefs
		if(a.equals(actorHandlingProduct)){
			return r;
		}
	}
	
	return akka.routing.NoRoutee$.MODULE$; //none found, return NoRoutee
}
 
开发者ID:maxant,项目名称:akkaTrader,代码行数:23,代码来源:Main.java

示例3: preStart

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void preStart() {
    Optional<PeerURLType> peerURL = discoveryConfiguration.getDiscoveryURL()
            .stream()
            .filter((url) -> url.getType().equalsIgnoreCase(NsiConstants.NSI_TOPOLOGY_V1))
            .findFirst();

    isConfigured = peerURL.isPresent();
    if (isConfigured) {
        manifestReader.setTarget(peerURL.get().getValue());
    }
    else {
        log.info("AgoleDiscoveryRouter: No AGOLE URL provisioned so disabling audit.");
        return;
    }

    List<Routee> routees = new ArrayList<>();
    for (int i = 0; i < getPoolSize(); i++) {
        ActorRef r = getContext().actorOf(Props.create(AgoleDiscoveryActor.class));
        getContext().watch(r);
        routees.add(new ActorRefRoutee(r));
    }
    router = new Router(new RoundRobinRoutingLogic(), routees);
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:25,代码来源:AgoleDiscoveryRouter.java

示例4: preStart

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void preStart() {
    List<Routee> routees = new ArrayList<>();
    for (int i = 0; i < getPoolSize(); i++) {
        ActorRef r = getContext().actorOf(Props.create(RegistrationActor.class, discoveryConfiguration, remoteSubscriptionCache));
        getContext().watch(r);
        routees.add(new ActorRefRoutee(r));
    }
    router = new Router(new RoundRobinRoutingLogic(), routees);
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:11,代码来源:RegistrationRouter.java

示例5: preStart

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void preStart() {
    List<Routee> routees = new ArrayList<>();
    for (int i = 0; i < getPoolSize(); i++) {
        ActorRef r = getContext().actorOf(Props.create(NotificationActor.class, discoveryConfiguration.getNsaId(), restClient));
        getContext().watch(r);
        routees.add(new ActorRefRoutee(r));
    }
    router = new Router(new RoundRobinRoutingLogic(), routees);
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:11,代码来源:NotificationRouter.java

示例6: onReceive

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void onReceive(Object msg) {
    if (msg instanceof DocumentEvent) {
        // We have a document event.
        DocumentEvent de = (DocumentEvent) msg;
        log.debug("NotificationRouter: document event {}, id={}", de.getEvent(), de.getDocument().getId());
        routeDocumentEvent(de);
    }
    else if (msg instanceof SubscriptionEvent) {
        // We have a subscription event.
        SubscriptionEvent se = (SubscriptionEvent) msg;
        log.debug("NotificationRouter: subscription event id={}, requesterId={}", se.getSubscription().getId(), se.getSubscription().getSubscription().getRequesterId());
        routeSubscriptionEvent(se);
    }
    else if (msg instanceof Terminated) {
        log.debug("NotificationRouter: terminate event.");
        router = router.removeRoutee(((Terminated) msg).actor());
        ActorRef r = getContext().actorOf(Props.create(NotificationActor.class));
        getContext().watch(r);
        router = router.addRoutee(new ActorRefRoutee(r));
    }
    else if (msg instanceof StartMsg) {
        // We ignore these for now as we have no specific start task.
    }
    else {
        log.debug("NotificationRouter: unhandled event = {}", msg.getClass().getName());
        unhandled(msg);
    }
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:30,代码来源:NotificationRouter.java

示例7: preStart

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void preStart() {
    List<Routee> routees = new ArrayList<>();
    for (int i = 0; i < getPoolSize(); i++) {
        ActorRef r = getContext().actorOf(Props.create(Gof3DiscoveryActor.class));
        getContext().watch(r);
        routees.add(new ActorRefRoutee(r));
    }
    router = new Router(new RoundRobinRoutingLogic(), routees);
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:11,代码来源:Gof3DiscoveryRouter.java

示例8: onReceive

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void onReceive(Object msg) {
    TimerMsg message = new TimerMsg();

    // Check to see if we got the go ahead to start registering.
    if (msg instanceof StartMsg) {
        // Create a Register event to start us off.
        msg = message;
    }

    if (msg instanceof TimerMsg) {
        routeTimerEvent();
        ddsActorSystem.getActorSystem().scheduler().scheduleOnce(Duration.create(getInterval(), TimeUnit.SECONDS), this.getSelf(), message, ddsActorSystem.getActorSystem().dispatcher(), null);
    }
    else if (msg instanceof Gof3DiscoveryMsg) {
        Gof3DiscoveryMsg incoming = (Gof3DiscoveryMsg) msg;

        log.debug("onReceive: discovery update for nsaId=" + incoming.getNsaId());

        discovery.put(incoming.getNsaURL(), incoming);
    }
    else if (msg instanceof Terminated) {
        log.debug("onReceive: terminate event.");
        router = router.removeRoutee(((Terminated) msg).actor());
        ActorRef r = getContext().actorOf(Props.create(Gof3DiscoveryActor.class));
        getContext().watch(r);
        router = router.addRoutee(new ActorRefRoutee(r));
    }
    else {
        log.error("onReceive: unhandled event.");
        unhandled(msg);
    }
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:34,代码来源:Gof3DiscoveryRouter.java

示例9: createParserActorBroadcastRoutes

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
private List<Routee> createParserActorBroadcastRoutes(List<ResponseParser> responseParsers) {
    return responseParsers.stream().map(responseParser -> {
        final ActorRef parserActorRef = getContext().actorOf(ParserActor.props(responseParser));
        return new ActorRefRoutee(parserActorRef);
    }).collect(Collectors.toList());
}
 
开发者ID:tarjeir,项目名称:vitus-elasticsearch-webintegration,代码行数:7,代码来源:CrawlerActor.java

示例10: onReceive

import akka.routing.ActorRefRoutee; //导入依赖的package包/类
@Override
public void onReceive(Object msg) {
    TimerMsg message = new TimerMsg();

    // Check to see if we got the go ahead to start registering.
    if (msg instanceof StartMsg) {
        // Create a Register event to start us off.
        msg = message;
        if (!isConfigured) {
            log.info("onReceive: StartMsg no AGOLE URL provisioned so disabling audit.");
            return;
        }
    }

    if (msg instanceof TimerMsg) {
        log.debug("onReceive: timer event.");
        if (!isConfigured) {
            log.info("onReceive: TimerMsg no AGOLE URL provisioned so disabling audit.");
            return;
        }
        if (readManifest() != null) {
            routeTimerEvent();
        }

        ddsActorSystem.getActorSystem().scheduler().scheduleOnce(Duration.create(getInterval(), TimeUnit.SECONDS), this.getSelf(), message, ddsActorSystem.getActorSystem().dispatcher(), null);
    }
    else if (msg instanceof AgoleDiscoveryMsg) {
        AgoleDiscoveryMsg incoming = (AgoleDiscoveryMsg) msg;

        log.debug("onReceive: discovery update for nsaId={}", incoming.getNsaId());

        discovery.put(incoming.getTopologyURL(), incoming);
    }
    else if (msg instanceof Terminated) {
        log.debug("onReceive: terminate event.");
        if (router != null) {
            router = router.removeRoutee(((Terminated) msg).actor());
            ActorRef r = getContext().actorOf(Props.create(AgoleDiscoveryActor.class));
            getContext().watch(r);
            router = router.addRoutee(new ActorRefRoutee(r));
        }
    }
    else {
        log.debug("onReceive: unhandled event.");
        unhandled(msg);
    }
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:48,代码来源:AgoleDiscoveryRouter.java


注:本文中的akka.routing.ActorRefRoutee类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。