> > I'd be interested to know if there are other examples which might solve > this problem without explicitly maintaining state?
@Denis You can create a only-use-once temporary actor in the router to track all acking. After it receive all acking from workers, send a message to router, and kill itself. On Friday, October 16, 2015 at 7:50:58 AM UTC+8, Denis Papathanasiou wrote: > > Answering my own question, I found this example[1] which was similar to > what I needed. > > So I wind up maintaining the file contents within the distribution actor, > and have the workers report back how many lines they've processed > (analogous to the total number of pints the Bartender tracks in the > example). > > When the distributor gets a total equivalent to the number of lines in > the first file, it starts processing the contents of the second file. > > It's a simple solution which solves my problem, but the idea of keeping > state in the distribution actor is not as clean/elegant as I would like. > > I'd be interested to know if there are other examples which might solve > this problem without explicitly maintaining state? > > [1] > http://www.reactive.io/tips/2014/03/28/getting-started-with-actor-based-programming-using-scala-and-akka/ > > On Wednesday, October 14, 2015 at 8:21:35 PM UTC-4, Denis Papathanasiou > wrote: >> >> I've written a simple actor system, based on the "calculate Pi" >> example[1]. >> >> In my case, I am processing two types of (large) csv files. >> >> I load and parse the first one into a list of lines, and then split >> the lines into equal chunks, for multiple worker actors to process >> in parallel: >> >> lines.grouped(chunks).toList.par.map( lineGroup => router ! Process( >> lineGroup) ) >> >> Next, I want to do the exact same thing on all the lines contained in >> the second file. >> >> But, before I issue any new requests to any worker actors, I want to >> make sure that all the actors who received the initial Process message >> are finished. >> >> I know there is a mechanism to send replies back to the actor which made >> the request, but I'm not sure how to wait for all the replies to arrive >> withoout blocking. >> >> Are there any good examples of this? >> >> [1] >> http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html >> > -- >>>>>>>>>> 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.
