pre/postRestart now takes a Throwable as arg
This commit is contained in:
parent
b4ea27d657
commit
1f3a38228b
6 changed files with 22 additions and 22 deletions
|
|
@ -558,8 +558,8 @@ object AMQP {
|
|||
}
|
||||
}
|
||||
|
||||
override def preRestart(reason: AnyRef) = disconnect
|
||||
override def preRestart(reason: Throwable) = disconnect
|
||||
|
||||
override def postRestart(reason: AnyRef) = reconnect(initReconnectDelay)
|
||||
override def postRestart(reason: Throwable) = reconnect(initReconnectDelay)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -413,13 +413,13 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Op
|
|||
throw new IllegalStateException("Unexpected message [" + unexpected + "] sent to [" + this + "]")
|
||||
}
|
||||
|
||||
override protected def preRestart(reason: AnyRef) {
|
||||
override protected def preRestart(reason: Throwable) {
|
||||
try {
|
||||
if (preRestart.isDefined) preRestart.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*)
|
||||
} catch { case e: InvocationTargetException => throw e.getCause }
|
||||
}
|
||||
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
try {
|
||||
if (postRestart.isDefined) postRestart.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*)
|
||||
} catch { case e: InvocationTargetException => throw e.getCause }
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ abstract class RemoteActor(hostname: String, port: Int) extends Actor {
|
|||
|
||||
@serializable sealed trait LifeCycleMessage
|
||||
case class HotSwap(code: Option[PartialFunction[Any, Unit]]) extends LifeCycleMessage
|
||||
case class Restart(reason: AnyRef) extends LifeCycleMessage
|
||||
case class Restart(reason: Throwable) extends LifeCycleMessage
|
||||
case class Exit(dead: Actor, killer: Throwable) extends LifeCycleMessage
|
||||
case object Kill extends LifeCycleMessage
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ trait Actor extends TransactionManagement {
|
|||
* Mandatory callback method that is called during restart and reinitialization after a server crash.
|
||||
* To be implemented by subclassing actor.
|
||||
*/
|
||||
protected def preRestart(reason: AnyRef) = {}
|
||||
protected def preRestart(reason: Throwable) = {}
|
||||
|
||||
/**
|
||||
* User overridable callback/setting.
|
||||
|
|
@ -397,7 +397,7 @@ trait Actor extends TransactionManagement {
|
|||
* Mandatory callback method that is called during restart and reinitialization after a server crash.
|
||||
* To be implemented by subclassing actor.
|
||||
*/
|
||||
protected def postRestart(reason: AnyRef) = {}
|
||||
protected def postRestart(reason: Throwable) = {}
|
||||
|
||||
/**
|
||||
* User overridable callback/setting.
|
||||
|
|
@ -981,7 +981,7 @@ trait Actor extends TransactionManagement {
|
|||
}
|
||||
}
|
||||
|
||||
private[this] def restartLinkedActors(reason: AnyRef) = {
|
||||
private[this] def restartLinkedActors(reason: Throwable) = {
|
||||
getLinkedActors.toArray.toList.asInstanceOf[List[Actor]].foreach {
|
||||
actor =>
|
||||
if (actor.lifeCycle.isEmpty) actor.lifeCycle = Some(LifeCycle(Permanent))
|
||||
|
|
@ -1000,7 +1000,7 @@ trait Actor extends TransactionManagement {
|
|||
}
|
||||
}
|
||||
|
||||
private[Actor] def restart(reason: AnyRef) = synchronized {
|
||||
private[Actor] def restart(reason: Throwable) = synchronized {
|
||||
preRestart(reason)
|
||||
Actor.log.info("Restarting actor [%s] configured as PERMANENT.", id)
|
||||
postRestart(reason)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ object Log {
|
|||
throw new RuntimeException("DIE")
|
||||
}
|
||||
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
Log.messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
Log.messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,8 +48,8 @@ object Log {
|
|||
throw new RuntimeException("DIE")
|
||||
}
|
||||
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
Log.messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
Log.messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +63,8 @@ object Log {
|
|||
throw new RuntimeException("DIE")
|
||||
}
|
||||
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
Log.messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
Log.messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -556,8 +556,8 @@ class SupervisorTest extends JUnitSuite {
|
|||
case Die =>
|
||||
throw new RuntimeException("DIE")
|
||||
}
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -569,8 +569,8 @@ class SupervisorTest extends JUnitSuite {
|
|||
case Die =>
|
||||
throw new RuntimeException("DIE")
|
||||
}
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -583,8 +583,8 @@ class SupervisorTest extends JUnitSuite {
|
|||
throw new RuntimeException("DIE")
|
||||
}
|
||||
|
||||
override protected def postRestart(reason: AnyRef) {
|
||||
messageLog += reason.asInstanceOf[Exception].getMessage
|
||||
override protected def postRestart(reason: Throwable) {
|
||||
messageLog += reason.getMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Boot {
|
|||
|
||||
|
||||
val supervisor = factory.newInstance
|
||||
supervisor.start
|
||||
supervisor.start
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue