!per #3681 Performance and consistency improvements

- batch-write of persistent messages (user API)
- batch-write of events (in EventsourcedProcessor)
- command processing in EventsourcedProcessor by unstashing messages one-by-one from the internal stash
   * fixes performance issues that come up with unstashAll
- commands are not looped through journal actor but processed directly
- initial performance tests
  * command sourcing
  * event sourcing
  * event sourcing with user stash operations
- suppress stack traces in tests
This commit is contained in:
Martin Krasser 2013-10-27 08:01:14 +01:00
parent 8eeaadfee0
commit 1da3369643
29 changed files with 1324 additions and 76 deletions

View file

@ -4,12 +4,12 @@
package akka.persistence.journal
import scala.collection.immutable
import scala.util._
import akka.actor.Actor
import akka.pattern.{ pipe, PromiseActorRef }
import akka.persistence._
import akka.serialization.Serialization
/**
* Abstract journal, optimized for synchronous writes.
@ -23,11 +23,18 @@ trait SyncWriteJournal extends Actor with AsyncReplay {
final def receive = {
case Write(persistent, processor) {
val sdr = if (sender.isInstanceOf[PromiseActorRef]) context.system.deadLetters else sender
Try(write(persistent.copy(sender = sdr, resolved = false, confirmTarget = null, confirmMessage = null))) match {
Try(write(persistent.prepareWrite(sdr))) match {
case Success(_) processor forward WriteSuccess(persistent)
case Failure(e) processor forward WriteFailure(persistent, e); throw e
}
}
case WriteBatch(persistentBatch, processor) {
val sdr = if (sender.isInstanceOf[PromiseActorRef]) context.system.deadLetters else sender
Try(writeBatch(persistentBatch.map(_.prepareWrite(sdr)))) match {
case Success(_) persistentBatch.foreach(processor forward WriteSuccess(_))
case Failure(e) persistentBatch.foreach(processor forward WriteFailure(_, e)); throw e
}
}
case Replay(fromSequenceNr, toSequenceNr, processorId, processor) {
replayAsync(processorId, fromSequenceNr, toSequenceNr) { p
if (!p.deleted) processor.tell(Replayed(p), p.sender)
@ -57,6 +64,14 @@ trait SyncWriteJournal extends Actor with AsyncReplay {
*/
def write(persistent: PersistentImpl): Unit
/**
* Plugin API.
*
* Synchronously writes a batch of persistent messages to the journal. The batch write
* must be atomic i.e. either all persistent messages in the batch are written or none.
*/
def writeBatch(persistentBatch: immutable.Seq[PersistentImpl]): Unit
/**
* Plugin API.
*