remove Actor.preRestart(cause: Throwable)
- adapt all internal uses (all tests green) - start migration guide for 2.0 with this change
This commit is contained in:
parent
00b9166b57
commit
5de2ca7aa5
16 changed files with 50 additions and 44 deletions
|
|
@ -334,7 +334,7 @@ class ActorRefSpec extends WordSpec with MustMatchers {
|
|||
val ref = Actor.actorOf(
|
||||
new Actor {
|
||||
def receive = { case _ ⇒ }
|
||||
override def preRestart(reason: Throwable) = latch.countDown()
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) = latch.countDown()
|
||||
override def postRestart(reason: Throwable) = latch.countDown()
|
||||
}).start()
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ object ActorRestartSpec {
|
|||
case "get" ⇒ self reply xx
|
||||
}
|
||||
override def preStart { testActor ! (("preStart", gen)) }
|
||||
override def preRestart(cause: Throwable) { testActor ! (("preRestart", gen)) }
|
||||
override def preRestart(cause: Throwable, msg: Option[Any]) { testActor ! (("preRestart", msg, gen)) }
|
||||
override def postRestart(cause: Throwable) { testActor ! (("postRestart", gen)) }
|
||||
override def freshInstance() = {
|
||||
restart match {
|
||||
|
|
@ -94,7 +94,7 @@ class ActorRestartSpec extends WordSpec with MustMatchers with TestKit with Befo
|
|||
supervisor link actor
|
||||
actor ! Kill
|
||||
within(1 second) {
|
||||
expectMsg(("preRestart", 1))
|
||||
expectMsg(("preRestart", Some(Kill), 1))
|
||||
expectMsg(("preStart", 2))
|
||||
expectMsg(("postRestart", 2))
|
||||
expectNoMsg
|
||||
|
|
@ -109,7 +109,7 @@ class ActorRestartSpec extends WordSpec with MustMatchers with TestKit with Befo
|
|||
actor ! Nested
|
||||
actor ! Kill
|
||||
within(1 second) {
|
||||
expectMsg(("preRestart", 1))
|
||||
expectMsg(("preRestart", Some(Kill), 1))
|
||||
val (tActor, tRef) = expectMsgType[(Actor, TestActorRef[Actor])]
|
||||
tRef.underlyingActor must be(tActor)
|
||||
expectMsg((tActor, tRef))
|
||||
|
|
@ -129,7 +129,7 @@ class ActorRestartSpec extends WordSpec with MustMatchers with TestKit with Befo
|
|||
actor ! Handover
|
||||
actor ! Kill
|
||||
within(1 second) {
|
||||
expectMsg(("preRestart", 1))
|
||||
expectMsg(("preRestart", Some(Kill), 1))
|
||||
expectMsg(("preStart", 2))
|
||||
expectMsg(("postRestart", 2))
|
||||
expectNoMsg
|
||||
|
|
@ -147,7 +147,7 @@ class ActorRestartSpec extends WordSpec with MustMatchers with TestKit with Befo
|
|||
actor ! Fail
|
||||
actor ! Kill
|
||||
within(1 second) {
|
||||
expectMsg(("preRestart", 1))
|
||||
expectMsg(("preRestart", Some(Kill), 1))
|
||||
expectMsg(("preStart", 2))
|
||||
expectMsg(("postRestart", 2))
|
||||
expectNoMsg
|
||||
|
|
@ -156,22 +156,6 @@ class ActorRestartSpec extends WordSpec with MustMatchers with TestKit with Befo
|
|||
expectMsg(1 second, 0)
|
||||
}
|
||||
|
||||
"call preRestart(cause, currentMessage) if defined" in {
|
||||
val actor = newActor(new Actor {
|
||||
def receive = { case _ ⇒ }
|
||||
override def preRestart(cause: Throwable, currentMessage: Option[Any]) {
|
||||
testActor ! (("preRestart", currentMessage))
|
||||
}
|
||||
})
|
||||
val supervisor = newActor(new Supervisor)
|
||||
supervisor link actor
|
||||
actor ! Kill
|
||||
within(1 second) {
|
||||
expectMsg(("preRestart", Some(Kill)))
|
||||
expectNoMsg
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ object FSMTransitionSpec {
|
|||
case Ev("reply") ⇒ stay replying "reply"
|
||||
}
|
||||
initialize
|
||||
override def preRestart(reason: Throwable) { target ! "restarted" }
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) { target ! "restarted" }
|
||||
}
|
||||
|
||||
class Forwarder(target: ActorRef) extends Actor {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class SupervisorTreeSpec extends WordSpec with MustMatchers {
|
|||
case Die ⇒ throw new Exception(self.address + " is dying...")
|
||||
}
|
||||
|
||||
override def preRestart(reason: Throwable) {
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) {
|
||||
log += self.address
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ object Ticket669Spec {
|
|||
case msg ⇒ throw new Exception("test")
|
||||
}
|
||||
|
||||
override def preRestart(reason: scala.Throwable) {
|
||||
override def preRestart(reason: scala.Throwable, msg: Option[Any]) {
|
||||
self.reply_?("failure1")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -659,19 +659,9 @@ trait Actor {
|
|||
* User overridable callback.
|
||||
* <p/>
|
||||
* Is called on a crashed Actor right BEFORE it is restarted to allow clean
|
||||
* up of resources before Actor is terminated. Override either the variant
|
||||
* with or without the currentMessage argument.
|
||||
* up of resources before Actor is terminated.
|
||||
*/
|
||||
def preRestart(reason: Throwable) {}
|
||||
|
||||
/**
|
||||
* User overridable callback.
|
||||
* <p/>
|
||||
* Is called on a crashed Actor right BEFORE it is restarted to allow clean
|
||||
* up of resources before Actor is terminated. Override either the variant
|
||||
* with or without the currentMessage argument.
|
||||
*/
|
||||
def preRestart(reason: Throwable, message: Option[Any]) { preRestart(reason) }
|
||||
def preRestart(reason: Throwable, message: Option[Any]) {}
|
||||
|
||||
/**
|
||||
* User overridable callback.
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ abstract class UntypedActor extends Actor {
|
|||
* <p/>
|
||||
* Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.
|
||||
*/
|
||||
override def preRestart(reason: Throwable) {}
|
||||
override def preRestart(reason: Throwable, lastMessage: Option[Any]) {}
|
||||
|
||||
/**
|
||||
* User overridable callback.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ trait ProducerSupport { this: Actor ⇒
|
|||
* Default implementation of <code>Actor.preRestart</code> for freeing resources needed
|
||||
* to actually send messages to <code>endpointUri</code>.
|
||||
*/
|
||||
override def preRestart(reason: Throwable) {
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) {
|
||||
try { preRestartProducer(reason) } finally { processor.stop }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ object ConsumerScalaTest {
|
|||
case "succeed" ⇒ self.reply("ok")
|
||||
}
|
||||
|
||||
override def preRestart(reason: scala.Throwable) {
|
||||
override def preRestart(reason: scala.Throwable, msg: Option[Any]) {
|
||||
self.reply_?("pr")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1606,7 +1606,7 @@ class RemoteClusterDaemon(cluster: ClusterNode) extends Actor {
|
|||
|
||||
self.dispatcher = Dispatchers.newPinnedDispatcher(self)
|
||||
|
||||
override def preRestart(reason: Throwable) {
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) {
|
||||
EventHandler.debug(this, "RemoteClusterDaemon failed due to [%s] restarting...".format(reason))
|
||||
}
|
||||
|
||||
|
|
|
|||
6
akka-docs/project/migration-guide-1.1.x-1.2.x.rst
Normal file
6
akka-docs/project/migration-guide-1.1.x-1.2.x.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.. _migration-1.2:
|
||||
|
||||
################################
|
||||
Migration Guide 1.1.x to 1.2.x
|
||||
################################
|
||||
|
||||
20
akka-docs/project/migration-guide-1.2.x-2.0.x.rst
Normal file
20
akka-docs/project/migration-guide-1.2.x-2.0.x.rst
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
.. _migration-2.0:
|
||||
|
||||
################################
|
||||
Migration Guide 1.2.x to 2.0.x
|
||||
################################
|
||||
|
||||
Actors
|
||||
======
|
||||
|
||||
The 2.0 release contains several new features which require source-level
|
||||
changes in client code. This API cleanup is planned to be the last one for a
|
||||
significant amount of time.
|
||||
|
||||
Lifecycle Callbacks
|
||||
-------------------
|
||||
|
||||
The :meth:`preRestart(cause: Throwable)` method has been replaced by
|
||||
:meth:`preRestart(cause: Throwable, lastMessage: Any)`, hence you must insert
|
||||
the second argument in all overriding methods. The good news is that any missed
|
||||
actor will not compile without error.
|
||||
|
|
@ -6,6 +6,8 @@ Migration Guides
|
|||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
migration-guide-1.2.x-2.0.x
|
||||
migration-guide-1.1.x-1.2.x
|
||||
migration-guide-1.0.x-1.1.x
|
||||
migration-guide-0.10.x-1.0.x
|
||||
migration-guide-0.9.x-0.10.x
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package akka.spring;
|
|||
|
||||
import akka.actor.*;
|
||||
|
||||
import scala.Option;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class RemoteTypedActorOneImpl extends TypedActor implements RemoteTypedActorOne {
|
||||
|
|
@ -22,7 +24,7 @@ public class RemoteTypedActorOneImpl extends TypedActor implements RemoteTypedAc
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preRestart(Throwable e) {
|
||||
public void preRestart(Throwable e, Option<Object> msg) {
|
||||
try { RemoteTypedActorLog.messageLog().put(e.getMessage()); } catch(Exception ex) {}
|
||||
latch.countDown();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package akka.spring;
|
|||
|
||||
import akka.actor.*;
|
||||
|
||||
import scala.Option;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class RemoteTypedActorTwoImpl extends TypedActor implements RemoteTypedActorTwo {
|
||||
|
|
@ -22,7 +24,7 @@ public class RemoteTypedActorTwoImpl extends TypedActor implements RemoteTypedAc
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preRestart(Throwable e) {
|
||||
public void preRestart(Throwable e, Option<Object> msg) {
|
||||
try { RemoteTypedActorLog.messageLog().put(e.getMessage()); } catch(Exception ex) {}
|
||||
latch.countDown();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
self.faultHandler = OneForOneStrategy(List(classOf[Throwable]), Some(2), Some(1000))
|
||||
val ref = TestActorRef(new TActor {
|
||||
def receiveT = { case _ ⇒ }
|
||||
override def preRestart(reason: Throwable) { counter -= 1 }
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) { counter -= 1 }
|
||||
override def postRestart(reason: Throwable) { counter -= 1 }
|
||||
}).start()
|
||||
self.dispatcher = CallingThreadDispatcher.global
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue