|
Akka/Scala example source code file (NodeMembershipSpec.scala)
The NodeMembershipSpec.scala Akka example source code/** * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package akka.cluster import com.typesafe.config.ConfigFactory import akka.remote.testkit.MultiNodeConfig import akka.remote.testkit.MultiNodeSpec import akka.testkit._ object NodeMembershipMultiJvmSpec extends MultiNodeConfig { val first = role("first") val second = role("second") val third = role("third") commonConfig(debugConfig(on = false).withFallback(MultiNodeClusterSpec.clusterConfigWithFailureDetectorPuppet)) } class NodeMembershipMultiJvmNode1 extends NodeMembershipSpec class NodeMembershipMultiJvmNode2 extends NodeMembershipSpec class NodeMembershipMultiJvmNode3 extends NodeMembershipSpec abstract class NodeMembershipSpec extends MultiNodeSpec(NodeMembershipMultiJvmSpec) with MultiNodeClusterSpec { import NodeMembershipMultiJvmSpec._ "A set of connected cluster systems" must { "(when two nodes) start gossiping to each other so that both nodes gets the same gossip info" taggedAs LongRunningTest in { // make sure that the node-to-join is started before other join runOn(first) { startClusterNode() } enterBarrier("first-started") runOn(first, second) { cluster.join(first) awaitAssert(clusterView.members.size should be(2)) assertMembers(clusterView.members, first, second) awaitAssert(clusterView.members.map(_.status) should be(Set(MemberStatus.Up))) } enterBarrier("after-1") } "(when three nodes) start gossiping to each other so that all nodes gets the same gossip info" taggedAs LongRunningTest in { runOn(third) { cluster.join(first) } awaitAssert(clusterView.members.size should be(3)) assertMembers(clusterView.members, first, second, third) awaitAssert(clusterView.members.map(_.status) should be(Set(MemberStatus.Up))) enterBarrier("after-2") } "correct member age" taggedAs LongRunningTest in { val firstMember = clusterView.members.find(_.address == address(first)).get val secondMember = clusterView.members.find(_.address == address(second)).get val thirdMember = clusterView.members.find(_.address == address(third)).get firstMember.isOlderThan(thirdMember) should be(true) thirdMember.isOlderThan(firstMember) should be(false) secondMember.isOlderThan(thirdMember) should be(true) thirdMember.isOlderThan(secondMember) should be(false) enterBarrier("after-3") } } } Other Akka source code examplesHere is a short list of links related to this Akka NodeMembershipSpec.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.