Hello,
just wondered whether it is possible in Akka to interrupt some actor
that is busy processing a long running task in order to make the actor
respond to some event it has to react to immediately (e.g., traffic
light turned red and the driver actor needs to stop the car).
Well I
guess I can send some interrupt message, but I don't know whether that
would screw up the actor. Maybe there is a high-level way of doing
this. Some suspend-resume mechanism is what I'm looking for: interrupt
the actor, the actor ckecks out whether it needs to respond to some
newly arrived event, when done it resumes the interrupted task or
continues with doing something else.
Thanx, Oliver
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
...and configure to use a priority queue mailbox to allow certain messages to jump the queue.
--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/HthJnJBSDcUJ.
> You're suggesting a solution to a problem that is not explained,Well, it was just some general thought that struck my mind. The
> tell us what you're doing and we can suggest possible solutions.
example of the driver actor that needs to stop the car, because some
traffic light turned red was meant to be somewhat serious, though ;-).
Let's say your nuclear power plant control system also makes use of
actors and therefore actors need to be able to be interrupted to shut
down the plant in case of an earth quake or whatever.
Any application that needs to respond quickly to input of sensors
needs some way to ensure sufficient quick response time. There is,
e.g., interleaving in JADE (http://jade.tilab.com/). They had a very
nice slide about it on their site, but I can't find it anymore. The
processing of some message received by some agent is broken down into
nodes in a tree. Whenever a node in the tree has been executed, the
agent is available to poll any other input. It then resumes execution
by processing the next node in the tree. I don't really like this
approach as it appears quite effortful and cumbersome to me to create
that tree of nodes. But responsiveness is an issue people in the world
of agents have thought about. I was basically looking into actors,
because agents are somewhat dead (I guess ai never fulfilled its
promises and so agents couldn't do so, either). But actors are in
spirit very similar (active objects processing message queues) and
could serve as a replacement.
All right. If that kind of things can be configured, it can be done
> ...and configure to use a priority queue mailbox to allow certain messages
> to jump the queue.
anyway I guess.
Thanks, Oliver
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Cheers, Oliver
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
LOL, mine as well.
--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner
Blog: letitcrash.com
Regards, Oliver
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
My bet is that everyone gets your use case. I myself have encountered it a number of times. But there are realities here:1) You're not talking about Actors, you're talking about threads. It might look like something Actors can do because of the beautiful way these guys hide the nasty world from you but it's not.
2) There is no way, in any language that I know of, on any platform that I know of, where "killing" a thread is actually supported. There are remnants of this mistake out there but they are deprecated.
3) I argue that it is not as common as you think. Smart companies that make good software don't let this situation occur. Google, Twitter, etc… these guys ensure the libraries they use don't suck. If they do, then they write better ones and displace the garbage. Your company is making a very poor decision.
4) Edmondo had it right. You're replacing QA with toolkit functionality - toolkit functionality that can't exist at this point in time.5) A separate process is really the only way to go if you want to do this
Your situation is completely awful. If the powers that be are forcing you into an awful situation and you can't find a good way out of it, then you have to find a not-so-good way out of it. Using defective software in production software is just a wrong thing to do.
√
Thanx, Oliver
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
--
Viktor Klang
Akka Tech Lead
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
On Fri, Feb 3, 2012 at 10:50 AM, Derek Wyatt <de...@derekwyatt.org> wrote:My bet is that everyone gets your use case. I myself have encountered it a number of times. But there are realities here:1) You're not talking about Actors, you're talking about threads. It might look like something Actors can do because of the beautiful way these guys hide the nasty world from you but it's not.Of course. I was hoping that since the Akka guys seem to know the JVM inside out they might find a solution for this problem. Also, interrupting a thread that runs actor should be less troublesome than interrupting a thread in your run of the mill java program since a well-designed actor should not use locks or do blocking IO. And you could ensure this with a class loader.
2) There is no way, in any language that I know of, on any platform that I know of, where "killing" a thread is actually supported. There are remnants of this mistake out there but they are deprecated.Well, in .NET you have the concept of an app-domain, which provides a level of isolation. And of course many scripting languages make using a process as a level of isolation easier because they don't have such a huge overhead for creating a new process. In low-level languages like C you have fork(), so you can also cheaply create a process at least on linux.
3) I argue that it is not as common as you think. Smart companies that make good software don't let this situation occur. Google, Twitter, etc… these guys ensure the libraries they use don't suck. If they do, then they write better ones and displace the garbage. Your company is making a very poor decision.It's not up to us. We are a tiny company that have to work together with huge companies for some projects. These huge companies have software departments of their own, so they see us as a competitor and are thus not that interested in providing us with bug-free libraries. They just grudgingly provide us with a library that works most of the time.4) Edmondo had it right. You're replacing QA with toolkit functionality - toolkit functionality that can't exist at this point in time.5) A separate process is really the only way to go if you want to do thisThis is where we want to go in the long term. We already do it for some interfaces. And akka should make this a bit easier. I think we should be OK.
Your situation is completely awful. If the powers that be are forcing you into an awful situation and you can't find a good way out of it, then you have to find a not-so-good way out of it. Using defective software in production software is just a wrong thing to do.Well, as I said it is not up to us. But I am willing to bet that there are a lot of companies in a similar situation.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
Thanks. I understand that you can not rely on non- recommended functionality unless you are really sure that it works. I was just thinking that if anybody can find a solution to this problem it would be you guys. You do use sun.misc.Unsafe after all :-)
But maybe dealing with this properly would require some changes at the JVM level.
2012/2/3 √iktor Ҡlang <viktor...@gmail.com>
You can always create your own Dispatcher that tracks misbehaving actors and kills their current worker thread. But since this is not supported or recommended on the JVM (Thread.stop/destroy), it means I cannot add it to Akka and then have to support it for our customers.
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
}
I feel your pain :) But everyone has already said it… you want a new version of the JVM, not Akka. Once the JVM can do it, I have 100% faith that these guys will incorporate and you won't even know it's there… Hell, they'll probably use it to fix the defective code at runtime :)
Then I expect to see that feature in the roadmap! :)
Lotsa good news from across the sea. It makes me wish I was Swedish.
Hi Rüdiger,
there was a ticket enabling something which would probably cover your use case: http://www.assembla.com/spaces/akka/tickets/1014
(this is of course no coincidence since it was created following a discussion we had last year ;-) )
The reason why Viktor closed it as invalid is plausible, because it would indeed be hard (in the sense that we would be re-implementing JBOSS or something within Akka); I am not yet convinced that it is impossible, though, by waving the dark magician’s wand and conjuring the powers of ClassLoaders with (possibly) SecurityManagers.
On Fri, Feb 3, 2012 at 11:13 AM, rkuhn wrote:Hi Rüdiger,
there was a ticket enabling something which would probably cover your use case: http://www.assembla.com/spaces/akka/tickets/1014
(this is of course no coincidence since it was created following a discussion we had last year ;-) )
The reason why Viktor closed it as invalid is plausible, because it would indeed be hard (in the sense that we would be re-implementing JBOSS or something within Akka); I am not yet convinced that it is impossible, though, by waving the dark magician’s wand and conjuring the powers of ClassLoaders with (possibly) SecurityManagers.
Well, as a brute force (but slow) solution you could inject code to check an abort flag into all loops and method calls. That would also cover tail-recursive methods since they get translated to loops by scalac. Blocking calls into operating system code would have to be dealt with by interrupt, which is not deprecated. Of course this would slow down everything tremendously, since you would have to apply this byte code transformation not just to the user code but also to the code used by the user code, like scala.collection._
If I remember correctly, Thread.Interrupt only interrupts blocking IO operations. But it won't interrupt a thread that is stuck in a loop like while(true) {}. You need to use the (deprecated) Thread.stop() for that:
Also, according to this page:A thread that doesn't respond to Thread.interrupt wouldn't have responded to Thread.stop either. I haven't tested to verify this though.
And then I don't want to have to be the support guy