Merge pull request #1723 from akka/wip-3600-disable-assertInvariants-patriknw

=clu #3600 Disable Cluster assertInvariants checks by default
This commit is contained in:
Patrik Nordwall 2013-09-13 08:13:10 -07:00
commit 1187fecfcc
4 changed files with 11 additions and 13 deletions

View file

@ -39,6 +39,15 @@ object Cluster extends ExtensionId[Cluster] with ExtensionIdProvider {
override def lookup = Cluster
override def createExtension(system: ExtendedActorSystem): Cluster = new Cluster(system)
/**
* INTERNAL API
*/
private[cluster] final val isAssertInvariantsEnabled: Boolean =
System.getProperty("akka.cluster.assert", "off").toLowerCase match {
case "on" | "true" true
case _ false
}
}
/**

View file

@ -255,8 +255,7 @@ private[cluster] case class ClusterHeartbeatSenderState private (
ending: Set[Address] = Set.empty,
heartbeatRequest: Map[Address, Deadline] = Map.empty) {
// TODO can be disabled as optimization
assertInvariants()
if (Cluster.isAssertInvariantsEnabled) assertInvariants()
private def assertInvariants(): Unit = {
val currentAndEnding = current.intersect(ending)

View file

@ -63,8 +63,7 @@ private[cluster] case class Gossip(
overview: GossipOverview = GossipOverview(),
version: VectorClock = VectorClock()) { // vector clock version
// TODO can be disabled as optimization
assertInvariants()
if (Cluster.isAssertInvariantsEnabled) assertInvariants()
private def assertInvariants(): Unit = {

View file

@ -60,15 +60,6 @@ class GossipSpec extends WordSpec with MustMatchers {
merged2.overview.reachability.allUnreachable must be(merged1.overview.reachability.allUnreachable)
}
"not have live members with wrong status" in intercept[IllegalArgumentException] {
// b2 is Removed
Gossip(members = SortedSet(a2, b2))
}
"not have non cluster members in seen table" in intercept[IllegalArgumentException] {
Gossip(members = SortedSet(a1, e1)).seen(a1.uniqueAddress).seen(e1.uniqueAddress).seen(b1.uniqueAddress)
}
"have leader as first member based on ordering, except Exiting status" in {
Gossip(members = SortedSet(c2, e2)).leader must be(Some(c2.uniqueAddress))
Gossip(members = SortedSet(c3, e2)).leader must be(Some(e2.uniqueAddress))