Upgrade to Scala 2.13.5 (#30072)
This commit is contained in:
parent
846359919f
commit
c5655a9ce6
264 changed files with 1071 additions and 538 deletions
|
|
@ -137,7 +137,7 @@ final class LmdbDurableStore(config: Config) extends Actor with ActorLogging {
|
|||
|
||||
private def lmdb(): Lmdb = _lmdb match {
|
||||
case OptionVal.Some(l) => l
|
||||
case OptionVal.None =>
|
||||
case _ =>
|
||||
val t0 = System.nanoTime()
|
||||
log.info("Using durable data in LMDB directory [{}]", dir.getCanonicalPath)
|
||||
val env = {
|
||||
|
|
@ -274,8 +274,8 @@ final class LmdbDurableStore(config: Config) extends Actor with ActorLogging {
|
|||
l.keyBuffer.put(key.getBytes(ByteString.UTF_8)).flip()
|
||||
l.valueBuffer.put(value).flip()
|
||||
tx match {
|
||||
case OptionVal.None => l.db.put(l.keyBuffer, l.valueBuffer)
|
||||
case OptionVal.Some(t) => l.db.put(t, l.keyBuffer, l.valueBuffer)
|
||||
case _ => l.db.put(l.keyBuffer, l.valueBuffer)
|
||||
}
|
||||
} finally {
|
||||
val l = lmdb()
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class ReplicatorChaosSpec extends MultiNodeSpec(ReplicatorChaosSpec) with STMult
|
|||
case c: PNCounter => c.value
|
||||
case c: GSet[_] => c.elements
|
||||
case c: ORSet[_] => c.elements
|
||||
case _ => fail()
|
||||
}
|
||||
}
|
||||
value should be(expected)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ class ReplicatorORSetDeltaSpec
|
|||
case g @ GetSuccess(`key`, _) =>
|
||||
g.dataValue match {
|
||||
case c: ORSet[_] => c.elements
|
||||
case _ => fail()
|
||||
}
|
||||
}
|
||||
value should be(expected)
|
||||
|
|
|
|||
|
|
@ -190,13 +190,19 @@ class GCounterSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"have unapply extractor" in {
|
||||
val c1 = GCounter.empty.increment(node1).increment(node2)
|
||||
val GCounter(value1) = c1
|
||||
val value1 = c1 match {
|
||||
case GCounter(value1) => value1
|
||||
case _ => fail()
|
||||
}
|
||||
val value2: BigInt = value1
|
||||
value2 should be(2L)
|
||||
|
||||
Changed(GCounterKey("key"))(c1) match {
|
||||
case c @ Changed(GCounterKey("key")) =>
|
||||
val GCounter(value3) = c.dataValue
|
||||
val value3 = c.dataValue match {
|
||||
case GCounter(value3) => value3
|
||||
case _ => fail()
|
||||
}
|
||||
val value4: BigInt = value3
|
||||
value4 should be(2L)
|
||||
case _ =>
|
||||
|
|
|
|||
|
|
@ -71,13 +71,19 @@ class LWWMapSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"have unapply extractor" in {
|
||||
val m1 = LWWMap.empty[String, Long].put(node1, "a", 1L, defaultClock[Long])
|
||||
val LWWMap(entries1) = m1
|
||||
val entries1 = m1 match {
|
||||
case LWWMap(entries1) => entries1
|
||||
case _ => fail()
|
||||
}
|
||||
val entries2: Map[String, Long] = entries1
|
||||
entries2 should be(Map("a" -> 1L))
|
||||
|
||||
Changed(LWWMapKey[String, Long]("key"))(m1) match {
|
||||
case c @ Changed(LWWMapKey("key")) =>
|
||||
val LWWMap(entries3) = c.dataValue
|
||||
val entries3 = c.dataValue match {
|
||||
case LWWMap(entries3) => entries3
|
||||
case _ => fail()
|
||||
}
|
||||
val entries4: Map[String, Long] = entries3
|
||||
entries4 should be(Map("a" -> 1L))
|
||||
case changed =>
|
||||
|
|
|
|||
|
|
@ -70,13 +70,19 @@ class LWWRegisterSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"have unapply extractor" in {
|
||||
val r1 = LWWRegister(node1, "a", defaultClock[String])
|
||||
val LWWRegister(value1) = r1
|
||||
val value1 = r1 match {
|
||||
case LWWRegister(value1) => value1
|
||||
case _ => fail()
|
||||
}
|
||||
val value2: String = value1
|
||||
value2 should be("a")
|
||||
|
||||
Changed(LWWRegisterKey[String]("key"))(r1) match {
|
||||
case c @ Changed(LWWRegisterKey("key")) =>
|
||||
val LWWRegister(value3) = c.dataValue
|
||||
val value3 = c.dataValue match {
|
||||
case LWWRegister(value3) => value3
|
||||
case _ => fail()
|
||||
}
|
||||
val value4: String = value3
|
||||
value4 should be("a")
|
||||
case changed =>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,10 @@ class LocalConcurrencySpec(_system: ActorSystem)
|
|||
val expected = ((1 to numMessages).map("a" + _) ++ (1 to numMessages).map("b" + _)).toSet
|
||||
awaitAssert {
|
||||
replicator ! Replicator.Get(Updater.key, Replicator.ReadLocal)
|
||||
val ORSet(elements) = expectMsgType[Replicator.GetSuccess[_]].get(Updater.key)
|
||||
val elements = expectMsgType[Replicator.GetSuccess[_]].get(Updater.key) match {
|
||||
case ORSet(e) => e
|
||||
case _ => fail()
|
||||
}
|
||||
elements should be(expected)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,10 @@ class LotsOfDataBot extends Actor with ActorLogging {
|
|||
case _: UpdateResponse[_] => // ignore
|
||||
|
||||
case c @ Changed(ORSetKey(id)) =>
|
||||
val ORSet(elements) = c.dataValue
|
||||
val elements = c.dataValue match {
|
||||
case ORSet(e) => e
|
||||
case _ => throw new RuntimeException()
|
||||
}
|
||||
log.info("Current elements: {} -> {}", id, elements)
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +133,10 @@ class LotsOfDataBot extends Actor with ActorLogging {
|
|||
log.info("It took {} ms to replicate {} entries", duration, keys.size)
|
||||
}
|
||||
case c @ Changed(ORSetKey(id)) =>
|
||||
val ORSet(elements) = c.dataValue
|
||||
val elements = c.dataValue match {
|
||||
case ORSet(e) => e
|
||||
case _ => throw new RuntimeException()
|
||||
}
|
||||
log.info("Current elements: {} -> {}", id, elements)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,22 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"be able to add entries" in {
|
||||
val m = ORMap().put(node1, "a", GSet() + "A").put(node1, "b", GSet() + "B")
|
||||
val GSet(a) = m.entries("a")
|
||||
val a = m.entries("a") match {
|
||||
case GSet(a) => a
|
||||
case _ => fail()
|
||||
}
|
||||
a should be(Set("A"))
|
||||
val GSet(b) = m.entries("b")
|
||||
val b = m.entries("b") match {
|
||||
case GSet(b) => b
|
||||
case _ => fail()
|
||||
}
|
||||
b should be(Set("B"))
|
||||
|
||||
val m2 = m.put(node1, "a", GSet() + "C")
|
||||
val GSet(a2) = m2.entries("a")
|
||||
val a2 = m2.entries("a") match {
|
||||
case GSet(a2) => a2
|
||||
case _ => fail()
|
||||
}
|
||||
a2 should be(Set("C"))
|
||||
|
||||
}
|
||||
|
|
@ -38,13 +47,22 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
val m1 = ORMap().mergeDelta(md)
|
||||
|
||||
val GSet(a) = m1.entries("a")
|
||||
val a = m1.entries("a") match {
|
||||
case GSet(a) => a
|
||||
case _ => fail()
|
||||
}
|
||||
a should be(Set("A"))
|
||||
val GSet(b) = m1.entries("b")
|
||||
val b = m1.entries("b") match {
|
||||
case GSet(b) => b
|
||||
case _ => fail()
|
||||
}
|
||||
b should be(Set("B"))
|
||||
|
||||
val m2 = m1.put(node1, "a", GSet() + "C")
|
||||
val GSet(a2) = m2.entries("a")
|
||||
val a2 = m2.entries("a") match {
|
||||
case GSet(a2) => a2
|
||||
case _ => fail()
|
||||
}
|
||||
a2 should be(Set("C"))
|
||||
|
||||
}
|
||||
|
|
@ -110,26 +128,44 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
// merge both ways
|
||||
val merged1 = m1.merge(m2)
|
||||
merged1.entries.keySet should contain("a")
|
||||
val GSet(a1) = merged1.entries("a")
|
||||
val a1 = merged1.entries("a") match {
|
||||
case GSet(a1) => a1
|
||||
case _ => fail()
|
||||
}
|
||||
a1 should be(Set("A2"))
|
||||
merged1.entries.keySet should contain("b")
|
||||
val GSet(b1) = merged1.entries("b")
|
||||
val b1 = merged1.entries("b") match {
|
||||
case GSet(b1) => b1
|
||||
case _ => fail()
|
||||
}
|
||||
b1 should be(Set("B1"))
|
||||
merged1.entries.keySet should contain("c")
|
||||
merged1.entries.keySet should contain("d")
|
||||
val GSet(d1) = merged1.entries("d")
|
||||
val d1 = merged1.entries("d") match {
|
||||
case GSet(d1) => d1
|
||||
case _ => fail()
|
||||
}
|
||||
d1 should be(Set("D1", "D2"))
|
||||
|
||||
val merged2 = m2.merge(m1)
|
||||
merged2.entries.keySet should contain("a")
|
||||
val GSet(a2) = merged1.entries("a")
|
||||
val a2 = merged1.entries("a") match {
|
||||
case GSet(a2) => a2
|
||||
case _ => fail()
|
||||
}
|
||||
a2 should be(Set("A2"))
|
||||
merged2.entries.keySet should contain("b")
|
||||
val GSet(b2) = merged2.entries("b")
|
||||
val b2 = merged2.entries("b") match {
|
||||
case GSet(b2) => b2
|
||||
case _ => fail()
|
||||
}
|
||||
b2 should be(Set("B1"))
|
||||
merged2.entries.keySet should contain("c")
|
||||
merged2.entries.keySet should contain("d")
|
||||
val GSet(d2) = merged2.entries("d")
|
||||
val d2 = merged2.entries("d") match {
|
||||
case GSet(d2) => d2
|
||||
case _ => fail()
|
||||
}
|
||||
d2 should be(Set("D1", "D2"))
|
||||
}
|
||||
|
||||
|
|
@ -553,7 +589,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
val m1 = ORMap.empty.put(node1, "a", GSet.empty + "A")
|
||||
val m2 = m1.resetDelta.updated(node1, "a", GSet.empty[String])(_.add("B"))
|
||||
val m3 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get)
|
||||
val GSet(d3) = m3.entries("a")
|
||||
val d3 = m3.entries("a") match {
|
||||
case GSet(d3) => d3
|
||||
case _ => fail()
|
||||
}
|
||||
d3 should be(Set("A", "B"))
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +601,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
val m2 = m1.resetDelta.updated(node1, "a", ORSet.empty[String])(_.add(node1, "B"))
|
||||
val m3 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get)
|
||||
|
||||
val ORSet(d3) = m3.entries("a")
|
||||
val d3 = m3.entries("a") match {
|
||||
case ORSet(d3) => d3
|
||||
case _ => fail()
|
||||
}
|
||||
d3 should be(Set("A", "B"))
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +614,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
.updated(node1, "a", GSet.empty[String])(_.add("B"))
|
||||
.updated(node1, "a", GSet.empty[String])(_.add("C"))
|
||||
val m3 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get)
|
||||
val GSet(d3) = m3.entries("a")
|
||||
val d3 = m3.entries("a") match {
|
||||
case GSet(d3) => d3
|
||||
case _ => fail()
|
||||
}
|
||||
d3 should be(Set("A", "B", "C"))
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +626,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
val m2 = m1.resetDelta.updated(node1, "a", GCounter.empty)(_.increment(node1, 10))
|
||||
val m3 = m2.resetDelta.updated(node2, "a", GCounter.empty)(_.increment(node2, 10))
|
||||
val m4 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get).mergeDelta(m3.delta.get)
|
||||
val GCounter(num) = m4.entries("a")
|
||||
val num = m4.entries("a") match {
|
||||
case GCounter(num) => num
|
||||
case _ => fail()
|
||||
}
|
||||
num should ===(20)
|
||||
}
|
||||
|
||||
|
|
@ -590,7 +638,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
val m2 = m1.resetDelta.updated(node1, "a", PNCounter.empty)(_.increment(node1, 10))
|
||||
val m3 = m2.resetDelta.updated(node2, "a", PNCounter.empty)(_.decrement(node2, 10))
|
||||
val m4 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get).mergeDelta(m3.delta.get)
|
||||
val PNCounter(num) = m4.entries("a")
|
||||
val num = m4.entries("a") match {
|
||||
case PNCounter(num) => num
|
||||
case _ => fail()
|
||||
}
|
||||
num should ===(0)
|
||||
}
|
||||
|
||||
|
|
@ -598,7 +649,10 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
val m1 = ORMap.empty.put(node1, "a", Flag(false))
|
||||
val m2 = m1.resetDelta.updated(node1, "a", Flag.Disabled)(_.switchOn)
|
||||
val m3 = ORMap().mergeDelta(m1.delta.get).mergeDelta(m2.delta.get)
|
||||
val Flag(d3) = m3.entries("a")
|
||||
val d3 = m3.entries("a") match {
|
||||
case Flag(d3) => d3
|
||||
case _ => fail()
|
||||
}
|
||||
d3 should be(true)
|
||||
}
|
||||
|
||||
|
|
@ -689,13 +743,19 @@ class ORMapSpec extends AnyWordSpec with Matchers {
|
|||
"have unapply extractor" in {
|
||||
val m1 = ORMap.empty.put(node1, "a", Flag(true)).put(node2, "b", Flag(false))
|
||||
val _: ORMap[String, Flag] = m1
|
||||
val ORMap(entries1) = m1
|
||||
val entries1 = m1 match {
|
||||
case ORMap(entries1) => entries1
|
||||
case _ => fail()
|
||||
}
|
||||
val entries2: Map[String, Flag] = entries1
|
||||
entries2 should be(Map("a" -> Flag(true), "b" -> Flag(false)))
|
||||
|
||||
Changed(ORMapKey[String, Flag]("key"))(m1) match {
|
||||
case c @ Changed(ORMapKey("key")) =>
|
||||
val ORMap(entries3) = c.dataValue
|
||||
val entries3 = c.dataValue match {
|
||||
case ORMap(entries3) => entries3
|
||||
case _ => fail()
|
||||
}
|
||||
val entries4: Map[String, ReplicatedData] = entries3
|
||||
entries4 should be(Map("a" -> Flag(true), "b" -> Flag(false)))
|
||||
case changed =>
|
||||
|
|
|
|||
|
|
@ -555,13 +555,19 @@ class ORMultiMapSpec extends AnyWordSpec with Matchers {
|
|||
"have unapply extractor" in {
|
||||
val m1 = ORMultiMap.empty.put(node1, "a", Set(1L, 2L)).put(node2, "b", Set(3L))
|
||||
val _: ORMultiMap[String, Long] = m1
|
||||
val ORMultiMap(entries1) = m1
|
||||
val entries1 = m1 match {
|
||||
case ORMultiMap(entries1) => entries1
|
||||
case _ => fail()
|
||||
}
|
||||
val entries2: Map[String, Set[Long]] = entries1
|
||||
entries2 should be(Map("a" -> Set(1L, 2L), "b" -> Set(3L)))
|
||||
|
||||
Changed(ORMultiMapKey[String, Long]("key"))(m1) match {
|
||||
case c @ Changed(ORMultiMapKey("key")) =>
|
||||
val ORMultiMap(entries3) = c.dataValue
|
||||
val entries3 = c.dataValue match {
|
||||
case ORMultiMap(entries3: Map[String, Set[Long]]) => entries3
|
||||
case _ => fail()
|
||||
}
|
||||
val entries4: Map[String, Set[Long]] = entries3
|
||||
entries4 should be(Map("a" -> Set(1L, 2L), "b" -> Set(3L)))
|
||||
case changed =>
|
||||
|
|
|
|||
|
|
@ -450,7 +450,10 @@ class ORSetSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
val merged2 = node3_1.mergeDelta(delta2_2)
|
||||
|
||||
val ORSet(mg2) = merged2
|
||||
val mg2 = merged2 match {
|
||||
case ORSet(mg2) => mg2
|
||||
case _ => fail()
|
||||
}
|
||||
mg2 should be(Set("x")) // !!!
|
||||
}
|
||||
|
||||
|
|
@ -602,14 +605,20 @@ class ORSetSpec extends AnyWordSpec with Matchers {
|
|||
"have unapply extractor" in {
|
||||
val s1 = ORSet.empty.add(node1, "a").add(node2, "b")
|
||||
val _: ORSet[String] = s1
|
||||
val ORSet(elements1) = s1 // `unapply[A](s: ORSet[A])` is used here
|
||||
val elements1 = s1 match { // `unapply[A](s: ORSet[A])` is used here
|
||||
case ORSet(elements1) => elements1
|
||||
case _ => fail()
|
||||
}
|
||||
val elements2: Set[String] = elements1
|
||||
elements2 should be(Set("a", "b"))
|
||||
|
||||
Changed(ORSetKey[String]("key"))(s1) match {
|
||||
case c @ Changed(ORSetKey("key")) =>
|
||||
val _: ORSet[String] = c.dataValue
|
||||
val ORSet(elements3) = c.dataValue
|
||||
val elements3 = c.dataValue match {
|
||||
case ORSet(elements3) => elements3
|
||||
case _ => fail()
|
||||
}
|
||||
val elements4: Set[String] = elements3
|
||||
elements4 should be(Set("a", "b"))
|
||||
case changed =>
|
||||
|
|
@ -619,10 +628,15 @@ class ORSetSpec extends AnyWordSpec with Matchers {
|
|||
val msg: Any = Changed(ORSetKey[String]("key"))(s1)
|
||||
msg match {
|
||||
case c @ Changed(ORSetKey("key")) =>
|
||||
val ORSet(elements3) = c.dataValue // `unapply(a: ReplicatedData)` is used here
|
||||
// FIXME we need to look into this for Scala 2.13.5
|
||||
// val ORSet(elements3) = c.dataValue // `unapply(a: ReplicatedData)` is used here
|
||||
// if `unapply(a: ReplicatedData)` isn't defined the next line doesn't compile:
|
||||
// type mismatch; found : scala.collection.immutable.Set[A] where type A required: Set[Any] Note: A <: Any,
|
||||
// but trait Set is invariant in type A. You may wish to investigate a wildcard type such as _ <: Any. (SLS 3.2.10)
|
||||
val elements3 = c.dataValue match {
|
||||
case ORSet(elements3) => elements3
|
||||
case _ => fail()
|
||||
}
|
||||
val elements4: Set[Any] = elements3
|
||||
elements4 should be(Set("a", "b"))
|
||||
case changed =>
|
||||
|
|
|
|||
|
|
@ -73,13 +73,19 @@ class PNCounterMapSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"have unapply extractor" in {
|
||||
val m1 = PNCounterMap.empty.increment(node1, "a", 1).increment(node2, "b", 2)
|
||||
val PNCounterMap(entries1) = m1
|
||||
val entries1 = m1 match {
|
||||
case PNCounterMap(entries1) => entries1
|
||||
case _ => throw new RuntimeException()
|
||||
}
|
||||
val entries2: Map[String, BigInt] = entries1
|
||||
entries2 should be(Map("a" -> 1L, "b" -> 2L))
|
||||
|
||||
Changed(PNCounterMapKey[String]("key"))(m1) match {
|
||||
case c @ Changed(PNCounterMapKey("key")) =>
|
||||
val PNCounterMap(entries3) = c.dataValue
|
||||
val entries3 = c.dataValue match {
|
||||
case PNCounterMap(entries3) => entries3
|
||||
case _ => throw new RuntimeException()
|
||||
}
|
||||
val entries4: Map[String, BigInt] = entries3
|
||||
entries4 should be(Map("a" -> 1L, "b" -> 2L))
|
||||
case _ =>
|
||||
|
|
|
|||
|
|
@ -191,13 +191,13 @@ class PNCounterSpec extends AnyWordSpec with Matchers {
|
|||
|
||||
"have unapply extractor" in {
|
||||
val c1 = PNCounter.empty.increment(node1).increment(node1).decrement(node2)
|
||||
val PNCounter(value1) = c1
|
||||
val value1 = c1.value
|
||||
val value2: BigInt = value1
|
||||
value2 should be(1L)
|
||||
|
||||
Changed(PNCounterKey("key"))(c1) match {
|
||||
case c @ Changed(PNCounterKey("key")) =>
|
||||
val PNCounter(value3) = c.dataValue
|
||||
val value3 = c.dataValue.value
|
||||
val value4: BigInt = value3
|
||||
value4 should be(1L)
|
||||
case changed =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue