#1496 - Rename 'targets' to 'routees'
This commit is contained in:
parent
c2597ed33d
commit
42e8a4559e
10 changed files with 90 additions and 91 deletions
|
|
@ -119,7 +119,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
actors = actors :+ actor
|
||||
}
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(targets = actors)))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(routees = actors)))
|
||||
|
||||
//send messages to the actor.
|
||||
for (i ← 0 until iterationCount) {
|
||||
|
|
@ -157,7 +157,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
}
|
||||
}))
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(routees = List(actor1, actor2))))
|
||||
|
||||
routedActor ! Broadcast(1)
|
||||
routedActor ! Broadcast("end")
|
||||
|
|
@ -195,7 +195,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
}
|
||||
}))
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RandomRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(RandomRouter(routees = List(actor1, actor2))))
|
||||
|
||||
routedActor ! Broadcast(1)
|
||||
routedActor ! Broadcast("end")
|
||||
|
|
@ -232,7 +232,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
}
|
||||
}))
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(BroadcastRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(BroadcastRouter(routees = List(actor1, actor2))))
|
||||
routedActor ! 1
|
||||
routedActor ! "end"
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
}
|
||||
}))
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(BroadcastRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(BroadcastRouter(routees = List(actor1, actor2))))
|
||||
routedActor ? 1
|
||||
routedActor ! "end"
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
"Scatter-gather router" must {
|
||||
|
||||
"be started when constructed" in {
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(targets = List(newActor(0)))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(routees = List(newActor(0)))))
|
||||
routedActor.isTerminated must be(false)
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
}
|
||||
}))
|
||||
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(routees = List(actor1, actor2))))
|
||||
routedActor ! Broadcast(1)
|
||||
routedActor ! Broadcast("end")
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
val shutdownLatch = new TestLatch(1)
|
||||
val actor1 = newActor(1, Some(shutdownLatch))
|
||||
val actor2 = newActor(22, Some(shutdownLatch))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(targets = List(actor1, actor2))))
|
||||
val routedActor = system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(routees = List(actor1, actor2))))
|
||||
|
||||
routedActor ! Broadcast(Stop(Some(1)))
|
||||
shutdownLatch.await
|
||||
|
|
@ -391,7 +391,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
//#crActors
|
||||
|
||||
//#crRouter
|
||||
case class VoteCountRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil)
|
||||
case class VoteCountRouter(nrOfInstances: Int = 0, routees: Iterable[String] = Nil)
|
||||
extends RouterConfig {
|
||||
|
||||
//#crRoute
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ akka {
|
|||
# in several ways:
|
||||
# - nr-of-instances: will create that many children given the actor factory
|
||||
# supplied in the source code (overridable using create-as below)
|
||||
# - target.paths: will look the paths up using actorFor and route to
|
||||
# - routees.paths: will look the paths up using actorFor and route to
|
||||
# them, i.e. will not create children
|
||||
router = "from-code"
|
||||
|
||||
# number of children to create in case of a non-direct router; this setting
|
||||
# is ignored if target.paths is given
|
||||
# is ignored if routees.paths is given
|
||||
nr-of-instances = 1
|
||||
|
||||
# FIXME document 'create-as', ticket 1511
|
||||
|
|
@ -87,7 +87,7 @@ akka {
|
|||
class = ""
|
||||
}
|
||||
|
||||
target {
|
||||
routees {
|
||||
# Alternatively to giving nr-of-instances you can specify the full
|
||||
# paths of those actors which should be routed to. This setting takes
|
||||
# precedence over nr-of-instances
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@ class Deployer(val settings: ActorSystem.Settings) {
|
|||
|
||||
val deployment = config.withFallback(default)
|
||||
|
||||
val targets = deployment.getStringList("target.paths").asScala.toSeq
|
||||
val routees = deployment.getStringList("routees.paths").asScala.toSeq
|
||||
|
||||
val nrOfInstances = deployment.getInt("nr-of-instances")
|
||||
|
||||
val router: RouterConfig = deployment.getString("router") match {
|
||||
case "from-code" ⇒ NoRouter
|
||||
case "round-robin" ⇒ RoundRobinRouter(nrOfInstances, targets)
|
||||
case "random" ⇒ RandomRouter(nrOfInstances, targets)
|
||||
case "scatter-gather" ⇒ ScatterGatherFirstCompletedRouter(nrOfInstances, targets)
|
||||
case "broadcast" ⇒ BroadcastRouter(nrOfInstances, targets)
|
||||
case "round-robin" ⇒ RoundRobinRouter(nrOfInstances, routees)
|
||||
case "random" ⇒ RandomRouter(nrOfInstances, routees)
|
||||
case "scatter-gather" ⇒ ScatterGatherFirstCompletedRouter(nrOfInstances, routees)
|
||||
case "broadcast" ⇒ BroadcastRouter(nrOfInstances, routees)
|
||||
case x ⇒ throw new ConfigurationException("unknown router type " + x + " for path " + key)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ trait RouterConfig {
|
|||
|
||||
def nrOfInstances: Int
|
||||
|
||||
def targets: Iterable[String]
|
||||
def routees: Iterable[String]
|
||||
|
||||
def createRoute(props: Props, actorContext: ActorContext, ref: RoutedActorRef): Route
|
||||
|
||||
|
|
@ -97,17 +97,16 @@ trait RouterConfig {
|
|||
}
|
||||
}
|
||||
|
||||
protected def toAll(sender: ActorRef, targets: Iterable[ActorRef]): Iterable[Destination] = targets.map(Destination(sender, _))
|
||||
protected def toAll(sender: ActorRef, routees: Iterable[ActorRef]): Iterable[Destination] = routees.map(Destination(sender, _))
|
||||
|
||||
protected def createRoutees(props: Props, context: ActorContext, nrOfInstances: Int, targets: Iterable[String]): Vector[ActorRef] = (nrOfInstances, targets) match {
|
||||
protected def createRoutees(props: Props, context: ActorContext, nrOfInstances: Int, routees: Iterable[String]): Vector[ActorRef] = (nrOfInstances, routees) match {
|
||||
case (0, Nil) ⇒ throw new IllegalArgumentException("Insufficient information - missing configuration.")
|
||||
case (x, Nil) ⇒ (1 to x).map(_ ⇒ context.actorOf(props))(scala.collection.breakOut)
|
||||
case (_, xs) ⇒ xs.map(context.actorFor(_))(scala.collection.breakOut)
|
||||
}
|
||||
|
||||
protected def createAndRegisterRoutees(props: Props, context: ActorContext, nrOfInstances: Int, targets: Iterable[String]): Unit = {
|
||||
val routees = createRoutees(props, context, nrOfInstances, targets)
|
||||
registerRoutees(context, routees)
|
||||
protected def createAndRegisterRoutees(props: Props, context: ActorContext, nrOfInstances: Int, routees: Iterable[String]): Unit = {
|
||||
registerRoutees(context, createRoutees(props, context, nrOfInstances, routees))
|
||||
}
|
||||
|
||||
protected def registerRoutees(context: ActorContext, routees: Vector[ActorRef]): Unit = {
|
||||
|
|
@ -163,25 +162,25 @@ case class Destination(sender: ActorRef, recipient: ActorRef)
|
|||
*/
|
||||
case object NoRouter extends RouterConfig {
|
||||
def nrOfInstances: Int = 0
|
||||
def targets: Iterable[String] = Nil
|
||||
def routees: Iterable[String] = Nil
|
||||
def createRoute(props: Props, actorContext: ActorContext, ref: RoutedActorRef): Route = null
|
||||
}
|
||||
|
||||
object RoundRobinRouter {
|
||||
def apply(targets: Iterable[ActorRef]) = new RoundRobinRouter(targets = targets map (_.path.toString))
|
||||
def apply(routees: Iterable[ActorRef]) = new RoundRobinRouter(routees = routees map (_.path.toString))
|
||||
}
|
||||
/**
|
||||
* A Router that uses round-robin to select a connection. For concurrent calls, round robin is just a best effort.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the round robin should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the round robin should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RoundRobinRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil) extends RouterConfig with RoundRobinLike {
|
||||
case class RoundRobinRouter(nrOfInstances: Int = 0, routees: Iterable[String] = Nil) extends RouterConfig with RoundRobinLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets nrOfInstances to be created.
|
||||
|
|
@ -192,17 +191,17 @@ case class RoundRobinRouter(nrOfInstances: Int = 0, targets: Iterable[String] =
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(t: java.util.Collection[String]) = {
|
||||
this(targets = collectionAsScalaIterable(t))
|
||||
this(routees = collectionAsScalaIterable(t))
|
||||
}
|
||||
}
|
||||
|
||||
trait RoundRobinLike { this: RouterConfig ⇒
|
||||
def createRoute(props: Props, context: ActorContext, ref: RoutedActorRef): Route = {
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, targets)
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, routees)
|
||||
|
||||
val next = new AtomicInteger(0)
|
||||
|
||||
|
|
@ -221,20 +220,20 @@ trait RoundRobinLike { this: RouterConfig ⇒
|
|||
}
|
||||
|
||||
object RandomRouter {
|
||||
def apply(targets: Iterable[ActorRef]) = new RandomRouter(targets = targets map (_.path.toString))
|
||||
def apply(routees: Iterable[ActorRef]) = new RandomRouter(routees = routees map (_.path.toString))
|
||||
}
|
||||
/**
|
||||
* A Router that randomly selects one of the target connections to send a message to.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RandomRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil) extends RouterConfig with RandomLike {
|
||||
case class RandomRouter(nrOfInstances: Int = 0, routees: Iterable[String] = Nil) extends RouterConfig with RandomLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets nrOfInstances to be created.
|
||||
|
|
@ -245,11 +244,11 @@ case class RandomRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil)
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(t: java.util.Collection[String]) = {
|
||||
this(targets = collectionAsScalaIterable(t))
|
||||
this(routees = collectionAsScalaIterable(t))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +261,7 @@ trait RandomLike { this: RouterConfig ⇒
|
|||
}
|
||||
|
||||
def createRoute(props: Props, context: ActorContext, ref: RoutedActorRef): Route = {
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, targets)
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, routees)
|
||||
|
||||
def getNext(): ActorRef = {
|
||||
ref.routees(random.get.nextInt(ref.routees.size))
|
||||
|
|
@ -279,20 +278,20 @@ trait RandomLike { this: RouterConfig ⇒
|
|||
}
|
||||
|
||||
object BroadcastRouter {
|
||||
def apply(targets: Iterable[ActorRef]) = new BroadcastRouter(targets = targets map (_.path.toString))
|
||||
def apply(routees: Iterable[ActorRef]) = new BroadcastRouter(routees = routees map (_.path.toString))
|
||||
}
|
||||
/**
|
||||
* A Router that uses broadcasts a message to all its connections.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class BroadcastRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil) extends RouterConfig with BroadcastLike {
|
||||
case class BroadcastRouter(nrOfInstances: Int = 0, routees: Iterable[String] = Nil) extends RouterConfig with BroadcastLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets nrOfInstances to be created.
|
||||
|
|
@ -303,17 +302,17 @@ case class BroadcastRouter(nrOfInstances: Int = 0, targets: Iterable[String] = N
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(t: java.util.Collection[String]) = {
|
||||
this(targets = collectionAsScalaIterable(t))
|
||||
this(routees = collectionAsScalaIterable(t))
|
||||
}
|
||||
}
|
||||
|
||||
trait BroadcastLike { this: RouterConfig ⇒
|
||||
def createRoute(props: Props, context: ActorContext, ref: RoutedActorRef): Route = {
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, targets)
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, routees)
|
||||
|
||||
{
|
||||
case (sender, message) ⇒
|
||||
|
|
@ -325,20 +324,20 @@ trait BroadcastLike { this: RouterConfig ⇒
|
|||
}
|
||||
|
||||
object ScatterGatherFirstCompletedRouter {
|
||||
def apply(targets: Iterable[ActorRef]) = new ScatterGatherFirstCompletedRouter(targets = targets map (_.path.toString))
|
||||
def apply(routees: Iterable[ActorRef]) = new ScatterGatherFirstCompletedRouter(routees = routees map (_.path.toString))
|
||||
}
|
||||
/**
|
||||
* Simple router that broadcasts the message to all routees, and replies with the first response.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class ScatterGatherFirstCompletedRouter(nrOfInstances: Int = 0, targets: Iterable[String] = Nil)
|
||||
case class ScatterGatherFirstCompletedRouter(nrOfInstances: Int = 0, routees: Iterable[String] = Nil)
|
||||
extends RouterConfig with ScatterGatherFirstCompletedLike {
|
||||
|
||||
/**
|
||||
|
|
@ -350,17 +349,17 @@ case class ScatterGatherFirstCompletedRouter(nrOfInstances: Int = 0, targets: It
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(t: java.util.Collection[String]) = {
|
||||
this(targets = collectionAsScalaIterable(t))
|
||||
this(routees = collectionAsScalaIterable(t))
|
||||
}
|
||||
}
|
||||
|
||||
trait ScatterGatherFirstCompletedLike { this: RouterConfig ⇒
|
||||
def createRoute(props: Props, context: ActorContext, ref: RoutedActorRef): Route = {
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, targets)
|
||||
createAndRegisterRoutees(props, context, nrOfInstances, routees)
|
||||
|
||||
{
|
||||
case (sender, message) ⇒
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ depending on the configuration of the actor system:
|
|||
the purpose of being completed by the response from an actor; it is created
|
||||
by the :meth:`ActorRef.ask` invocation.
|
||||
- :class:`DeadLetterActorRef` is the default implementation of the dead
|
||||
letters service, where all messages are re-routed whose targets are shut
|
||||
letters service, where all messages are re-routed whose routees are shut
|
||||
down or non-existent.
|
||||
|
||||
- And then there are some one-off internal implementations which you should
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ This is also done via configuration::
|
|||
/serviceA/aggregation {
|
||||
router = “round-robin”
|
||||
nr-of-instances = 10
|
||||
target {
|
||||
routees {
|
||||
nodes = [“akka://app@10.0.0.2:2552”, “akka://app@10.0.0.3:2552”]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ object RoutingProgrammaticallyExample extends App {
|
|||
val actor3 = system.actorOf(Props[ExampleActor1])
|
||||
val routees = Vector[ActorRef](actor1, actor2, actor3)
|
||||
val router2 = system.actorOf(Props[ExampleActor1].withRouter(
|
||||
RoundRobinRouter(targets = routees)))
|
||||
RoundRobinRouter(routees = routees)))
|
||||
//#programmaticRoutingRoutees
|
||||
1 to 6 foreach { i ⇒ router2 ! Message1(i) }
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ This is also done via configuration::
|
|||
/serviceA/aggregation {
|
||||
router = “round-robin”
|
||||
nr-of-instances = 10
|
||||
target {
|
||||
routees {
|
||||
nodes = [“akka://app@10.0.0.2:2552”, “akka://app@10.0.0.3:2552”]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ akka {
|
|||
# at that node e.g. "akka://sys@host:port"
|
||||
remote = ""
|
||||
|
||||
target {
|
||||
routees {
|
||||
|
||||
# A list of hostnames and ports for instantiating the children of a
|
||||
# non-direct router
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import com.typesafe.config.ConfigFactory
|
|||
import akka.config.ConfigurationException
|
||||
|
||||
trait RemoteRouterConfig extends RouterConfig {
|
||||
override protected def createRoutees(props: Props, context: ActorContext, nrOfInstances: Int, targets: Iterable[String]): Vector[ActorRef] = (nrOfInstances, targets) match {
|
||||
override protected def createRoutees(props: Props, context: ActorContext, nrOfInstances: Int, routees: Iterable[String]): Vector[ActorRef] = (nrOfInstances, routees) match {
|
||||
case (_, Nil) ⇒ throw new ConfigurationException("must specify list of remote nodes")
|
||||
case (n, xs) ⇒
|
||||
val nodes = targets map {
|
||||
val nodes = routees map {
|
||||
case RemoteAddressExtractor(a) ⇒ a
|
||||
case x ⇒ throw new ConfigurationException("unparseable remote node " + x)
|
||||
}
|
||||
|
|
@ -31,18 +31,18 @@ trait RemoteRouterConfig extends RouterConfig {
|
|||
/**
|
||||
* A Router that uses round-robin to select a connection. For concurrent calls, round robin is just a best effort.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the round robin should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the round robin should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RemoteRoundRobinRouter(nrOfInstances: Int, targets: Iterable[String]) extends RemoteRouterConfig with RoundRobinLike {
|
||||
case class RemoteRoundRobinRouter(nrOfInstances: Int, routees: Iterable[String]) extends RemoteRouterConfig with RoundRobinLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(n: Int, t: java.util.Collection[String]) = this(n, t.asScala)
|
||||
|
|
@ -51,18 +51,18 @@ case class RemoteRoundRobinRouter(nrOfInstances: Int, targets: Iterable[String])
|
|||
/**
|
||||
* A Router that randomly selects one of the target connections to send a message to.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RemoteRandomRouter(nrOfInstances: Int, targets: Iterable[String]) extends RemoteRouterConfig with RandomLike {
|
||||
case class RemoteRandomRouter(nrOfInstances: Int, routees: Iterable[String]) extends RemoteRouterConfig with RandomLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(n: Int, t: java.util.Collection[String]) = this(n, t.asScala)
|
||||
|
|
@ -71,18 +71,18 @@ case class RemoteRandomRouter(nrOfInstances: Int, targets: Iterable[String]) ext
|
|||
/**
|
||||
* A Router that uses broadcasts a message to all its connections.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RemoteBroadcastRouter(nrOfInstances: Int, targets: Iterable[String]) extends RemoteRouterConfig with BroadcastLike {
|
||||
case class RemoteBroadcastRouter(nrOfInstances: Int, routees: Iterable[String]) extends RemoteRouterConfig with BroadcastLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(n: Int, t: java.util.Collection[String]) = this(n, t.asScala)
|
||||
|
|
@ -91,19 +91,19 @@ case class RemoteBroadcastRouter(nrOfInstances: Int, targets: Iterable[String])
|
|||
/**
|
||||
* Simple router that broadcasts the message to all routees, and replies with the first response.
|
||||
* <br>
|
||||
* Please note that providing both 'nrOfInstances' and 'targets' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'targets' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'targets' will be used.
|
||||
* Please note that providing both 'nrOfInstances' and 'routees' does not make logical sense as this means
|
||||
* that the random router should both create new actors and use the 'routees' actor(s).
|
||||
* In this case the 'nrOfInstances' will be ignored and the 'routees' will be used.
|
||||
* <br>
|
||||
* <b>The</b> configuration parameter trumps the constructor arguments. This means that
|
||||
* if you provide either 'nrOfInstances' or 'targets' to during instantiation they will
|
||||
* if you provide either 'nrOfInstances' or 'routees' to during instantiation they will
|
||||
* be ignored if the 'nrOfInstances' is defined in the configuration file for the actor being used.
|
||||
*/
|
||||
case class RemoteScatterGatherFirstCompletedRouter(nrOfInstances: Int, targets: Iterable[String])
|
||||
case class RemoteScatterGatherFirstCompletedRouter(nrOfInstances: Int, routees: Iterable[String])
|
||||
extends RemoteRouterConfig with ScatterGatherFirstCompletedLike {
|
||||
|
||||
/**
|
||||
* Constructor that sets the targets to be used.
|
||||
* Constructor that sets the routees to be used.
|
||||
* Java API
|
||||
*/
|
||||
def this(n: Int, t: java.util.Collection[String]) = this(n, t.asScala)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue