format source with scalafmt

This commit is contained in:
Auto Format 2019-03-11 10:38:24 +01:00 committed by Patrik Nordwall
parent 0f40491d42
commit ce404e4f53
1669 changed files with 43208 additions and 35404 deletions

View file

@ -54,11 +54,11 @@ object DurableDataSpec {
if (failStore) reply match {
case Some(StoreReply(_, failureMsg, replyTo)) => replyTo ! failureMsg
case None =>
}
else reply match {
case Some(StoreReply(successMsg, _, replyTo)) => replyTo ! successMsg
case None =>
}
} else
reply match {
case Some(StoreReply(successMsg, _, replyTo)) => replyTo ! successMsg
case None =>
}
}
}
@ -72,7 +72,9 @@ class DurableDataWriteBehindSpecMultiJvmNode1 extends DurableDataSpec(DurableDat
class DurableDataWriteBehindSpecMultiJvmNode2 extends DurableDataSpec(DurableDataSpecConfig(writeBehind = true))
abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
extends MultiNodeSpec(multiNodeConfig) with STMultiNodeSpec with ImplicitSender {
extends MultiNodeSpec(multiNodeConfig)
with STMultiNodeSpec
with ImplicitSender {
import DurableDataSpec._
import Replicator._
import multiNodeConfig._
@ -95,12 +97,13 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
enterBarrier("after-" + testStepCounter)
}
def newReplicator(sys: ActorSystem = system) = sys.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second)), "replicator-" + testStepCounter)
def newReplicator(sys: ActorSystem = system) =
sys.actorOf(Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second)),
"replicator-" + testStepCounter)
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -272,10 +275,9 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
Await.ready(sys1.terminate(), 10.seconds)
}
val sys2 = ActorSystem(
"AdditionalSys",
// use the same port
ConfigFactory.parseString(s"""
val sys2 = ActorSystem("AdditionalSys",
// use the same port
ConfigFactory.parseString(s"""
akka.remote.artery.canonical.port = ${address.port.get}
akka.remote.netty.tcp.port = ${address.port.get}
""").withFallback(system.settings.config))
@ -310,8 +312,7 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
"stop Replicator if Load fails" in {
runOn(first) {
val r = system.actorOf(
Replicator.props(
ReplicatorSettings(system).withDurableStoreProps(testDurableStoreProps(failLoad = true))),
Replicator.props(ReplicatorSettings(system).withDurableStoreProps(testDurableStoreProps(failLoad = true))),
"replicator-" + testStepCounter)
watch(r)
expectTerminated(r)
@ -322,8 +323,7 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
"reply with StoreFailure if store fails" in {
runOn(first) {
val r = system.actorOf(
Replicator.props(
ReplicatorSettings(system).withDurableStoreProps(testDurableStoreProps(failStore = true))),
Replicator.props(ReplicatorSettings(system).withDurableStoreProps(testDurableStoreProps(failStore = true))),
"replicator-" + testStepCounter)
r ! Update(KeyA, GCounter(), WriteLocal, request = Some("a"))(_ :+ 1)
expectMsg(StoreFailure(KeyA, Some("a")))
@ -332,4 +332,3 @@ abstract class DurableDataSpec(multiNodeConfig: DurableDataSpecConfig)
}
}

View file

@ -50,8 +50,10 @@ class DurablePruningSpec extends MultiNodeSpec(DurablePruningSpec) with STMultiN
def startReplicator(sys: ActorSystem): ActorRef =
sys.actorOf(Replicator.props(
ReplicatorSettings(sys).withGossipInterval(1.second)
.withPruning(pruningInterval = 1.second, maxPruningDissemination)), "replicator")
ReplicatorSettings(sys)
.withGossipInterval(1.second)
.withPruning(pruningInterval = 1.second, maxPruningDissemination)),
"replicator")
val replicator = startReplicator(system)
val timeout = 5.seconds.dilated
@ -59,7 +61,7 @@ class DurablePruningSpec extends MultiNodeSpec(DurablePruningSpec) with STMultiN
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -150,7 +152,8 @@ class DurablePruningSpec extends MultiNodeSpec(DurablePruningSpec) with STMultiN
runOn(first) {
val address = cluster2.selfAddress
val sys3 = ActorSystem(system.name, ConfigFactory.parseString(s"""
val sys3 = ActorSystem(system.name,
ConfigFactory.parseString(s"""
akka.remote.artery.canonical.port = ${address.port.get}
akka.remote.netty.tcp.port = ${address.port.get}
""").withFallback(system.settings.config))
@ -190,4 +193,3 @@ class DurablePruningSpec extends MultiNodeSpec(DurablePruningSpec) with STMultiN
}
}

View file

@ -43,7 +43,10 @@ class JepsenInspiredInsertSpecMultiJvmNode4 extends JepsenInspiredInsertSpec
class JepsenInspiredInsertSpecMultiJvmNode5 extends JepsenInspiredInsertSpec
class JepsenInspiredInsertSpecMultiJvmNode6 extends JepsenInspiredInsertSpec
class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) with STMultiNodeSpec with ImplicitSender {
class JepsenInspiredInsertSpec
extends MultiNodeSpec(JepsenInspiredInsertSpec)
with STMultiNodeSpec
with ImplicitSender {
import JepsenInspiredInsertSpec._
import Replicator._
@ -82,7 +85,7 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -102,7 +105,9 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
}
runOn(controller) {
nodes.foreach { n => enterBarrier(n.name + "-joined") }
nodes.foreach { n =>
enterBarrier(n.name + "-joined")
}
}
enterBarrier("after-setup")
@ -119,7 +124,7 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
writeProbe.receiveOne(3.seconds)
}
val successWriteAcks = writeAcks.collect { case success: UpdateSuccess[_] => success }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
successWriteAcks.map(_.request.get).toSet should be(myData.toSet)
successWriteAcks.size should be(myData.size)
failureWriteAcks should be(Nil)
@ -152,7 +157,7 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
writeProbe.receiveOne(timeout + 1.second)
}
val successWriteAcks = writeAcks.collect { case success: UpdateSuccess[_] => success }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
successWriteAcks.map(_.request.get).toSet should be(myData.toSet)
successWriteAcks.size should be(myData.size)
failureWriteAcks should be(Nil)
@ -196,7 +201,7 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
writeProbe.receiveOne(3.seconds)
}
val successWriteAcks = writeAcks.collect { case success: UpdateSuccess[_] => success }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
successWriteAcks.map(_.request.get).toSet should be(myData.toSet)
successWriteAcks.size should be(myData.size)
failureWriteAcks should be(Nil)
@ -241,7 +246,7 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
writeProbe.receiveOne(timeout + 1.second)
}
val successWriteAcks = writeAcks.collect { case success: UpdateSuccess[_] => success }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
val failureWriteAcks = writeAcks.collect { case fail: UpdateFailure[_] => fail }
runOn(n1, n4, n5) {
successWriteAcks.map(_.request.get).toSet should be(myData.toSet)
successWriteAcks.size should be(myData.size)
@ -282,4 +287,3 @@ class JepsenInspiredInsertSpec extends MultiNodeSpec(JepsenInspiredInsertSpec) w
}
}

View file

@ -78,14 +78,17 @@ class PerformanceSpec extends MultiNodeSpec(PerformanceSpec) with STMultiNodeSpe
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
def repeat(description: String, keys: Iterable[ORSetKey[Int]], n: Int,
expectedAfterReplication: Option[Set[Int]] = None, oneByOne: Boolean = false)(
block: (ORSetKey[Int], Int, ActorRef) => Unit, afterEachKey: ORSetKey[Int] => Unit = _ => ()): Unit = {
def repeat(description: String,
keys: Iterable[ORSetKey[Int]],
n: Int,
expectedAfterReplication: Option[Set[Int]] = None,
oneByOne: Boolean = false)(block: (ORSetKey[Int], Int, ActorRef) => Unit,
afterEachKey: ORSetKey[Int] => Unit = _ => ()): Unit = {
keys.foreach { key =>
val startTime = System.nanoTime()
@ -124,7 +127,9 @@ class PerformanceSpec extends MultiNodeSpec(PerformanceSpec) with STMultiNodeSpe
}
def awaitReplicated(keys: Iterable[ORSetKey[Int]], expectedData: Set[Int]): Unit =
keys.foreach { key => awaitReplicated(key, expectedData) }
keys.foreach { key =>
awaitReplicated(key, expectedData)
}
def awaitReplicated(key: ORSetKey[Int], expectedData: Set[Int]): Unit = {
within(20.seconds) {
@ -266,4 +271,3 @@ class PerformanceSpec extends MultiNodeSpec(PerformanceSpec) with STMultiNodeSpe
}
}

View file

@ -45,8 +45,9 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
val cluster = Cluster(system)
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val replicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withRole("backend").withGossipInterval(1.second)), "replicator")
val replicator = system.actorOf(
Replicator.props(ReplicatorSettings(system).withRole("backend").withGossipInterval(1.second)),
"replicator")
val timeout = 3.seconds.dilated
val KeyA = GCounterKey("A")
@ -59,7 +60,7 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -69,12 +70,13 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
awaitAssert {
replicator ! Get(key, ReadLocal)
val value = expectMsgPF() {
case g @ GetSuccess(`key`, _) => g.dataValue match {
case c: GCounter => c.value
case c: PNCounter => c.value
case c: GSet[_] => c.elements
case c: ORSet[_] => c.elements
}
case g @ GetSuccess(`key`, _) =>
g.dataValue match {
case c: GCounter => c.value
case c: PNCounter => c.value
case c: GSet[_] => c.elements
case c: ORSet[_] => c.elements
}
}
value should be(expected)
}
@ -107,7 +109,7 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
runOn(first) {
for (_ <- 0 until 5) {
replicator ! Update(KeyA, GCounter(), WriteLocal)(_ :+ 1)
replicator ! Update(KeyB, PNCounter(), WriteLocal)(_ decrement 1)
replicator ! Update(KeyB, PNCounter(), WriteLocal)(_.decrement(1))
replicator ! Update(KeyC, GCounter(), WriteAll(timeout))(_ :+ 1)
}
receiveN(15).map(_.getClass).toSet should be(Set(classOf[UpdateSuccess[_]]))
@ -117,9 +119,8 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
replicator ! Update(KeyA, GCounter(), WriteLocal)(_ :+ 20)
replicator ! Update(KeyB, PNCounter(), WriteTo(2, timeout))(_ :+ 20)
replicator ! Update(KeyC, GCounter(), WriteAll(timeout))(_ :+ 20)
receiveN(3).toSet should be(Set(
UpdateSuccess(KeyA, None),
UpdateSuccess(KeyB, None), UpdateSuccess(KeyC, None)))
receiveN(3).toSet should be(
Set(UpdateSuccess(KeyA, None), UpdateSuccess(KeyB, None), UpdateSuccess(KeyC, None)))
replicator ! Update(KeyE, GSet(), WriteLocal)(_ + "e1" + "e2")
expectMsg(UpdateSuccess(KeyE, None))
@ -180,7 +181,7 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
replicator ! Update(KeyE, GSet(), WriteTo(2, timeout))(_ + "e4")
expectMsg(UpdateSuccess(KeyE, None))
replicator ! Update(KeyF, ORSet(), WriteTo(2, timeout))(_ remove "e2")
replicator ! Update(KeyF, ORSet(), WriteTo(2, timeout))(_.remove("e2"))
expectMsg(UpdateSuccess(KeyF, None))
}
runOn(fourth) {
@ -234,4 +235,3 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
}
}

View file

@ -31,7 +31,9 @@ object ReplicatorDeltaSpec extends MultiNodeConfig {
testTransport(on = true)
case class Highest(n: Int, delta: Option[Highest] = None)
extends DeltaReplicatedData with RequiresCausalDeliveryOfDeltas with ReplicatedDelta {
extends DeltaReplicatedData
with RequiresCausalDeliveryOfDeltas
with ReplicatedDelta {
type T = Highest
type D = Highest
@ -143,8 +145,9 @@ class ReplicatorDeltaSpec extends MultiNodeSpec(ReplicatorDeltaSpec) with STMult
val cluster = Cluster(system)
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val fullStateReplicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second).withDeltaCrdtEnabled(false)), "fullStateReplicator")
val fullStateReplicator = system.actorOf(
Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second).withDeltaCrdtEnabled(false)),
"fullStateReplicator")
val deltaReplicator = {
val r = system.actorOf(Replicator.props(ReplicatorSettings(system)), "deltaReplicator")
r ! Replicator.Internal.TestFullStateGossip(enabled = false)
@ -161,7 +164,7 @@ class ReplicatorDeltaSpec extends MultiNodeSpec(ReplicatorDeltaSpec) with STMult
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -370,8 +373,8 @@ class ReplicatorDeltaSpec extends MultiNodeSpec(ReplicatorDeltaSpec) with STMult
fullStateReplicator ! Update(key, PNCounter.empty, consistency)(_ :+ n)
deltaReplicator ! Update(key, PNCounter.empty, consistency)(_ :+ n)
case Decr(key, n, consistency) =>
fullStateReplicator ! Update(key, PNCounter.empty, consistency)(_ decrement n)
deltaReplicator ! Update(key, PNCounter.empty, consistency)(_ decrement n)
fullStateReplicator ! Update(key, PNCounter.empty, consistency)(_.decrement(n))
deltaReplicator ! Update(key, PNCounter.empty, consistency)(_.decrement(n))
case Add(key, elem, consistency) =>
// to have an deterministic result when mixing add/remove we can only perform
// the ORSet operations from one node
@ -381,8 +384,8 @@ class ReplicatorDeltaSpec extends MultiNodeSpec(ReplicatorDeltaSpec) with STMult
}
case Remove(key, elem, consistency) =>
runOn(first) {
fullStateReplicator ! Update(key, ORSet.empty[String], consistency)(_ remove elem)
deltaReplicator ! Update(key, ORSet.empty[String], consistency)(_ remove elem)
fullStateReplicator ! Update(key, ORSet.empty[String], consistency)(_.remove(elem))
deltaReplicator ! Update(key, ORSet.empty[String], consistency)(_.remove(elem))
}
}
}
@ -425,4 +428,3 @@ class ReplicatorDeltaSpec extends MultiNodeSpec(ReplicatorDeltaSpec) with STMult
}
}

View file

@ -40,13 +40,19 @@ object ReplicatorMapDeltaSpec extends MultiNodeConfig {
final case class Incr(ki: (PNCounterMapKey[String], String), n: Int, consistency: WriteConsistency) extends Op
final case class Decr(ki: (PNCounterMapKey[String], String), n: Int, consistency: WriteConsistency) extends Op
// AddVD and RemoveVD for variant of ORMultiMap with Value Deltas, NoVD - for the vanilla ORMultiMap
final case class AddVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency) extends Op
final case class RemoveVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency) extends Op
final case class AddNoVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency) extends Op
final case class RemoveNoVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency) extends Op
final case class AddVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency)
extends Op
final case class RemoveVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency)
extends Op
final case class AddNoVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency)
extends Op
final case class RemoveNoVD(ki: (ORMultiMapKey[String, String], String), elem: String, consistency: WriteConsistency)
extends Op
// AddOM and RemoveOM for Vanilla ORMap holding ORSet inside
final case class AddOM(ki: (ORMapKey[String, ORSet[String]], String), elem: String, consistency: WriteConsistency) extends Op
final case class RemoveOM(ki: (ORMapKey[String, ORSet[String]], String), elem: String, consistency: WriteConsistency) extends Op
final case class AddOM(ki: (ORMapKey[String, ORSet[String]], String), elem: String, consistency: WriteConsistency)
extends Op
final case class RemoveOM(ki: (ORMapKey[String, ORSet[String]], String), elem: String, consistency: WriteConsistency)
extends Op
val timeout = 5.seconds
val writeTwo = WriteTo(2, timeout)
@ -164,10 +170,12 @@ object ReplicatorMapDeltaSpec extends MultiNodeConfig {
}.toVector
}
def addElementToORMap(om: ORMap[String, ORSet[String]], key: String, element: String)(implicit node: SelfUniqueAddress) =
def addElementToORMap(om: ORMap[String, ORSet[String]], key: String, element: String)(
implicit node: SelfUniqueAddress) =
om.updated(node, key, ORSet.empty[String])(_ :+ element)
def removeElementFromORMap(om: ORMap[String, ORSet[String]], key: String, element: String)(implicit node: SelfUniqueAddress) =
def removeElementFromORMap(om: ORMap[String, ORSet[String]], key: String, element: String)(
implicit node: SelfUniqueAddress) =
om.updated(node, key, ORSet.empty[String])(_.remove(element))
}
@ -184,16 +192,17 @@ class ReplicatorMapDeltaSpec extends MultiNodeSpec(ReplicatorMapDeltaSpec) with
val cluster = Cluster(system)
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val fullStateReplicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second).withDeltaCrdtEnabled(false)), "fullStateReplicator")
val fullStateReplicator = system.actorOf(
Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second).withDeltaCrdtEnabled(false)),
"fullStateReplicator")
val deltaReplicator = {
val r = system.actorOf(Replicator.props(ReplicatorSettings(system)), "deltaReplicator")
r ! Replicator.Internal.TestFullStateGossip(enabled = false)
r
}
// both deltas and full state
val ordinaryReplicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second)), "ordinaryReplicator")
val ordinaryReplicator =
system.actorOf(Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second)), "ordinaryReplicator")
var afterCounter = 0
def enterBarrierAfterTestStep(): Unit = {
@ -203,7 +212,7 @@ class ReplicatorMapDeltaSpec extends MultiNodeSpec(ReplicatorMapDeltaSpec) with
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -246,16 +255,20 @@ class ReplicatorMapDeltaSpec extends MultiNodeSpec(ReplicatorMapDeltaSpec) with
deltaReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_.incrementBy(key._2, 1))
}
List(KeyD, KeyE, KeyF).foreach { key =>
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ :+ (key._2 -> Set("a")))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ :+ (key._2 -> Set("a")))
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_ :+ (key._2 -> Set("a")))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_ :+ (key._2 -> Set("a")))
}
List(KeyG, KeyH, KeyI).foreach { key =>
fullStateReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ :+ (key._2 -> Set("a")))
deltaReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ :+ (key._2 -> Set("a")))
}
List(KeyJ, KeyK, KeyL).foreach { key =>
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(_ :+ (key._2 -> (ORSet.empty :+ "a")))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(_ :+ (key._2 -> (ORSet.empty :+ "a")))
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(
_ :+ (key._2 -> (ORSet.empty :+ "a")))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(
_ :+ (key._2 -> (ORSet.empty :+ "a")))
}
}
enterBarrier("updated-1")
@ -335,46 +348,58 @@ class ReplicatorMapDeltaSpec extends MultiNodeSpec(ReplicatorMapDeltaSpec) with
op match {
case Delay(d) => Thread.sleep(d)
case Incr(key, n, _) =>
fullStateReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_ incrementBy (key._2, n))
deltaReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_ incrementBy (key._2, n))
fullStateReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_.incrementBy(key._2, n))
deltaReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_.incrementBy(key._2, n))
case Decr(key, n, _) =>
fullStateReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_ decrementBy (key._2, n))
deltaReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_ decrementBy (key._2, n))
fullStateReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_.decrementBy(key._2, n))
deltaReplicator ! Update(key._1, PNCounterMap.empty[String], WriteLocal)(_.decrementBy(key._2, n))
case AddVD(key, elem, _) =>
// to have an deterministic result when mixing add/remove we can only perform
// the ORSet operations from one node
runOn((if (key == KeyF) List(first) else List(first, second, third)): _*) {
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ addBindingBy (key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ addBindingBy (key._2, elem))
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_.addBindingBy(key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_.addBindingBy(key._2, elem))
}
case RemoveVD(key, elem, _) =>
runOn(first) {
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ removeBindingBy (key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(_ removeBindingBy (key._2, elem))
fullStateReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_.removeBindingBy(key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.emptyWithValueDeltas[String, String], WriteLocal)(
_.removeBindingBy(key._2, elem))
}
case AddNoVD(key, elem, _) =>
// to have an deterministic result when mixing add/remove we can only perform
// the ORSet operations from one node
runOn((if (key == KeyI) List(first) else List(first, second, third)): _*) {
fullStateReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ addBindingBy (key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ addBindingBy (key._2, elem))
fullStateReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(
_.addBindingBy(key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(
_.addBindingBy(key._2, elem))
}
case RemoveNoVD(key, elem, _) =>
runOn(first) {
fullStateReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ removeBindingBy (key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(_ removeBindingBy (key._2, elem))
fullStateReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(
_.removeBindingBy(key._2, elem))
deltaReplicator ! Update(key._1, ORMultiMap.empty[String, String], WriteLocal)(
_.removeBindingBy(key._2, elem))
}
case AddOM(key, elem, _) =>
// to have an deterministic result when mixing add/remove we can only perform
// the ORSet operations from one node
runOn((if (key == KeyL) List(first) else List(first, second, third)): _*) {
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om => addElementToORMap(om, key._2, elem))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om => addElementToORMap(om, key._2, elem))
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om =>
addElementToORMap(om, key._2, elem))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om =>
addElementToORMap(om, key._2, elem))
}
case RemoveOM(key, elem, _) =>
runOn(first) {
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om => removeElementFromORMap(om, key._2, elem))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om => removeElementFromORMap(om, key._2, elem))
fullStateReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om =>
removeElementFromORMap(om, key._2, elem))
deltaReplicator ! Update(key._1, ORMap.empty[String, ORSet[String]], WriteLocal)(om =>
removeElementFromORMap(om, key._2, elem))
}
}
}
@ -443,4 +468,3 @@ class ReplicatorMapDeltaSpec extends MultiNodeSpec(ReplicatorMapDeltaSpec) with
}
}

View file

@ -36,7 +36,10 @@ class ReplicatorORSetDeltaSpecMultiJvmNode1 extends ReplicatorORSetDeltaSpec
class ReplicatorORSetDeltaSpecMultiJvmNode2 extends ReplicatorORSetDeltaSpec
class ReplicatorORSetDeltaSpecMultiJvmNode3 extends ReplicatorORSetDeltaSpec
class ReplicatorORSetDeltaSpec extends MultiNodeSpec(ReplicatorORSetDeltaSpec) with STMultiNodeSpec with ImplicitSender {
class ReplicatorORSetDeltaSpec
extends MultiNodeSpec(ReplicatorORSetDeltaSpec)
with STMultiNodeSpec
with ImplicitSender {
import Replicator._
import ReplicatorORSetDeltaSpec._
@ -44,8 +47,8 @@ class ReplicatorORSetDeltaSpec extends MultiNodeSpec(ReplicatorORSetDeltaSpec) w
val cluster = Cluster(system)
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val replicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second)), "replicator")
val replicator =
system.actorOf(Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second)), "replicator")
val timeout = 3.seconds.dilated
val KeyA = ORSetKey[String]("A")
@ -54,7 +57,7 @@ class ReplicatorORSetDeltaSpec extends MultiNodeSpec(ReplicatorORSetDeltaSpec) w
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -64,9 +67,10 @@ class ReplicatorORSetDeltaSpec extends MultiNodeSpec(ReplicatorORSetDeltaSpec) w
awaitAssert {
replicator ! Get(key, ReadLocal)
val value = expectMsgPF() {
case g @ GetSuccess(`key`, _) => g.dataValue match {
case c: ORSet[_] => c.elements
}
case g @ GetSuccess(`key`, _) =>
g.dataValue match {
case c: ORSet[_] => c.elements
}
}
value should be(expected)
}
@ -166,4 +170,3 @@ class ReplicatorORSetDeltaSpec extends MultiNodeSpec(ReplicatorORSetDeltaSpec) w
}
}

View file

@ -42,8 +42,10 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val maxPruningDissemination = 3.seconds
val replicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second)
.withPruning(pruningInterval = 1.second, maxPruningDissemination)), "replicator")
ReplicatorSettings(system)
.withGossipInterval(1.second)
.withPruning(pruningInterval = 1.second, maxPruningDissemination)),
"replicator")
val timeout = 3.seconds.dilated
val KeyA = GCounterKey("A")
@ -54,7 +56,7 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -77,10 +79,13 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
val memberProbe = TestProbe()
cluster.subscribe(memberProbe.ref, initialStateMode = InitialStateAsEvents, classOf[MemberUp])
val thirdUniqueAddress = {
val member = memberProbe.fishForMessage(3.seconds) {
case MemberUp(m) if m.address == node(third).address => true
case _ => false
}.asInstanceOf[MemberUp].member
val member = memberProbe
.fishForMessage(3.seconds) {
case MemberUp(m) if m.address == node(third).address => true
case _ => false
}
.asInstanceOf[MemberUp]
.member
member.uniqueAddress
}
@ -90,13 +95,17 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
replicator ! Update(KeyB, ORSet(), WriteAll(timeout))(_ :+ "a" :+ "b" :+ "c")
expectMsg(UpdateSuccess(KeyB, None))
replicator ! Update(KeyC, PNCounterMap.empty[String], WriteAll(timeout)) { _.incrementBy("x", 1).incrementBy("y", 1) }
replicator ! Update(KeyC, PNCounterMap.empty[String], WriteAll(timeout)) {
_.incrementBy("x", 1).incrementBy("y", 1)
}
expectMsg(UpdateSuccess(KeyC, None))
replicator ! Update(KeyD, ORMultiMap.empty[String, String], WriteAll(timeout)) { _ :+ ("a" -> Set("A")) }
expectMsg(UpdateSuccess(KeyD, None))
replicator ! Update(KeyE, ORMap.empty[String, GSet[String]], WriteAll(timeout)) { _ :+ ("a" -> GSet.empty[String].add("A")) }
replicator ! Update(KeyE, ORMap.empty[String, GSet[String]], WriteAll(timeout)) {
_ :+ ("a" -> GSet.empty[String].add("A"))
}
expectMsg(UpdateSuccess(KeyE, None))
enterBarrier("updates-done")
@ -126,7 +135,7 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
enterBarrier("get-old")
runOn(third) {
replicator ! Update(KeyE, ORMap.empty[String, GSet[String]], WriteLocal) { _ remove "a" }
replicator ! Update(KeyE, ORMap.empty[String, GSet[String]], WriteLocal) { _.remove("a") }
expectMsg(UpdateSuccess(KeyE, None))
}
@ -246,4 +255,3 @@ class ReplicatorPruningSpec extends MultiNodeSpec(ReplicatorPruningSpec) with ST
}
}

View file

@ -42,8 +42,9 @@ class ReplicatorSpec extends MultiNodeSpec(ReplicatorSpec) with STMultiNodeSpec
val cluster = Cluster(system)
implicit val selfUniqueAddress = DistributedData(system).selfUniqueAddress
val replicator = system.actorOf(Replicator.props(
ReplicatorSettings(system).withGossipInterval(1.second).withMaxDeltaElements(10)), "replicator")
val replicator = system.actorOf(
Replicator.props(ReplicatorSettings(system).withGossipInterval(1.second).withMaxDeltaElements(10)),
"replicator")
val timeout = 3.seconds.dilated
val writeTwo = WriteTo(2, timeout)
val writeMajority = WriteMajority(timeout)
@ -75,7 +76,7 @@ class ReplicatorSpec extends MultiNodeSpec(ReplicatorSpec) with STMultiNodeSpec
def join(from: RoleName, to: RoleName): Unit = {
runOn(from) {
cluster join node(to).address
cluster.join(node(to).address)
}
enterBarrier(from.name + "-joined")
}
@ -575,4 +576,3 @@ class ReplicatorSpec extends MultiNodeSpec(ReplicatorSpec) with STMultiNodeSpec
}
}

View file

@ -12,8 +12,7 @@ import org.scalatest.Matchers
/**
* Hooks up MultiNodeSpec with ScalaTest
*/
trait STMultiNodeSpec extends MultiNodeSpecCallbacks
with WordSpecLike with Matchers with BeforeAndAfterAll {
trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with Matchers with BeforeAndAfterAll {
override def beforeAll() = multiNodeSpecBeforeAll()