Refer to the same cluster-wide router from several actors in the cluster on the same node

26 views
Skip to first unread message

Eugene Dzhurinsky

unread,
Apr 5, 2015, 12:54:41 PM4/5/15
to akka...@googlegroups.com
Hello!

I have a cluster configuration like this:

"/cluster_router_httpworker"  {
router = consistent-hashing-group
nr-of-instances = 10
routees.paths = [ "/user/router_httpworker" ]
cluster {
enabled = on
max-nr-of-instances-per-node = 5
allow-local-routees = off
use-role = "http"
}
},
"/cluster_router_chunkworker" {
router = consistent-hashing-group
nr-of-instances = 5
routees.paths = ["/user/router_chunkworker" ]
cluster {
enabled = on
max-nr-of-instances-per-node = 1
allow-local-routees = off
use-role = "chunk"
}
}

Now I start a TaskChunkActor the as below:

val sys = ActorSystem("HttpCluster", config)
val ref = sys.actorOf(Props[TaskChunkActor].withRouter(RoundRobinPool(10)), "router_chunkworker")
val clusterRef = sys.actorOf(FromConfig.props(Props.empty), "cluster_router_chunkworker")

The TaskChunkActor initializes its internal references to the HttpWorker :

val httpWorkers = context.system.actorOf(FromConfig.props(Props.empty), "cluster_router_httpworker")

At this point I'm getting the exception:

akka.actor.InvalidActorNameException: actor name [cluster_router_httpworker] is not unique!
    at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:130)
    at akka.actor.dungeon.Children$class.reserveChild(Children.scala:76)
    at akka.actor.ActorCell.reserveChild(ActorCell.scala:369)
    at akka.actor.dungeon.Children$class.makeChild(Children.scala:201)
    at akka.actor.dungeon.Children$class.attachChild(Children.scala:41)
    at akka.actor.ActorCell.attachChild(ActorCell.scala:369)
    at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:553)

It seems that every TaskChunkActor tries to create it's own reference to the cluster-related actor, and fails.

I see that I could pass the route to every instance of TaskChunkActor via constructor, but perhaps there's a way to either create an instance of the actor from config or return the existing one?

Thanks!

Viktor Klang

unread,
Apr 7, 2015, 8:10:19 AM4/7/15
to Akka User List
actorOf creates a new actor, and in this case you're doing it at the system level from within another actor:


val httpWorkers = context.system.actorOf(FromConfig.props(Props.empty), "cluster_router_httpworker")
That's the problem.


--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Reply all
Reply to author
Forward
0 new messages