!cdd #17770 Use self recursive type in AbstractReplicatedData (Java API)
* complete the TwoPhaseSet java sample with serialization
This commit is contained in:
parent
49e6e7f38c
commit
da07a2e68e
9 changed files with 315 additions and 26 deletions
|
|
@ -33,6 +33,17 @@ object DistributedDataDocSpec {
|
|||
}
|
||||
}
|
||||
#//#serializer-config
|
||||
|
||||
#//#japi-serializer-config
|
||||
akka.actor {
|
||||
serializers {
|
||||
twophaseset = "docs.ddata.japi.protobuf.TwoPhaseSetSerializer"
|
||||
}
|
||||
serialization-bindings {
|
||||
"docs.ddata.japi.TwoPhaseSet" = twophaseset
|
||||
}
|
||||
}
|
||||
#//#japi-serializer-config
|
||||
"""
|
||||
|
||||
//#data-bot
|
||||
|
|
@ -391,4 +402,14 @@ class DistributedDataDocSpec extends AkkaSpec(DistributedDataDocSpec.config) {
|
|||
s1 should be(s1)
|
||||
}
|
||||
|
||||
"test japi.TwoPhaseSetSerializer" in {
|
||||
import scala.collection.JavaConverters._
|
||||
val s1 = japi.TwoPhaseSet.create().add("a").add("b").add("c").remove("b")
|
||||
s1.getElements.asScala should be(Set("a", "c"))
|
||||
val serializer = SerializationExtension(system).findSerializerFor(s1)
|
||||
val blob = serializer.toBinary(s1)
|
||||
val s2 = serializer.fromBinary(blob, None)
|
||||
s1 should be(s1)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ case class TwoPhaseSet(
|
|||
|
||||
override def merge(that: TwoPhaseSet): TwoPhaseSet =
|
||||
copy(
|
||||
adds = GSet(this.adds.elements ++ that.adds.elements),
|
||||
removals = GSet(this.removals.elements ++ that.removals.elements))
|
||||
adds = this.adds.merge(that.adds),
|
||||
removals = this.removals.merge(that.removals))
|
||||
}
|
||||
//#twophaseset
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue