本文整理汇总了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;
}
示例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
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}