Introduce cluster 'team' setting and add to Member
Introduced cluster-team.md so we can grow the documentation with each PR, but did not add it to the ToC yet. (cherry picked from commit a06badaa03fa9f3c9a942b1468090f758c74a869)
This commit is contained in:
parent
a7dc938188
commit
2f11ec6f25
8 changed files with 57 additions and 8 deletions
|
|
@ -65,6 +65,11 @@ akka {
|
||||||
# move 'WeaklyUp' members to 'Up' status once convergence has been reached.
|
# move 'WeaklyUp' members to 'Up' status once convergence has been reached.
|
||||||
allow-weakly-up-members = on
|
allow-weakly-up-members = on
|
||||||
|
|
||||||
|
# Teams are used to make islands of the cluster that are colocated. It can be used
|
||||||
|
# to make the cluster "dc-aware", run the cluster in multiple availability zones or regions.
|
||||||
|
# The team is added to the list of roles of the node with the prefix "team-".
|
||||||
|
team = "default"
|
||||||
|
|
||||||
# The roles of this member. List of strings, e.g. roles = ["A", "B"].
|
# The roles of this member. List of strings, e.g. roles = ["A", "B"].
|
||||||
# The roles are part of the membership information and can be used by
|
# The roles are part of the membership information and can be used by
|
||||||
# routers or other services to distribute work to certain member types,
|
# routers or other services to distribute work to certain member types,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ final class ClusterSettings(val config: Config, val systemName: String) {
|
||||||
|
|
||||||
val AllowWeaklyUpMembers = cc.getBoolean("allow-weakly-up-members")
|
val AllowWeaklyUpMembers = cc.getBoolean("allow-weakly-up-members")
|
||||||
|
|
||||||
val Roles: Set[String] = immutableSeq(cc.getStringList("roles")).toSet
|
val Team: String = cc.getString("team")
|
||||||
|
val Roles: Set[String] = immutableSeq(cc.getStringList("roles")).toSet + s"team-$Team"
|
||||||
val MinNrOfMembers: Int = {
|
val MinNrOfMembers: Int = {
|
||||||
cc.getInt("min-nr-of-members")
|
cc.getInt("min-nr-of-members")
|
||||||
} requiring (_ > 0, "min-nr-of-members must be > 0")
|
} requiring (_ > 0, "min-nr-of-members must be > 0")
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ class Member private[cluster] (
|
||||||
val status: MemberStatus,
|
val status: MemberStatus,
|
||||||
val roles: Set[String]) extends Serializable {
|
val roles: Set[String]) extends Serializable {
|
||||||
|
|
||||||
|
lazy val team = roles.find(_.startsWith("team-"))
|
||||||
|
.getOrElse(throw new IllegalStateException("Team undefined, should not be possible"))
|
||||||
|
|
||||||
def address: Address = uniqueAddress.address
|
def address: Address = uniqueAddress.address
|
||||||
|
|
||||||
override def hashCode = uniqueAddress.##
|
override def hashCode = uniqueAddress.##
|
||||||
|
|
|
||||||
|
|
@ -120,28 +120,32 @@ abstract class MBeanSpec
|
||||||
| {
|
| {
|
||||||
| "address": "${sortedNodes(0)}",
|
| "address": "${sortedNodes(0)}",
|
||||||
| "roles": [
|
| "roles": [
|
||||||
| "testNode"
|
| "testNode",
|
||||||
|
| "team-default"
|
||||||
| ],
|
| ],
|
||||||
| "status": "Up"
|
| "status": "Up"
|
||||||
| },
|
| },
|
||||||
| {
|
| {
|
||||||
| "address": "${sortedNodes(1)}",
|
| "address": "${sortedNodes(1)}",
|
||||||
| "roles": [
|
| "roles": [
|
||||||
| "testNode"
|
| "testNode",
|
||||||
|
| "team-default"
|
||||||
| ],
|
| ],
|
||||||
| "status": "Up"
|
| "status": "Up"
|
||||||
| },
|
| },
|
||||||
| {
|
| {
|
||||||
| "address": "${sortedNodes(2)}",
|
| "address": "${sortedNodes(2)}",
|
||||||
| "roles": [
|
| "roles": [
|
||||||
| "testNode"
|
| "testNode",
|
||||||
|
| "team-default"
|
||||||
| ],
|
| ],
|
||||||
| "status": "Up"
|
| "status": "Up"
|
||||||
| },
|
| },
|
||||||
| {
|
| {
|
||||||
| "address": "${sortedNodes(3)}",
|
| "address": "${sortedNodes(3)}",
|
||||||
| "roles": [
|
| "roles": [
|
||||||
| "testNode"
|
| "testNode",
|
||||||
|
| "team-default"
|
||||||
| ],
|
| ],
|
||||||
| "status": "Up"
|
| "status": "Up"
|
||||||
| }
|
| }
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ abstract class QuickRestartSpec
|
||||||
Cluster(system).state.members.size should ===(totalNumberOfNodes)
|
Cluster(system).state.members.size should ===(totalNumberOfNodes)
|
||||||
Cluster(system).state.members.map(_.status == MemberStatus.Up)
|
Cluster(system).state.members.map(_.status == MemberStatus.Up)
|
||||||
// use the role to test that it is the new incarnation that joined, sneaky
|
// use the role to test that it is the new incarnation that joined, sneaky
|
||||||
Cluster(system).state.members.flatMap(_.roles) should ===(Set(s"round-$n"))
|
Cluster(system).state.members.flatMap(_.roles) should ===(Set(s"round-$n", "team-default"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enterBarrier("members-up-" + n)
|
enterBarrier("members-up-" + n)
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,13 @@
|
||||||
package akka.cluster
|
package akka.cluster
|
||||||
|
|
||||||
import language.postfixOps
|
import language.postfixOps
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
import com.typesafe.config.ConfigFactory
|
||||||
|
|
||||||
import akka.testkit.AkkaSpec
|
import akka.testkit.AkkaSpec
|
||||||
import akka.dispatch.Dispatchers
|
import akka.dispatch.Dispatchers
|
||||||
import scala.concurrent.duration._
|
|
||||||
import akka.remote.PhiAccrualFailureDetector
|
import akka.remote.PhiAccrualFailureDetector
|
||||||
import akka.util.Helpers.ConfigOps
|
import akka.util.Helpers.ConfigOps
|
||||||
import akka.actor.Address
|
import akka.actor.Address
|
||||||
|
|
@ -41,7 +45,8 @@ class ClusterConfigSpec extends AkkaSpec {
|
||||||
DownRemovalMargin should ===(Duration.Zero)
|
DownRemovalMargin should ===(Duration.Zero)
|
||||||
MinNrOfMembers should ===(1)
|
MinNrOfMembers should ===(1)
|
||||||
MinNrOfMembersOfRole should ===(Map.empty[String, Int])
|
MinNrOfMembersOfRole should ===(Map.empty[String, Int])
|
||||||
Roles should ===(Set.empty[String])
|
Team should ===("default")
|
||||||
|
Roles should ===(Set("team-default"))
|
||||||
JmxEnabled should ===(true)
|
JmxEnabled should ===(true)
|
||||||
UseDispatcher should ===(Dispatchers.DefaultDispatcherId)
|
UseDispatcher should ===(Dispatchers.DefaultDispatcherId)
|
||||||
GossipDifferentViewProbability should ===(0.8 +- 0.0001)
|
GossipDifferentViewProbability should ===(0.8 +- 0.0001)
|
||||||
|
|
@ -49,5 +54,20 @@ class ClusterConfigSpec extends AkkaSpec {
|
||||||
SchedulerTickDuration should ===(33 millis)
|
SchedulerTickDuration should ===(33 millis)
|
||||||
SchedulerTicksPerWheel should ===(512)
|
SchedulerTicksPerWheel should ===(512)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"be able to parse non-default cluster config elements" in {
|
||||||
|
val settings = new ClusterSettings(ConfigFactory.parseString(
|
||||||
|
"""
|
||||||
|
|akka {
|
||||||
|
| cluster {
|
||||||
|
| roles = [ "hamlet" ]
|
||||||
|
| team = "blue"
|
||||||
|
| }
|
||||||
|
|}
|
||||||
|
""".stripMargin).withFallback(ConfigFactory.load()), system.name)
|
||||||
|
import settings._
|
||||||
|
Roles should ===(Set("hamlet", "team-blue"))
|
||||||
|
Team should ===("blue")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
akka-docs/src/main/paradox/java/cluster-team.md
Symbolic link
1
akka-docs/src/main/paradox/java/cluster-team.md
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../scala/cluster-team.md
|
||||||
15
akka-docs/src/main/paradox/scala/cluster-team.md
Normal file
15
akka-docs/src/main/paradox/scala/cluster-team.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Cluster Team
|
||||||
|
|
||||||
|
@@@ note
|
||||||
|
|
||||||
|
Cluster teams are a work-in-progress feature, and behavior is still expected to change.
|
||||||
|
|
||||||
|
@@@
|
||||||
|
|
||||||
|
Teams are used to define islands of the cluster that are colocated.
|
||||||
|
They can be used to make the cluster "dc-aware", run the cluster in multiple availability zones or regions.
|
||||||
|
|
||||||
|
Cluster nodes can be assigned to a team by setting the `akka.cluster.team` setting.
|
||||||
|
When no team is specified, a node will belong to the 'default' team.
|
||||||
|
|
||||||
|
The team is added to the list of roles of the node with the prefix "team-".
|
||||||
Loading…
Add table
Add a link
Reference in a new issue