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.

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top