The way you would approach this depends very much on what you want to
achieve: is it enough if your router can handle a million messages per
second? If that is the case then I would recommend just writing your own
actor implementing exactly what you want, not using any of the RouterLogic
infrastructure (since that is geared towards a more generic an reusable
goal). That would also mean that you do not need to worry about
synchronization issues at all (and as a hint: ConcurrentHashMap is not the
most scalable choice, especially if reads are far more frequent than
updates).

Using a normal actor which creates children of known names sounds like a
good plan to me, the complexity of `context.child(name)` is O(log n) (it
uses a TreeMap).

Regards,

Roland



On Wed, May 7, 2014 at 4:26 AM, 何品 <[email protected]> wrote:

> Hi I was trying to implement an router which could router a message to an
> specified routee via the message's key.just as the ConsistentHashRouter.
> when I look at the selected method ,the comes out routees are in an
> immutable seq,but not a map<String,Routee>,so if I want to selected one of
> the routee
> I should iterate the routee in the seq? or I should use my one implement?
>
> I have checked the ConsistentHashRouter's logic,it has an inner map and an
> transform the data in the seq to map,and selected on the map if the passed
> in seq has not changed otherwise will rebuild the map.
>
> So ,I was wondering,If I want to implement on hash based one should I use
> the concorrentHashMap for the treadsafe? and how about the
> actorRef.getContext().child("name")?
> should it be O(1),is it based on hash in the inner implement?
>
> all in all,
> 1,if I want to implement an hash based router ,in the logic implement i
> must transform the seq to hashmap right?
> 2,the child(name:String) to selecte an child of an parent Actor is O(1)?
>
>
>  --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to