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


Java RoundRobinRouter类代码示例

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


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

示例1: run

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @see com.yammer.dropwizard.Service#run(com.yammer.dropwizard.config.Configuration, com.yammer.dropwizard.config.Environment)
 */
public void run(WebtrendsKafkaProducerServiceConfiguration configuration, Environment environment) throws Exception {
	
	this.actorSystem = ActorSystem.create("webtrends-kafka-producer");
	
	if(configuration.getKafkaProducer().getNumOfProducers() > 1) {
		this.webtrendsKafkaProducerRef = actorSystem.actorOf(
			Props.create(
					WebtrendsKafkaProducer.class, configuration.getKafkaProducer()).withRouter(new RoundRobinRouter(configuration.getKafkaProducer().getNumOfProducers())));
	} else {
		this.webtrendsKafkaProducerRef = actorSystem.actorOf(
				Props.create(
						WebtrendsKafkaProducer.class, configuration.getKafkaProducer()));
	}

	actorSystem.actorOf(Props.create(WebtrendsStreamListenerActor.class, configuration.getWebtrendsStreamListener(), webtrendsKafkaProducerRef));
	
	environment.jersey().register(new KafkaProducerStatisticsResource());
}
 
开发者ID:mnxfst,项目名称:webtrends-kafka-producer,代码行数:22,代码来源:WebtrendsKafkaProducerService.java

示例2: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
	ActorSystem _system = ActorSystem.create("RoundRobinRouterExample");
	ActorRef roundRobinRouter = _system.actorOf(new Props(
			MsgEchoActor.class).withRouter(new RoundRobinRouter(5)),"myRoundRobinRouterActor");

	for (int i = 1; i <= 10; i++) {
		//sends messages in a round robin way to all the actors
		roundRobinRouter.tell(i);
		if (i == 5) {
			TimeUnit.MILLISECONDS.sleep(100);
			System.out.println("\n");
		}
	}
	_system.shutdown();
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:20,代码来源:Example.java

示例3: addWorkerRoute

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * Add the new worker to the router mechanism
 * 
 * @param address
 */
private void addWorkerRoute(String address) {

	// send the stop message to all the worker actors
	if (workerRouterActor != null) {
		for (int i = 0; i < workerAddressMap.size(); i++)
			workerRouterActor.tell("STOP");
	}

	// add the address to the Map
	workerAddressMap.put(address, AddressFromURIString.parse(address));

	Address[] addressNodes = new Address[workerAddressMap.size()];

	Address[] workerAddress = workerAddressMap.values().toArray(
			addressNodes);

	// update the workerRouter actor with the information on all workers
	workerRouterActor = getContext().system().actorOf(
			new Props(WorkerActor.class).withRouter(new RemoteRouterConfig(
					new RoundRobinRouter(workerAddress.length),
					workerAddress)));

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:29,代码来源:JobControllerActor.java

示例4: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	ActorSystem _system = ActorSystem.create("balancing-dispatcher",
			ConfigFactory.load().getConfig("MyDispatcherExample"));
	
	ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
			.withDispatcher("balancingDispatcher").withRouter(
					new RoundRobinRouter(5)));

	for (int i = 0; i < 25; i++) {
		actor.tell(i);
	}

	_system.shutdown();

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:Example1.java

示例5: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	ActorSystem _system = ActorSystem.create("balancing-dispatcher",
			ConfigFactory.load().getConfig("MyDispatcherExample"));
	
	ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
			.withDispatcher("balancingDispatcher1").withRouter(
					new RoundRobinRouter(5)));

	for (int i = 0; i < 25; i++) {
		actor.tell(i);
	}

	_system.shutdown();

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:Example2.java

示例6: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	ActorSystem _system = ActorSystem.create("pinned-dispatcher",
			ConfigFactory.load().getConfig("MyDispatcherExample"));
	
	ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
			.withDispatcher("pinnedDispatcher").withRouter(
					new RoundRobinRouter(5)));

	for (int i = 0; i < 25; i++) {
		actor.tell(i);
	}

	_system.shutdown();

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:Example.java

示例7: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	ActorSystem _system = ActorSystem.create("callingThread-dispatcher",
			ConfigFactory.load().getConfig("MyDispatcherExample"));
	
	ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
			.withDispatcher("CallingThreadDispatcher").withRouter(
					new RoundRobinRouter(2)));

	for (int i = 0; i < 5; i++) {
		actor.tell(i);
	}

	_system.shutdown();

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:Example.java

示例8: main

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	ActorSystem _system = ActorSystem.create("default-dispatcher",
			ConfigFactory.load().getConfig("MyDispatcherExample"));
	
	ActorRef actor = _system.actorOf(new Props(MsgEchoActor.class)
			.withDispatcher("defaultDispatcher1").withRouter(
					new RoundRobinRouter(5)));

	for (int i = 0; i < 25; i++) {
		actor.tell(i);
	}

	_system.shutdown();

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:Example2.java

示例9: ApplicationManagerSystem

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
public ApplicationManagerSystem() {

		final int no_of_workers = 10;

		system = ActorSystem.create("LoadGeneratorApp");

		final ActorRef appManager = system.actorOf(
				new Props(new UntypedActorFactory() {
					public UntypedActor create() {
						return new JobControllerActor(no_of_msgs);
					}
				}), "jobController");

		router = system.actorOf(new Props(new UntypedActorFactory() {
			public UntypedActor create() {
				return new WorkerActor(appManager);
			}
		}).withRouter(new RoundRobinRouter(no_of_workers)));
	}
 
开发者ID:rokumar7,项目名称:trial,代码行数:20,代码来源:ApplicationManagerSystem.java

示例10: Master

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
public Master( Timestamp start, final int numberOfWorkers, ActorRef listener )
{
    // Save our parameters locally
	this.start = start;
    this.numberOfWorkers = numberOfWorkers;
    this.listener = listener;

    // Create a new router to distribute messages out to the workers
    workerRouter = this.getContext()
            .actorOf( new Props(Worker.class )
                    .withRouter( new RoundRobinRouter( numberOfWorkers )), "workerRouter" );
}
 
开发者ID:collab-uniba,项目名称:SO_reputation,代码行数:13,代码来源:Master.java

示例11: SimulationMaster

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public SimulationMaster(int numberOfEventEmitters, Class eventEmitterClass,
		ActorRef listener, int numberOfEvents, long demoId, int messageDelay) {
	logger.info("Starting simulation with " + numberOfEventEmitters
			+ " of " + eventEmitterClass + " Event Emitters -- "
			+ eventEmitterClass.toString());
	this.listener = listener;
	this.numberOfEventEmitters = numberOfEventEmitters;
	this.eventEmitterClass = eventEmitterClass;
	eventEmitterRouter = this.getContext().actorOf(
			Props.create(eventEmitterClass, numberOfEvents, demoId, messageDelay).withRouter(
					new RoundRobinRouter(numberOfEventEmitters)),
			"eventEmitterRouter");
}
 
开发者ID:DhruvKumar,项目名称:iot-masterclass,代码行数:15,代码来源:SimulationMaster.java

示例12: ControllerSoftwareSupervisor

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
public ControllerSoftwareSupervisor(ArrayList<VirtuelImage> imageVirtuels, SoftwareService software, ShellService shell, Props typeWorker, ActorRef listener) {
	 
	this.nbrWorker = imageVirtuels.size();
	this.imageVirtuels = imageVirtuels;
	this.software = software;
	this.sh = shell;
	this.listener = listener;
	this.resultWokers = new ArrayList<String>(); 
	 
	supervisor = this.getContext().actorOf(typeWorker.withRouter(new RoundRobinRouter(this.nbrWorker)),
	"Supervisor");
}
 
开发者ID:Spirals-Team,项目名称:peak-forecast,代码行数:13,代码来源:ControllerSoftwareImpl.java

示例13: ControllerVMSupervisor

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
public ControllerVMSupervisor(ArrayList<VirtuelImage> imageVituels,String pathFabFile,ShellService shell, Props typeWorker, ActorRef listener) {
	 
	this.nbrWorker = imageVituels.size();
	this.imageVirtuels = imageVituels;
	this.sh = shell;
	this.pathFabFile=pathFabFile;
	this.listener = listener;
	this.resultWokers = new ArrayList<String>(); 
	 
	supervisor = this.getContext().actorOf(typeWorker.withRouter(new RoundRobinRouter(this.nbrWorker)),
	"Supervisor");
}
 
开发者ID:Spirals-Team,项目名称:peak-forecast,代码行数:13,代码来源:ControllerVMImpl.java

示例14: afterPropertiesSet

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
            
    log.info("[fuse] Creating actor system");
    actorSystem = ActorSystem.create("fuse", configSource.getConfig());
    actorFactory.setActorSystem(actorSystem);

    log.info("[fuse] Creating system logger");
    actorSystem.actorOf(Props.create(SystemLogActor.class));

    log.info("[fuse] Initializing routing");
    configSource.parseLocalConfig();

    log.info("[fuse] Running annotation scanner");
    annotationScanner.scan();

    // create router actor and pass the reference to channelInitializer
    channelInitializer
        .setRouter(
            actorSystem.actorOf(
                Props.empty()
                     .withRouter(
                         RoundRobinRouter.create(getRouteFinders())
                     )                          
            )
        );

    // create suspended animator
    actorFactory.getLocalActor(
        "animator",
        "com.sulaco.fuse.akka.actor.SuspendedAnimationActor",
        "animator",
        configSource.getConfig().getInt("fuse.animator.spin")
    );
}
 
开发者ID:gibffe,项目名称:fuse,代码行数:36,代码来源:FuseServerImpl.java

示例15: reinitiateRouter

import akka.routing.RoundRobinRouter; //导入依赖的package包/类
private void reinitiateRouter() {
    ActorSystem system = ActorSystem.create(systemName);
    router = system.actorOf(Props.empty().withRouter(RoundRobinRouter.create(new ArrayList<ActorRef>())));

}
 
开发者ID:gihankarunarathne,项目名称:dynamo-mini,代码行数:6,代码来源:Bootstraper.java


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