introducing: MainBus feat. LoggingBus
most tests passing, everything compiling, but docs not updated and nasty
thread-leak preventing me from running the whole test-suite (which is
the reason for this commit: I want to chase down that one first).
- the app.mainbus is classified by Class[_] (currently lookup, will
possibly change to sub-class-aware) and accepts AnyRef messages
- LoggingBus handles akka.event-handlers from config specially:
+ start them as system services, supervised by SystemGuardian
+ keep their subscriptions in sync when logLevel_= is called
+ send them InitializeLogger(bus) message before subscribing them (so
they can register for extras like Mute/UnMute)
- two-phased start-up: first phase with actor-less stdout logging, then
subscription of config loggers, then remove stdout logger (logLevels
configurable separately)
- MainBusReaper watches registered receivers and unsubscribes them upon
death (started in phase 2)
- logger factory on Logging object, needs app/bus and log source;
default instance in app.log
This commit is contained in:
parent
c8b17b9e92
commit
f46c6dc533
63 changed files with 749 additions and 643 deletions
|
|
@ -5,7 +5,7 @@
|
|||
package akka.tutorial.second
|
||||
|
||||
import akka.actor.Actor._
|
||||
import akka.event.EventHandler
|
||||
import akka.event.Logging
|
||||
import System.{ currentTimeMillis ⇒ now }
|
||||
import akka.routing.Routing.Broadcast
|
||||
import akka.actor.{ Timeout, Channel, Actor, PoisonPill }
|
||||
|
|
@ -15,6 +15,7 @@ import akka.AkkaApplication
|
|||
object Pi extends App {
|
||||
|
||||
val app = AkkaApplication()
|
||||
val log = Logging(app, this)
|
||||
|
||||
calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
|
||||
|
||||
|
|
@ -110,9 +111,9 @@ object Pi extends App {
|
|||
master.?(Calculate, Timeout(60000)).
|
||||
await.resultOrException match { //wait for the result, with a 60 seconds timeout
|
||||
case Some(pi) ⇒
|
||||
app.eventHandler.info(this, "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis".format(pi, (now - start)))
|
||||
log.info("\n\tPi estimate: \t\t{}\n\tCalculation time: \t{} millis", pi, now - start)
|
||||
case None ⇒
|
||||
app.eventHandler.error(this, "Pi calculation did not complete within the timeout.")
|
||||
log.error("Pi calculation did not complete within the timeout.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue