Re: [akka-user] Cluster Aware Routers and the PoisonPill

2014-07-17 Thread Konrad Malawski
Hi Sean,
I tried to replicate your problem, but seems to work as expected in my
sample app.

I've tried with an app like this:
https://gist.github.com/ktoso/c7382f3c88159f352b75
Which you can paste in the akka-sample-cluster-scala
https://typesafe.com/activator/template/akka-sample-cluster-scala
activator template.

I'd love to help out, but so far couldn't replicate the problem - would be
cool if you could prepare a minimised example (can be based on my gist
maybe?) to show the problem.
In general you're right to expect that death watch should just work™ with
remote actors.



On Mon, Jul 14, 2014 at 6:07 AM, Sean Policarpio kdra...@gmail.com wrote:

 The documentation at
 http://doc.akka.io/docs/akka/snapshot/scala/cluster-usage.html doesn't
 state that the PoisonPill performs differently than the behaviour listed
 here
 http://doc.akka.io/docs/akka/snapshot/scala/routing.html#note-router-terminated-children-scala,
 so I assumed if I used a Broadcast message like below:

 ...
   def vectorizeUserContent(streamer : ActorRef, libraryId : Long,
 senderNode : ActorRef) = {

 val userVectorizationReducers =
   context.actorOf(FromConfig.props(Props[ UserVectorizationReducer ]),
 userVectorizationReducer)

 context.actorOf(Props(new Actor {

   override def preStart() {
 context.watch(userVectorizationReducers)
 streamer ! StartStream(libraryId)
   }

   override def receive = {
 case dto : RawUserContentDto = userVectorizationReducers !
 ConsistentHashableEnvelope(dto, dto.userId)
 case EndOfStream() = {
   userVectorizationReducers !
 Broadcast(ReturnUserVectors(senderNode))
   *userVectorizationReducers ! Broadcast(PoisonPill)*
 }
 case Terminated(userVectorizationReducers) = {
   senderNode ! VectorizationCompleted()
   self ! PoisonPill
 }
   }

 }), userContentVectorizerDirector)
   }
 ...

 where userVectorizationReducers is a remotely deployed pool of routees,
 the Terminated message would be retrieved due to the watch made in
 preStart(). Unfortunately, the broadcasted PoisonPill does not trigger
 the expected Terminated message I'm waiting for. If I however replace the
 broadcast in my 'EndOfStream()' case with userVectorizationReducers !
 PoisonPill, then the Terminated message is returned. In both cases, all
 routees are terminated individually (evident through some logging in the
 postStop() method of the UserVectorizationReducer actor). I'm assuming
 the PoisonPill is actually being routed to the routees where they can be
 gracefully shutdown after all other messages have been processed, but I
 could be wrong.

 Can I get clarification if this is in fact true and it is the recommended
 way to shutdown a pool of cluster routees?

 Cheers,
 Sean

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




-- 
Cheers,
Konrad 'ktoso' Malawski
hAkker @ Typesafe

http://typesafe.com

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


[akka-user] Cluster Aware Routers and the PoisonPill

2014-07-14 Thread Sean Policarpio
The documentation 
at http://doc.akka.io/docs/akka/snapshot/scala/cluster-usage.html doesn't 
state that the PoisonPill performs differently than the behaviour listed 
here 
http://doc.akka.io/docs/akka/snapshot/scala/routing.html#note-router-terminated-children-scala,
 
so I assumed if I used a Broadcast message like below:

...
  def vectorizeUserContent(streamer : ActorRef, libraryId : Long, 
senderNode : ActorRef) = {

val userVectorizationReducers =
  context.actorOf(FromConfig.props(Props[ UserVectorizationReducer ]), 
userVectorizationReducer)

context.actorOf(Props(new Actor {

  override def preStart() {
context.watch(userVectorizationReducers)
streamer ! StartStream(libraryId)
  }

  override def receive = {
case dto : RawUserContentDto = userVectorizationReducers ! 
ConsistentHashableEnvelope(dto, dto.userId)
case EndOfStream() = {
  userVectorizationReducers ! 
Broadcast(ReturnUserVectors(senderNode))
  *userVectorizationReducers ! Broadcast(PoisonPill)*
}
case Terminated(userVectorizationReducers) = {
  senderNode ! VectorizationCompleted()
  self ! PoisonPill
}
  }

}), userContentVectorizerDirector)
  }
...

where userVectorizationReducers is a remotely deployed pool of routees, the 
Terminated message would be retrieved due to the watch made in preStart(). 
Unfortunately, the broadcasted PoisonPill does not trigger the expected 
Terminated message I'm waiting for. If I however replace the broadcast in 
my 'EndOfStream()' case with userVectorizationReducers ! PoisonPill, then 
the Terminated message is returned. In both cases, all routees are 
terminated individually (evident through some logging in the postStop() 
method of the UserVectorizationReducer actor). I'm assuming the PoisonPill 
is actually being routed to the routees where they can be gracefully 
shutdown after all other messages have been processed, but I could be wrong.

Can I get clarification if this is in fact true and it is the recommended 
way to shutdown a pool of cluster routees?

Cheers,
Sean

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