Make cluster sharding DC aware, #23231
* Sharding only within own team (coordinator is singleton) * the ddata Replicator used by Sharding must also be only within own team * added support for Set of roles in ddata Replicator so that can be used by sharding to specify role + team * Sharding proxy can route to sharding in another team
This commit is contained in:
parent
e37243f471
commit
e0fe0bc49e
12 changed files with 417 additions and 47 deletions
|
|
@ -176,13 +176,13 @@ final class ClusterSingletonProxy(singletonManagerPath: String, settings: Cluste
|
|||
identifyTimer = None
|
||||
}
|
||||
|
||||
private val targetTeam = settings.team match {
|
||||
private val targetTeamRole = settings.team match {
|
||||
case Some(t) ⇒ ClusterSettings.TeamRolePrefix + t
|
||||
case None ⇒ ClusterSettings.TeamRolePrefix + cluster.settings.Team
|
||||
}
|
||||
|
||||
def matchingRole(member: Member): Boolean =
|
||||
member.hasRole(targetTeam) && role.forall(member.hasRole)
|
||||
member.hasRole(targetTeamRole) && role.forall(member.hasRole)
|
||||
|
||||
def handleInitial(state: CurrentClusterState): Unit = {
|
||||
trackChange {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import akka.cluster.Cluster
|
|||
|
||||
import akka.testkit.ImplicitSender
|
||||
import akka.remote.testkit.{ MultiNodeConfig, MultiNodeSpec, STMultiNodeSpec }
|
||||
import akka.cluster.ClusterSettings
|
||||
|
||||
object TeamSingletonManagerSpec extends MultiNodeConfig {
|
||||
val controller = role("controller")
|
||||
|
|
@ -100,10 +101,10 @@ abstract class TeamSingletonManagerSpec extends MultiNodeSpec(TeamSingletonManag
|
|||
pong.fromTeam should equal(Cluster(system).settings.Team)
|
||||
pong.roles should contain(worker)
|
||||
runOn(controller, first) {
|
||||
pong.roles should contain("team-one")
|
||||
pong.roles should contain(ClusterSettings.TeamRolePrefix + "one")
|
||||
}
|
||||
runOn(second, third) {
|
||||
pong.roles should contain("team-two")
|
||||
pong.roles should contain(ClusterSettings.TeamRolePrefix + "two")
|
||||
}
|
||||
|
||||
enterBarrier("after-1")
|
||||
|
|
@ -118,7 +119,7 @@ abstract class TeamSingletonManagerSpec extends MultiNodeSpec(TeamSingletonManag
|
|||
val pong = expectMsgType[TeamSingleton.Pong](10.seconds)
|
||||
pong.fromTeam should ===("one")
|
||||
pong.roles should contain(worker)
|
||||
pong.roles should contain("team-one")
|
||||
pong.roles should contain(ClusterSettings.TeamRolePrefix + "one")
|
||||
}
|
||||
enterBarrier("after-1")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue