-
Notifications
You must be signed in to change notification settings - Fork 6
/
RouterActor.scala
53 lines (39 loc) · 1.09 KB
/
RouterActor.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package actor
import akka.actor._
import akka.event._
import akka.pattern.pipe
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import java.net.URL
import crawler._
import org.apache.spark._
import org.apache.spark.streaming._
import org.apache.spark.streaming.receiver._
import scala.concurrent._
import scala.concurrent.duration._
import scala.util.control.NonFatal
import models._
import common._
import common.eventbus._
/**
* This actor will just forward messages to Spark to be processed by streaming jobs
*/
class RouterActor extends Actor with ActorHelper {
override def preStart = {
mailman subscribe self to Seq(
classOf[java.net.URL]
)
}
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
case NonFatal(_) => Restart
}
def receive = {
case url: java.net.URL =>
log info s"Word Cloud - URL: ${url}"
store(url.toString)
case other =>
log warn s"Received unknown message: $other"
}
}