net.dubboclub.akka.remoting.actor.dispatcher.ClientDispatcher Maven / Gradle / Ivy
package net.dubboclub.akka.remoting.actor.dispatcher;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.ActorRefRoutee;
import akka.routing.Routee;
import akka.routing.Router;
import akka.routing.SmallestMailboxRoutingLogic;
import net.dubboclub.akka.remoting.message.ActorOperate;
import scala.collection.immutable.IndexedSeq;
import java.util.HashMap;
import java.util.Map;
/**
* Created by bieber on 2015/7/16.
*/
public class ClientDispatcher extends DispatchActor {
private static final Map CLIENT_CACHE = new HashMap();
private static final int DEFAULT_CLIENT_SIZE=3;
@Override
protected void generateChildActor(Class extends UntypedActor> actor, Object[] constructorArgs, String actorName) {
Router router = CLIENT_CACHE.get(actorName);
if(router==null){
router=new Router(new SmallestMailboxRoutingLogic());
CLIENT_CACHE.put(actorName,router);
for(int i=0;i routeeIterator = router.routees();
for(int i=0;i