Refactoring the use of !! to ?+.get for Akka internal code
This commit is contained in:
parent
6ddee70e0b
commit
9c1a50ba2c
11 changed files with 34 additions and 34 deletions
|
|
@ -66,7 +66,7 @@ object SupervisorSpec {
|
|||
}
|
||||
|
||||
override def receive = {
|
||||
case Die ⇒ temp !! (Die, TimeoutMillis)
|
||||
case Die ⇒ (temp ? (Die, TimeoutMillis)).get
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,13 +200,13 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
|
|||
}
|
||||
|
||||
def ping(pingPongActor: ActorRef) = {
|
||||
(pingPongActor !! (Ping, TimeoutMillis)).getOrElse("nil") must be(PongMessage)
|
||||
messageLogPoll must be(PingMessage)
|
||||
(pingPongActor ? (Ping, TimeoutMillis)).as[String].getOrElse("nil") must be === PongMessage
|
||||
messageLogPoll must be === PingMessage
|
||||
}
|
||||
|
||||
def kill(pingPongActor: ActorRef) = {
|
||||
intercept[RuntimeException] { pingPongActor !! (Die, TimeoutMillis) }
|
||||
messageLogPoll must be(ExceptionMessage)
|
||||
messageLogPoll must be === ExceptionMessage
|
||||
}
|
||||
|
||||
"A supervisor" must {
|
||||
|
|
@ -215,7 +215,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
|
|||
val master = actorOf[Master].start()
|
||||
|
||||
intercept[RuntimeException] {
|
||||
master !! (Die, TimeoutMillis)
|
||||
(master ? (Die, TimeoutMillis)).get
|
||||
}
|
||||
|
||||
sleepFor(1 second)
|
||||
|
|
@ -226,7 +226,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
|
|||
val (temporaryActor, supervisor) = temporaryActorAllForOne
|
||||
|
||||
intercept[RuntimeException] {
|
||||
temporaryActor !! (Die, TimeoutMillis)
|
||||
(temporaryActor ? (Die, TimeoutMillis)).get
|
||||
}
|
||||
|
||||
sleepFor(1 second)
|
||||
|
|
@ -374,13 +374,13 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach
|
|||
Supervise(dyingActor, Permanent) :: Nil))
|
||||
|
||||
intercept[Exception] {
|
||||
dyingActor !! (Die, TimeoutMillis)
|
||||
(dyingActor ? (Die, TimeoutMillis)).get
|
||||
}
|
||||
|
||||
// give time for restart
|
||||
sleepFor(3 seconds)
|
||||
|
||||
(dyingActor !! (Ping, TimeoutMillis)).getOrElse("nil") must be(PongMessage)
|
||||
(dyingActor ? (Ping, TimeoutMillis)).as[String].getOrElse("nil") must be === PongMessage
|
||||
|
||||
inits.get must be(3)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ class DispatcherActorSpec extends JUnitSuite {
|
|||
@Test
|
||||
def shouldSendReplyAsync = {
|
||||
val actor = actorOf[TestActor].start()
|
||||
val result = actor !! "Hello"
|
||||
assert("World" === result.get.asInstanceOf[String])
|
||||
val result = (actor ? "Hello").as[String]
|
||||
assert("World" === result.get)
|
||||
actor.stop()
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ class DispatcherActorSpec extends JUnitSuite {
|
|||
def shouldSendReceiveException = {
|
||||
val actor = actorOf[TestActor].start()
|
||||
try {
|
||||
actor !! "Failure"
|
||||
(actor ? "Failure").get
|
||||
fail("Should have thrown an exception")
|
||||
} catch {
|
||||
case e ⇒
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class PinnedActorSpec extends JUnitSuite {
|
|||
def shouldSendReceiveException = {
|
||||
val actor = actorOf[TestActor].start()
|
||||
try {
|
||||
actor !! "Failure"
|
||||
(actor ? "Failure").get
|
||||
fail("Should have thrown an exception")
|
||||
} catch {
|
||||
case e ⇒
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
|
||||
count.get must be(2)
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be(2)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be(2)
|
||||
|
||||
pool.stop()
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
|
||||
pool ! 1
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be(2)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be(2)
|
||||
|
||||
var loops = 0
|
||||
def loop(t: Int) = {
|
||||
|
|
@ -296,7 +296,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
latch.await
|
||||
count.get must be(loops)
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be(2)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be(2)
|
||||
|
||||
// a whole bunch should max it out
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
latch.await
|
||||
count.get must be(loops)
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be(4)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be(4)
|
||||
|
||||
pool.stop()
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
latch.await
|
||||
count.get must be(loops)
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be(2)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be(2)
|
||||
|
||||
// send a bunch over the theshold and observe an increment
|
||||
loops = 15
|
||||
|
|
@ -362,7 +362,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
latch.await(10 seconds)
|
||||
count.get must be(loops)
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be >= (3)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be >= (3)
|
||||
|
||||
pool.stop()
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
|
||||
sleepFor(5 millis)
|
||||
|
||||
val z = (pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size
|
||||
val z = (pool ? ActorPool.Stat).as[ActorPool.Stats].get.size
|
||||
|
||||
z must be >= (2)
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ class RoutingSpec extends WordSpec with MustMatchers {
|
|||
sleepFor(500 millis)
|
||||
}
|
||||
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be <= (z)
|
||||
(pool ? ActorPool.Stat).as[ActorPool.Stats].get.size must be <= (z)
|
||||
|
||||
pool.stop()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ class DefaultClusterNode private[akka] (
|
|||
.build
|
||||
|
||||
replicaConnectionsForReplicationFactor(replicationFactor) foreach { connection ⇒
|
||||
(connection !! (command, remoteDaemonAckTimeout)) match {
|
||||
(connection ? (command, remoteDaemonAckTimeout)).as[Status] match {
|
||||
|
||||
case Some(Success) ⇒
|
||||
EventHandler.debug(this, "Replica for [%s] successfully created".format(actorRef.address))
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ object PingPong {
|
|||
count += 1
|
||||
self reply Ball
|
||||
} else {
|
||||
self.sender.foreach(_ !! Stop)
|
||||
self.sender.foreach(s ⇒ (s ? Stop).await)
|
||||
gameOverLatch.countDown
|
||||
self.stop
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
package sample.osgi
|
||||
|
||||
import akka.actor.{ Actor, ActorRegistry }
|
||||
import Actor._
|
||||
import akka.actor.Actor
|
||||
import akka.actor.Actor._
|
||||
|
||||
import org.osgi.framework.{ BundleActivator, BundleContext }
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ class Activator extends BundleActivator {
|
|||
def start(context: BundleContext) {
|
||||
println("Starting the OSGi example ...")
|
||||
val echo = actorOf[EchoActor].start()
|
||||
val answer = (echo !! "OSGi example")
|
||||
val answer = (echo ? "OSGi example").as[String]
|
||||
println(answer getOrElse "No answer!")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class CoordinatedIncrementSpec extends WordSpec with MustMatchers {
|
|||
counters(0) ! coordinated(Increment(counters.tail))
|
||||
coordinated.await
|
||||
for (counter ← counters) {
|
||||
(counter !! GetCount).get must be === 1
|
||||
(counter ? GetCount).as[Int].get must be === 1
|
||||
}
|
||||
counters foreach (_.stop())
|
||||
failer.stop()
|
||||
|
|
@ -76,7 +76,7 @@ class CoordinatedIncrementSpec extends WordSpec with MustMatchers {
|
|||
counters(0) ! Coordinated(Increment(counters.tail :+ failer))
|
||||
coordinated.await
|
||||
for (counter ← counters) {
|
||||
(counter !! GetCount).get must be === 0
|
||||
(counter ? GetCount).as[Int].get must be === 0
|
||||
}
|
||||
counters foreach (_.stop())
|
||||
failer.stop()
|
||||
|
|
|
|||
|
|
@ -109,9 +109,9 @@ class FickleFriendsSpec extends WordSpec with MustMatchers {
|
|||
val latch = new CountDownLatch(1)
|
||||
coordinator ! FriendlyIncrement(counters, latch)
|
||||
latch.await // this could take a while
|
||||
(coordinator !! GetCount).get must be === 1
|
||||
(coordinator ? GetCount).as[Int].get must be === 1
|
||||
for (counter ← counters) {
|
||||
(counter !! GetCount).get must be === 1
|
||||
(counter ? GetCount).as[Int].get must be === 1
|
||||
}
|
||||
counters foreach (_.stop())
|
||||
coordinator.stop()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class TransactorSpec extends WordSpec with MustMatchers {
|
|||
counters(0) ! Increment(counters.tail, incrementLatch)
|
||||
incrementLatch.await(timeout.length, timeout.unit)
|
||||
for (counter ← counters) {
|
||||
(counter !! GetCount).get must be === 1
|
||||
(counter ? GetCount).as[Int].get must be === 1
|
||||
}
|
||||
counters foreach (_.stop())
|
||||
failer.stop()
|
||||
|
|
@ -104,7 +104,7 @@ class TransactorSpec extends WordSpec with MustMatchers {
|
|||
counters(0) ! Increment(counters.tail :+ failer, failLatch)
|
||||
failLatch.await(timeout.length, timeout.unit)
|
||||
for (counter ← counters) {
|
||||
(counter !! GetCount).get must be === 0
|
||||
(counter ? GetCount).as[Int].get must be === 0
|
||||
}
|
||||
counters foreach (_.stop())
|
||||
failer.stop()
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
def receive = { case _ ⇒ self reply nested }
|
||||
}).start()
|
||||
a must not be (null)
|
||||
val nested = (a !! "any").get.asInstanceOf[ActorRef]
|
||||
val nested = (a ? "any").as[ActorRef].get
|
||||
nested must not be (null)
|
||||
a must not be theSameInstanceAs(nested)
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
def receive = { case _ ⇒ self reply nested }
|
||||
}).start()
|
||||
a must not be (null)
|
||||
val nested = (a !! "any").get.asInstanceOf[ActorRef]
|
||||
val nested = (a ? "any").as[ActorRef].get
|
||||
nested must not be (null)
|
||||
a must not be theSameInstanceAs(nested)
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
"stop when sent a poison pill" in {
|
||||
val a = TestActorRef[WorkerActor].start()
|
||||
intercept[ActorKilledException] {
|
||||
a !! PoisonPill
|
||||
(a ? PoisonPill).get
|
||||
}
|
||||
a must not be ('running)
|
||||
a must be('shutdown)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue