Question

Context: I want to write scalding job(hadoop) to crawl pages and I want to set timeout on url extraction(without timeout on URLConnection, I want generic solution for other timeout cases) i.e. map function.

I'm think about futures which are killed after some timout with all resources released since it is memory critical code. Not sure what to use in scala API.

Was it helpful?

Solution

While Akka was suggested--and is superior to the following solution--Scala does have its own, built in Actor model much like Akka which can do you want you want. Examples can be found here:

http://www.scala-lang.org/node/242

You'll probably want either reactWithin or receiveWithin, the documentation for which can be found here:

http://www.scala-lang.org/api/current/scala/actors/TIMEOUT$.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top