=clu replace Set -- with diff and ++ with union

* better performance according to
  https://docs.google.com/presentation/d/1Qjryxoe-fYEM8ZPhM-98LKfbhnRcn5eAEMNlVVnixsA/pub
This commit is contained in:
Patrik Nordwall 2015-10-30 14:59:36 +01:00
parent 9380983d3c
commit c7c187f6b7
24 changed files with 46 additions and 46 deletions

View file

@ -303,7 +303,7 @@ trait MultiNodeClusterSpec extends Suite with STMultiNodeSpec with WatchedByCoro
* Wait until the specified nodes have seen the same gossip overview.
*/
def awaitSeenSameState(addresses: Address*): Unit =
awaitAssert((addresses.toSet -- clusterView.seenBy) should ===(Set.empty))
awaitAssert((addresses.toSet diff clusterView.seenBy) should ===(Set.empty))
/**
* Leader according to the address ordering of the roles.

View file

@ -3,8 +3,8 @@
*/
package akka.cluster
// TODO remove metrics
// FIXME this test is not migrated to metrics extension
// TODO remove metrics
// FIXME this test is not migrated to metrics extension
import language.postfixOps
import scala.annotation.tailrec
@ -981,7 +981,7 @@ abstract class StressSpec
timeout = remainingOrDefault)
awaitAllReachable()
}
val nextAddresses = clusterView.members.map(_.address) -- usedAddresses
val nextAddresses = clusterView.members.map(_.address) diff usedAddresses
runOn(usedRoles: _*) {
nextAddresses.size should ===(numberOfNodesJoinRemove)
}

View file

@ -46,7 +46,7 @@ abstract class TransitionSpec
def nonLeader(roles: RoleName*) = roles.toSeq.sorted.tail
def memberStatus(address: Address): MemberStatus = {
val statusOption = (clusterView.members ++ clusterView.unreachableMembers).collectFirst {
val statusOption = (clusterView.members union clusterView.unreachableMembers).collectFirst {
case m if m.address == address m.status
}
statusOption.getOrElse(Removed)
@ -91,7 +91,7 @@ abstract class TransitionSpec
clusterView.latestStats.gossipStats.receivedGossipCount != oldCount // received gossip
}
// gossip chat will synchronize the views
awaitCond((Set(fromRole, toRole) -- seenLatestGossip).isEmpty)
awaitCond((Set(fromRole, toRole) diff seenLatestGossip).isEmpty)
enterBarrier("after-gossip-" + gossipBarrierCounter)
}
runOn(fromRole) {
@ -99,7 +99,7 @@ abstract class TransitionSpec
// send gossip
cluster.clusterCore ! InternalClusterAction.SendGossipTo(toRole)
// gossip chat will synchronize the views
awaitCond((Set(fromRole, toRole) -- seenLatestGossip).isEmpty)
awaitCond((Set(fromRole, toRole) diff seenLatestGossip).isEmpty)
enterBarrier("after-gossip-" + gossipBarrierCounter)
}
runOn(roles.filterNot(r r == fromRole || r == toRole): _*) {

View file

@ -342,7 +342,7 @@ abstract class ClusterRoundRobinSpec extends MultiNodeSpec(ClusterRoundRobinMult
def routeeAddresses = (routees map { case ActorRefRoutee(ref) fullAddress(ref) }).toSet
routees foreach { case ActorRefRoutee(ref) watch(ref) }
val notUsedAddress = ((roles map address).toSet -- routeeAddresses).head
val notUsedAddress = ((roles map address).toSet diff routeeAddresses).head
val downAddress = routeeAddresses.find(_ != address(first)).get
val downRouteeRef = routees.collectFirst {
case ActorRefRoutee(ref) if ref.path.address == downAddress ref