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


Java Routee类代码示例

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


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

示例1: partitionAndCreateRouter

import akka.routing.Routee; //导入依赖的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.Routee; //导入依赖的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: CrawlerActor

import akka.routing.Routee; //导入依赖的package包/类
public CrawlerActor(final UrlVisitor urlVisitor, final Indexer indexer, final DataCleaner dataCleaner, final ThrottlerConfig throttlerConfig, final List<ResponseParser> responseParsers, final DataValidator dataValidator) {
    this.urlVisited = getContext().actorOf(UrlVisitedActor.props(), "urlVisitedActor");
    this.urlVisitor = getContext().actorOf(UrlVisitorActor.props(urlVisitor), "urlVisitorActor");

    List<Routee> routes = createParserActorBroadcastRoutes(responseParsers);
    parserBroadcast = new Router(new BroadcastRoutingLogic(), routes);

    this.indexActor = getContext().actorOf(IndexActor.props(indexer), "indexActor");

    this.cleanerActor = getContext().actorOf(CleanerActor.props(dataCleaner));

    this.validatorActor = getContext().actorOf(DataValidatorActor.props(dataValidator));

    final Integer seconds = throttlerConfig.getSeconds();
    final Integer urlsPer = throttlerConfig.getUrlsPer();
    isThrottlerDisabled = throttlerConfig.isDisabled();
    this.urlThrottler = getContext().actorOf(Props.create(TimerBasedThrottler.class, new Throttler.Rate(urlsPer,
            Duration.create(seconds, TimeUnit.SECONDS))), "urlThrottler");
    urlThrottler.tell(new Throttler.SetTarget(this.urlVisitor), null);
}
 
开发者ID:tarjeir,项目名称:vitus-elasticsearch-webintegration,代码行数:21,代码来源:CrawlerActor.java

示例4: preStart

import akka.routing.Routee; //导入依赖的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

示例5: preStart

import akka.routing.Routee; //导入依赖的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

示例6: preStart

import akka.routing.Routee; //导入依赖的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

示例7: preStart

import akka.routing.Routee; //导入依赖的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: createParserActorBroadcastRoutes

import akka.routing.Routee; //导入依赖的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


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