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


Java RoundRobinPool类代码示例

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


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

示例1: shouldReadFilesWithActors

import akka.routing.RoundRobinPool; //导入依赖的package包/类
@Test
public void shouldReadFilesWithActors() throws Exception {

    ActorRef workerRouter = system.actorOf(Props.create(ArticleParseActor.class).
                    withRouter(new RoundRobinPool(8)));

    CompletableFuture future = new CompletableFuture();
    ActorRef cameoActor = system.actorOf(Props.create(TestCameoActor.class, future));

    IntStream.range(0, 2000).forEach(x -> {
                workerRouter.tell(
                        new ParseArticle(TestHelper.file)
                        , cameoActor);
            }
    );

    long start = System.currentTimeMillis();
    future.get();
    long elapsedTime = System.currentTimeMillis() - start;
    System.out.println("ReadFilesWithActorsTest Took: " + elapsedTime);

}
 
开发者ID:jasongoodwin,项目名称:learning-akka,代码行数:23,代码来源:ReadFilesWithActorsTest.java

示例2: startEventMessageProcessingActor

import akka.routing.RoundRobinPool; //导入依赖的package包/类
/**
 * Start the router associated with the specified flow type (IN or OUT).
 * 
 * @param pluginRegistrationEntry
 *            a plugin registration entry
 * @param flowType
 *            a type of flow
 * @return the actor ref created
 */
private ActorRef startEventMessageProcessingActor(PluginRegistrationEntry pluginRegistrationEntry, FlowType flowType) {
    ActorRef actorRef = null;
    EventInterfaceConfiguration eventInterfaceConfiguration = null;

    if (flowType.equals(FlowType.IN)) {
        eventInterfaceConfiguration = (pluginRegistrationEntry.getDescriptor().hasInMessageInterface() ? new EventInterfaceConfiguration() : null);
    } else {
        eventInterfaceConfiguration = (pluginRegistrationEntry.getDescriptor().hasOutMessageInterface() ? new EventInterfaceConfiguration() : null);
    }
    if (eventInterfaceConfiguration != null) {
        actorRef = getActorSystem().actorOf(
                (new RoundRobinPool(eventInterfaceConfiguration.getPoolSize()))
                        .withSupervisorStrategy(getSupervisorStrategy(eventInterfaceConfiguration.getNumberOfRetry(),
                                eventInterfaceConfiguration.getRetryDuration(), pluginRegistrationEntry.getPluginConfigurationId()))
                .props(Props.create(new EventMessageProcessingActorCreator(pluginRegistrationEntry.getPluginConfigurationId(),
                        pluginRegistrationEntry.getPluginRunner(), FlowType.OUT))),
                flowType.getRouterPrefix() + pluginRegistrationEntry.getPluginConfigurationId() + "-" + UUID.randomUUID().toString());
        String message = "The %s interface for the plugin %d has been started";
        log.info(String.format(message, flowType.name(), pluginRegistrationEntry.getPluginConfigurationId()));
        return actorRef;
    }
    return null;
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:33,代码来源:PluginManagerServiceImpl.java

示例3: GenerateActor

import akka.routing.RoundRobinPool; //导入依赖的package包/类
/**
 * Instantiates a new Generate actor.
 *
 * @param config the config
 * @param callback the callback
 */
public GenerateActor(GeneratorConfig config, Callback callback)
{
  this.config = config;
  this.callback = callback;

  // lookups
  jobKeys = new HashSet<>();
  jobCountLookup = new HashMap<>();

  // create pool of workers
  RoundRobinPool roundRobinPool = new RoundRobinPool(config.getThreads());
  workerPool = getContext().system().actorOf(roundRobinPool.props(Props.create(GenerateWorkActor.class)));

  // lets delegate some work
  for(int i = 0; i < config.getThreads(); i++)
  {
    String jobKey = UUID.randomUUID().toString();
    jobKeys.add(jobKey);
    workerPool.tell(new GenerateWorkMsg(jobKey, config), getSelf());
  }
}
 
开发者ID:de-luxe,项目名称:burstcoin-address-generator,代码行数:28,代码来源:GenerateActor.java

示例4: initActorSystem

import akka.routing.RoundRobinPool; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:28,代码来源:DefaultAkkaService.java

示例5: TaskRunner

import akka.routing.RoundRobinPool; //导入依赖的package包/类
public TaskRunner() {
    this.taskActor =
        context().actorOf(
            Props.create(TaskActor.class).withRouter(new RoundRobinPool(10)),
            "task"
        );

    receive(
        ReceiveBuilder
            .matchEquals("start", msg -> {
                for (int i = 0; i < numRuns; i++) {
                    taskActor.tell("run", self());
                    activeTasks++;
                }
                originator = sender();
            })
            .match(Long.class, msg -> {
                currentSum += msg;
                activeTasks--;
                if (activeTasks == 0) {
                    originator.tell(currentSum, self());
                }
            })
            .matchEquals("progress", msg -> printProgress(activeTasks))
            .build()
    );
}
 
开发者ID:ChristinGorman,项目名称:javazone2016,代码行数:28,代码来源:Akka.java

示例6: createRouter

import akka.routing.RoundRobinPool; //导入依赖的package包/类
/**
 * bean factory to create pool of the master client actors, the pool is used in a round robin manner
 * @param system
 * @param pool
 * @param masterName
 * @return
 */
@Bean
public ActorRef createRouter(ActorSystem system,
                             @Value("${master.client.pool}") int pool,
                             @Value("${master.name}") String masterName){
    ActorRef router1 = system.actorOf(new RoundRobinPool(pool).props(Props.create(MasterClientActor.class,system,masterName)), "router");
    return router1;
}
 
开发者ID:Abiy,项目名称:distGatling,代码行数:15,代码来源:SystemConfig.java

示例7: createOrResize

import akka.routing.RoundRobinPool; //导入依赖的package包/类
@Override
public void createOrResize(String routerName, int newSize) {
    if(!routerMap.containsKey(routerName)) {
        final ActorSystem actorSystem = actorSystemManager.retrieveActorSystem();
        //create a local router with configured no.of task actors and keep the router reference in routerMap
        ActorRef router = actorSystem.actorOf(new RoundRobinPool(newSize).withSupervisorStrategy(getTasksuperviseStrategy())
                .props(Props.create(AkkaTask.class)), routerName);
        routerMap.put(routerName, router);
        logger.info("Created router: {} with no.of actors: {}", routerName, newSize);
    } else {
        // TODO ask the router to resize its pool of routees.
        logger.warn("Currently router resize is NOT SUPPORTED. To change size Flux process has to be relaunched. Received resize request for router: {}, newSize: {}", routerName, newSize);
    }
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:15,代码来源:EagerInitRouterRegistryImpl.java

示例8: Master

import akka.routing.RoundRobinPool; //导入依赖的package包/类
public Master(final int nrOfWorkers, int nrOfMessages,
		int nrOfElements, ActorRef listener) {
	this.nrOfMessages = nrOfMessages;
	this.nrOfElements = nrOfElements;
	this.listener = listener;

	workerRouter = this.getContext().actorOf(
			Props.create(Worker.class).withRouter(
					new RoundRobinPool(nrOfWorkers)), "workerRouter");
}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:11,代码来源:Pi.java

示例9: Master

import akka.routing.RoundRobinPool; //导入依赖的package包/类
public Master(final int nrOfWorkers, int nrOfMessages, int nrOfElements, ActorRef listener) {
	this.nrOfElements = nrOfElements;
	this.nrOfMessages = nrOfMessages;
	this.listener = listener;

	workerRouter = getContext()
			.actorOf(Props.create(Worker.class)
			.withRouter(new RoundRobinPool(nrOfWorkers)),
			"workerRouter");

}
 
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:12,代码来源:Master.java

示例10: createActors

import akka.routing.RoundRobinPool; //导入依赖的package包/类
private void createActors(ActorSystem actorSystem) {
    SupervisorStrategy strategy = getSupervisorStrategy(getNotificationRetryNumber(), getNotificationRetryDuration());
    this.supervisorActor = actorSystem.actorOf((new RoundRobinPool(getPoolSize())).withSupervisorStrategy(strategy)
            .props(Props.create(new NotificationMessageProcessingActorCreator(getConfiguration(), getPreferenceManagerPlugin(), getEmailService(),
                    this.getI18nMessagesPlugin()))),
            SUPERVISOR_ACTOR_NAME);
    log.info("Actor based notification system is started");
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:9,代码来源:DefaultNotificationManagerPlugin.java

示例11: Master

import akka.routing.RoundRobinPool; //导入依赖的package包/类
@Autowired
public Master(final SpringProps springProps) {
    LOGGER.debug("CREATING MASTER...");
    this.workerRouter = getContext().actorOf(springProps.create(Worker.class)
                                                     .withRouter(new RoundRobinPool(5)),
                                             "workerRouter");
}
 
开发者ID:choonchernlim,项目名称:test-akka-spring,代码行数:8,代码来源:Master.java

示例12: init

import akka.routing.RoundRobinPool; //导入依赖的package包/类
protected static void init(DialsSystemConfiguration configuration) {
    systemConfiguration = configuration;
    system = ActorSystem.create("Dials");

    system.actorOf(Props.create(ExecutionRegistry.class, configuration.getExecutionContextRecorder())
            .withRouter(new RoundRobinPool(ACTOR_COUNT)), "ExecutionRegistry");

    initialized = true;
}
 
开发者ID:BrettDuclos,项目名称:Dials,代码行数:10,代码来源:Dials.java

示例13: MainActor

import akka.routing.RoundRobinPool; //导入依赖的package包/类
public MainActor() {
    MAX_CONCURRENCY = getNumWorkers();
    workerRouter = getContext().actorOf(Props.create(WorkerActor.class).
            withRouter(new RoundRobinPool(MAX_CONCURRENCY)), "workerRouter");    
    scheduler = getContext().system().scheduler();
    WORK_GENERATE_INTERVAL = getWorkGenerateInterval();
    WORK_TRACKER_INTERVAL = getWorkTrackInterval();
}
 
开发者ID:srikalyc,项目名称:Sql4D,代码行数:9,代码来源:MainActor.java

示例14: AlbumActor

import akka.routing.RoundRobinPool; //导入依赖的package包/类
private AlbumActor() {
	database = PhotostashDatabase.INSTANCE;
	storyRouter = getContext().actorOf(new RoundRobinPool(5).props(Props.create(StoryActor.class)), "story-router");
	storiesOrganizing = new HashMap<AlbumDocument, Set<File>>();
	organizingRequestMap = new HashMap<AlbumDocument, OrganizeAlbumRequester>();
}
 
开发者ID:corbantek,项目名称:play-photostash,代码行数:7,代码来源:AlbumActor.java

示例15: ShoeboxActor

import akka.routing.RoundRobinPool; //导入依赖的package包/类
private ShoeboxActor() {
	albumRouter = getContext().actorOf(new RoundRobinPool(2).props(Props.create(AlbumActor.class)), "album-router");
	albumsOrganizing = new HashSet<File>();
}
 
开发者ID:corbantek,项目名称:play-photostash,代码行数:5,代码来源:ShoeboxActor.java


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