Improve publish of domain events, see #2202

* Gossip is not exposed in user api
* Better and more events
* Snapshot event sent to new subscriber
* Updated tests
* Periodic publish only for internal stats
This commit is contained in:
Patrik Nordwall 2012-08-15 16:47:34 +02:00
parent bc4d8fc7c5
commit 06f81f4373
21 changed files with 294 additions and 197 deletions

View file

@ -29,7 +29,7 @@ object MultiNodeClusterSpec {
leader-actions-interval = 200 ms
unreachable-nodes-reaper-interval = 200 ms
periodic-tasks-initial-delay = 300 ms
publish-state-interval = 0 s # always, when it happens
publish-stats-interval = 0 s # always, when it happens
}
akka.test {
single-expect-default = 5 s
@ -106,9 +106,9 @@ trait MultiNodeClusterSpec extends FailureDetectorStrategy with Suite { self: Mu
* Use this method for the initial startup of the cluster node.
*/
def startClusterNode(): Unit = {
if (cluster.latestGossip.members.isEmpty) {
if (cluster.members.isEmpty) {
cluster join myself
awaitCond(cluster.latestGossip.members.exists(_.address == address(myself)))
awaitCond(cluster.members.exists(_.address == address(myself)))
} else
cluster.self
}
@ -181,25 +181,20 @@ trait MultiNodeClusterSpec extends FailureDetectorStrategy with Suite { self: Mu
canNotBePartOfMemberRing: Seq[Address] = Seq.empty[Address],
timeout: Duration = 20.seconds): Unit = {
within(timeout) {
awaitCond(cluster.latestGossip.members.size == numberOfMembers)
awaitCond(cluster.latestGossip.members.forall(_.status == MemberStatus.Up))
awaitCond(cluster.convergence.isDefined)
awaitCond(cluster.members.size == numberOfMembers)
awaitCond(cluster.members.forall(_.status == MemberStatus.Up))
awaitCond(cluster.convergence)
if (!canNotBePartOfMemberRing.isEmpty) // don't run this on an empty set
awaitCond(
canNotBePartOfMemberRing forall (address !(cluster.latestGossip.members exists (_.address == address))))
canNotBePartOfMemberRing forall (address !(cluster.members exists (_.address == address))))
}
}
/**
* Wait until the specified nodes have seen the same gossip overview.
*/
def awaitSeenSameState(addresses: Address*): Unit = {
awaitCond {
val seen = cluster.latestGossip.overview.seen
val seenVectorClocks = addresses.flatMap(seen.get(_))
seenVectorClocks.size == addresses.size && seenVectorClocks.toSet.size == 1
}
}
def awaitSeenSameState(addresses: Address*): Unit =
awaitCond((addresses.toSet -- cluster.seenBy).isEmpty)
def roleOfLeader(nodesInCluster: Seq[RoleName] = roles): RoleName = {
nodesInCluster.length must not be (0)