format source with scalafmt
This commit is contained in:
parent
0f40491d42
commit
ce404e4f53
1669 changed files with 43208 additions and 35404 deletions
|
|
@ -7,12 +7,12 @@ package akka.persistence.journal.leveldb
|
|||
import akka.actor._
|
||||
import akka.persistence._
|
||||
import akka.persistence.journal.PersistencePluginProxy
|
||||
import akka.testkit.{ TestProbe, AkkaSpec }
|
||||
import akka.testkit.{ AkkaSpec, TestProbe }
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
||||
object PersistencePluginProxySpec {
|
||||
lazy val config = ConfigFactory.parseString(
|
||||
"""
|
||||
lazy val config =
|
||||
ConfigFactory.parseString("""
|
||||
akka {
|
||||
actor {
|
||||
provider = remote
|
||||
|
|
@ -42,8 +42,8 @@ object PersistencePluginProxySpec {
|
|||
}
|
||||
""")
|
||||
|
||||
lazy val startTargetConfig = ConfigFactory.parseString(
|
||||
"""
|
||||
lazy val startTargetConfig =
|
||||
ConfigFactory.parseString("""
|
||||
|akka.extensions = ["akka.persistence.journal.PersistencePluginProxyExtension"]
|
||||
|akka.persistence {
|
||||
| journal.proxy.start-target-journal = on
|
||||
|
|
@ -51,12 +51,18 @@ object PersistencePluginProxySpec {
|
|||
|}
|
||||
""".stripMargin)
|
||||
|
||||
def targetAddressConfig(system: ActorSystem) = ConfigFactory.parseString(
|
||||
s"""
|
||||
def targetAddressConfig(system: ActorSystem) =
|
||||
ConfigFactory.parseString(s"""
|
||||
|akka.extensions = ["akka.persistence.Persistence"]
|
||||
|akka.persistence.journal.auto-start-journals = [""]
|
||||
|akka.persistence.journal.proxy.target-journal-address = "${system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress}"
|
||||
|akka.persistence.snapshot-store.proxy.target-snapshot-store-address = "${system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress}"
|
||||
|akka.persistence.journal.proxy.target-journal-address = "${system
|
||||
.asInstanceOf[ExtendedActorSystem]
|
||||
.provider
|
||||
.getDefaultAddress}"
|
||||
|akka.persistence.snapshot-store.proxy.target-snapshot-store-address = "${system
|
||||
.asInstanceOf[ExtendedActorSystem]
|
||||
.provider
|
||||
.getDefaultAddress}"
|
||||
""".stripMargin)
|
||||
|
||||
class ExamplePersistentActor(probe: ActorRef, name: String) extends NamedPersistentActor(name) {
|
||||
|
|
@ -77,17 +83,19 @@ object PersistencePluginProxySpec {
|
|||
val p = context.actorOf(Props(classOf[ExamplePersistentActor], probe, context.system.name))
|
||||
|
||||
def receive = {
|
||||
case m => p forward m
|
||||
case m => p.forward(m)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class PersistencePluginProxySpec extends AkkaSpec(PersistencePluginProxySpec.startTargetConfig withFallback PersistencePluginProxySpec.config) with Cleanup {
|
||||
class PersistencePluginProxySpec
|
||||
extends AkkaSpec(PersistencePluginProxySpec.startTargetConfig.withFallback(PersistencePluginProxySpec.config))
|
||||
with Cleanup {
|
||||
import PersistencePluginProxySpec._
|
||||
|
||||
val systemA = ActorSystem("SysA", config)
|
||||
val systemB = ActorSystem("SysB", targetAddressConfig(system) withFallback PersistencePluginProxySpec.config)
|
||||
val systemB = ActorSystem("SysB", targetAddressConfig(system).withFallback(PersistencePluginProxySpec.config))
|
||||
|
||||
override protected def afterTermination(): Unit = {
|
||||
shutdown(systemA)
|
||||
|
|
@ -95,7 +103,7 @@ class PersistencePluginProxySpec extends AkkaSpec(PersistencePluginProxySpec.sta
|
|||
super.afterTermination()
|
||||
}
|
||||
|
||||
"A persistence proxy" can {
|
||||
"A persistence proxy".can {
|
||||
"be shared by multiple actor systems" in {
|
||||
|
||||
val address = system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package akka.persistence.journal.leveldb
|
|||
|
||||
import akka.actor._
|
||||
import akka.persistence._
|
||||
import akka.testkit.{ TestProbe, AkkaSpec }
|
||||
import akka.testkit.{ AkkaSpec, TestProbe }
|
||||
|
||||
object SharedLeveldbJournalSpec {
|
||||
val config =
|
||||
|
|
@ -45,9 +45,10 @@ object SharedLeveldbJournalSpec {
|
|||
case payload => probe ! payload
|
||||
}
|
||||
override def receiveCommand = {
|
||||
case payload => persist(payload) { _ =>
|
||||
probe ! payload
|
||||
}
|
||||
case payload =>
|
||||
persist(payload) { _ =>
|
||||
probe ! payload
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ object SharedLeveldbJournalSpec {
|
|||
|
||||
def receive = {
|
||||
case ActorIdentity(1, Some(store)) => SharedLeveldbJournal.setStore(store, context.system)
|
||||
case m => p forward m
|
||||
case m => p.forward(m)
|
||||
}
|
||||
|
||||
override def preStart(): Unit =
|
||||
|
|
@ -77,7 +78,7 @@ class SharedLeveldbJournalSpec extends AkkaSpec(SharedLeveldbJournalSpec.config)
|
|||
super.afterTermination()
|
||||
}
|
||||
|
||||
"A LevelDB store" can {
|
||||
"A LevelDB store".can {
|
||||
"be shared by multiple actor systems" in {
|
||||
|
||||
val probeA = new TestProbe(systemA)
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ import akka.serialization._
|
|||
import akka.testkit._
|
||||
import akka.util.ByteString.UTF_8
|
||||
import com.typesafe.config._
|
||||
import org.apache.commons.codec.binary.Hex.{ encodeHex, decodeHex }
|
||||
import org.apache.commons.codec.binary.Hex.{ decodeHex, encodeHex }
|
||||
import scala.concurrent.Await
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
object SerializerSpecConfigs {
|
||||
val customSerializers = ConfigFactory.parseString(
|
||||
"""
|
||||
val customSerializers =
|
||||
ConfigFactory.parseString("""
|
||||
akka.actor {
|
||||
serializers {
|
||||
my-payload = "akka.persistence.serialization.MyPayloadSerializer"
|
||||
|
|
@ -40,8 +40,7 @@ object SerializerSpecConfigs {
|
|||
}
|
||||
""")
|
||||
|
||||
val remote = ConfigFactory.parseString(
|
||||
"""
|
||||
val remote = ConfigFactory.parseString("""
|
||||
akka {
|
||||
actor {
|
||||
provider = remote
|
||||
|
|
@ -101,11 +100,11 @@ class SnapshotSerializerPersistenceSpec extends AkkaSpec(customSerializers) {
|
|||
// println(s"encoded snapshot: " + String.valueOf(encodeHex(serializer.toBinary(snapshot))))
|
||||
val oldSnapshot = // 32 bytes per line
|
||||
"a8000000aced00057372002d616b6b612e70657273697374656e63652e736572" +
|
||||
"69616c697a6174696f6e2e536e617073686f7448656164657200000000000000" +
|
||||
"0102000249000c73657269616c697a657249644c00086d616e69666573747400" +
|
||||
"0e4c7363616c612f4f7074696f6e3b7870000000047372000b7363616c612e4e" +
|
||||
"6f6e6524465024f653ca94ac0200007872000c7363616c612e4f7074696f6ee3" +
|
||||
"6024a8328a45e90200007870616263"
|
||||
"69616c697a6174696f6e2e536e617073686f7448656164657200000000000000" +
|
||||
"0102000249000c73657269616c697a657249644c00086d616e69666573747400" +
|
||||
"0e4c7363616c612f4f7074696f6e3b7870000000047372000b7363616c612e4e" +
|
||||
"6f6e6524465024f653ca94ac0200007872000c7363616c612e4f7074696f6ee3" +
|
||||
"6024a8328a45e90200007870616263"
|
||||
|
||||
val bytes = decodeHex(oldSnapshot.toCharArray)
|
||||
val cause = intercept[NotSerializableException] {
|
||||
|
|
@ -125,11 +124,11 @@ class SnapshotSerializerPersistenceSpec extends AkkaSpec(customSerializers) {
|
|||
// println(s"encoded snapshot: " + String.valueOf(encodeHex(serializer.toBinary(snapshot))))
|
||||
val oldSnapshot = // 32 bytes per line
|
||||
"a8000000aced00057372002d616b6b612e70657273697374656e63652e736572" +
|
||||
"69616c697a6174696f6e2e536e617073686f7448656164657200000000000000" +
|
||||
"0102000249000c73657269616c697a657249644c00086d616e69666573747400" +
|
||||
"0e4c7363616c612f4f7074696f6e3b7870000000047372000b7363616c612e4e" +
|
||||
"6f6e6524465024f653ca94ac0200007872000c7363616c612e4f7074696f6efe" +
|
||||
"6937fddb0e66740200007870616263"
|
||||
"69616c697a6174696f6e2e536e617073686f7448656164657200000000000000" +
|
||||
"0102000249000c73657269616c697a657249644c00086d616e69666573747400" +
|
||||
"0e4c7363616c612f4f7074696f6e3b7870000000047372000b7363616c612e4e" +
|
||||
"6f6e6524465024f653ca94ac0200007872000c7363616c612e4f7074696f6efe" +
|
||||
"6937fddb0e66740200007870616263"
|
||||
|
||||
val bytes = decodeHex(oldSnapshot.toCharArray)
|
||||
val cause = intercept[NotSerializableException] {
|
||||
|
|
@ -222,12 +221,12 @@ class MessageSerializerPersistenceSpec extends AkkaSpec(customSerializers) {
|
|||
//
|
||||
val oldData =
|
||||
"0a3e08c7da04120d4f6c645061796c6f61642841291a2" +
|
||||
"9616b6b612e70657273697374656e63652e7365726961" +
|
||||
"6c697a6174696f6e2e4f6c645061796c6f6164100d1a0" +
|
||||
"2703120015a45616b6b613a2f2f4d6573736167655365" +
|
||||
"7269616c697a657250657273697374656e63655370656" +
|
||||
"32f73797374656d2f746573744163746f722d31233133" +
|
||||
"3137373931343033"
|
||||
"9616b6b612e70657273697374656e63652e7365726961" +
|
||||
"6c697a6174696f6e2e4f6c645061796c6f6164100d1a0" +
|
||||
"2703120015a45616b6b613a2f2f4d6573736167655365" +
|
||||
"7269616c697a657250657273697374656e63655370656" +
|
||||
"32f73797374656d2f746573744163746f722d31233133" +
|
||||
"3137373931343033"
|
||||
|
||||
// now the system is updated, OldPayload is replaced by MyPayload, and the
|
||||
// OldPayloadSerializer is adjusted to migrate OldPayload
|
||||
|
|
@ -247,12 +246,12 @@ class MessageSerializerPersistenceSpec extends AkkaSpec(customSerializers) {
|
|||
// println(s"encoded persistent: " + String.valueOf(encodeHex(serializer.toBinary(persistent))))
|
||||
val oldData =
|
||||
"0a3208c3da0412022e611a28616b6b612e70657273697374656e63652e73657269616c697a" +
|
||||
"6174696f6e2e4d795061796c6f6164100d1a027031200130033a0263313a02633240014a0c" +
|
||||
"0a02703212026332180e20005244616b6b613a2f2f4d65737361676553657269616c697a65" +
|
||||
"7250657273697374656e6365537065632f73797374656d2f746573744163746f7232232d34" +
|
||||
"34373233313933375a44616b6b613a2f2f4d65737361676553657269616c697a6572506572" +
|
||||
"73697374656e6365537065632f73797374656d2f746573744163746f7232232d3434373233" +
|
||||
"31393337"
|
||||
"6174696f6e2e4d795061796c6f6164100d1a027031200130033a0263313a02633240014a0c" +
|
||||
"0a02703212026332180e20005244616b6b613a2f2f4d65737361676553657269616c697a65" +
|
||||
"7250657273697374656e6365537065632f73797374656d2f746573744163746f7232232d34" +
|
||||
"34373233313933375a44616b6b613a2f2f4d65737361676553657269616c697a6572506572" +
|
||||
"73697374656e6365537065632f73797374656d2f746573744163746f7232232d3434373233" +
|
||||
"31393337"
|
||||
|
||||
val bytes = decodeHex(oldData.toCharArray)
|
||||
val expected = PersistentRepr(MyPayload(".a."), 13, "p1", "", true, Actor.noSender)
|
||||
|
|
@ -277,10 +276,9 @@ class MessageSerializerPersistenceSpec extends AkkaSpec(customSerializers) {
|
|||
}
|
||||
|
||||
"handle a few unconfirmed" in {
|
||||
val unconfirmed = Vector(
|
||||
UnconfirmedDelivery(deliveryId = 1, destination = testActor.path, "a"),
|
||||
UnconfirmedDelivery(deliveryId = 2, destination = testActor.path, "b"),
|
||||
UnconfirmedDelivery(deliveryId = 3, destination = testActor.path, 42))
|
||||
val unconfirmed = Vector(UnconfirmedDelivery(deliveryId = 1, destination = testActor.path, "a"),
|
||||
UnconfirmedDelivery(deliveryId = 2, destination = testActor.path, "b"),
|
||||
UnconfirmedDelivery(deliveryId = 3, destination = testActor.path, 42))
|
||||
val snap = AtLeastOnceDeliverySnapshot(17, unconfirmed)
|
||||
val serializer = serialization.findSerializerFor(snap)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue