parent
63ccdeec16
commit
b1df13d4d4
221 changed files with 1528 additions and 1580 deletions
|
|
@ -18,9 +18,9 @@ object ConsistentHashingRouterDocSpec {
|
|||
var cache = Map.empty[String, String]
|
||||
|
||||
def receive = {
|
||||
case Entry(key, value) => cache += (key -> value)
|
||||
case Get(key) => sender() ! cache.get(key)
|
||||
case Evict(key) => cache -= key
|
||||
case Entry(key, value) ⇒ cache += (key -> value)
|
||||
case Get(key) ⇒ sender() ! cache.get(key)
|
||||
case Evict(key) ⇒ cache -= key
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class ConsistentHashingRouterDocSpec extends AkkaSpec with ImplicitSender {
|
|||
import akka.routing.ConsistentHashingRouter.ConsistentHashableEnvelope
|
||||
|
||||
def hashMapping: ConsistentHashMapping = {
|
||||
case Evict(key) => key
|
||||
case Evict(key) ⇒ key
|
||||
}
|
||||
|
||||
val cache: ActorRef =
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ akka.actor.deployment {
|
|||
class RedundancyRoutingLogic(nbrCopies: Int) extends RoutingLogic {
|
||||
val roundRobin = RoundRobinRoutingLogic()
|
||||
def select(message: Any, routees: immutable.IndexedSeq[Routee]): Routee = {
|
||||
val targets = (1 to nbrCopies).map(_ => roundRobin.select(message, routees))
|
||||
val targets = (1 to nbrCopies).map(_ ⇒ roundRobin.select(message, routees))
|
||||
SeveralRoutees(targets)
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ akka.actor.deployment {
|
|||
|
||||
class Storage extends Actor {
|
||||
def receive = {
|
||||
case x => sender() ! x
|
||||
case x ⇒ sender() ! x
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ class CustomRouterDocSpec extends AkkaSpec(CustomRouterDocSpec.config) with Impl
|
|||
//#unit-test-logic
|
||||
val logic = new RedundancyRoutingLogic(nbrCopies = 3)
|
||||
|
||||
val routees = for (n <- 1 to 7) yield TestRoutee(n)
|
||||
val routees = for (n ← 1 to 7) yield TestRoutee(n)
|
||||
|
||||
val r1 = logic.select("msg", routees)
|
||||
r1.asInstanceOf[SeveralRoutees].routees should be(
|
||||
|
|
@ -120,9 +120,9 @@ class CustomRouterDocSpec extends AkkaSpec(CustomRouterDocSpec.config) with Impl
|
|||
|
||||
"demonstrate usage of custom router" in {
|
||||
//#usage-1
|
||||
for (n <- 1 to 10) system.actorOf(Props[Storage], "s" + n)
|
||||
for (n ← 1 to 10) system.actorOf(Props[Storage], "s" + n)
|
||||
|
||||
val paths = for (n <- 1 to 10) yield ("/user/s" + n)
|
||||
val paths = for (n ← 1 to 10) yield ("/user/s" + n)
|
||||
val redundancy1: ActorRef =
|
||||
system.actorOf(
|
||||
RedundancyGroup(paths, nbrCopies = 3).props(),
|
||||
|
|
@ -130,7 +130,7 @@ class CustomRouterDocSpec extends AkkaSpec(CustomRouterDocSpec.config) with Impl
|
|||
redundancy1 ! "important"
|
||||
//#usage-1
|
||||
|
||||
for (_ <- 1 to 3) expectMsg("important")
|
||||
for (_ ← 1 to 3) expectMsg("important")
|
||||
|
||||
//#usage-2
|
||||
val redundancy2: ActorRef = system.actorOf(
|
||||
|
|
@ -139,7 +139,7 @@ class CustomRouterDocSpec extends AkkaSpec(CustomRouterDocSpec.config) with Impl
|
|||
redundancy2 ! "very important"
|
||||
//#usage-2
|
||||
|
||||
for (_ <- 1 to 5) expectMsg("very important")
|
||||
for (_ ← 1 to 5) expectMsg("very important")
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -305,9 +305,9 @@ router-dispatcher {}
|
|||
}
|
||||
|
||||
def receive = {
|
||||
case w: Work =>
|
||||
case w: Work ⇒
|
||||
router.route(w, sender())
|
||||
case Terminated(a) =>
|
||||
case Terminated(a) ⇒
|
||||
router = router.removeRoutee(a)
|
||||
val r = context.actorOf(Props[Worker])
|
||||
context watch r
|
||||
|
|
@ -318,7 +318,7 @@ router-dispatcher {}
|
|||
|
||||
class Worker extends Actor {
|
||||
def receive = {
|
||||
case _ =>
|
||||
case _ ⇒
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ router-dispatcher {}
|
|||
//#create-worker-actors
|
||||
|
||||
def receive = {
|
||||
case _ =>
|
||||
case _ ⇒
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ router-dispatcher {}
|
|||
context.actorOf(BalancingPool(20).props(Props[Worker]), "router10b")
|
||||
//#balancing-pool-3
|
||||
import scala.collection.JavaConversions._
|
||||
for (i <- 1 to 100) router10b ! i
|
||||
for (i ← 1 to 100) router10b ! i
|
||||
val threads10b = Thread.getAllStackTraces.keySet.filter { _.getName contains "router10b" }
|
||||
val threads10bNr = threads10b.size
|
||||
require(threads10bNr == 5, s"Expected 5 threads for router10b, had $threads10bNr! Got: ${threads10b.map(_.getName)}")
|
||||
|
|
@ -518,14 +518,14 @@ router-dispatcher {}
|
|||
//#optimal-size-exploring-resize-pool
|
||||
|
||||
def receive = {
|
||||
case _ =>
|
||||
case _ ⇒
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Echo extends Actor {
|
||||
def receive = {
|
||||
case m => sender() ! m
|
||||
case m ⇒ sender() ! m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue