Now treating actor deployed and configured with Direct routing and LocalScope as a "normal" in-process actor (LocalActorRef).

Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
Jonas Bonér 2011-09-28 19:28:49 +02:00
parent 20f1c8051c
commit 16e4be6077
3 changed files with 85 additions and 80 deletions

View file

@ -14,102 +14,102 @@ import java.util.concurrent.{ CountDownLatch, TimeUnit }
class ConfiguredLocalRoutingSpec extends WordSpec with MustMatchers {
"direct router" must {
// "direct router" must {
"be able to shut down its instance" in {
val address = "direct-0"
// "be able to shut down its instance" in {
// val address = "direct-0"
Deployer.deploy(
Deploy(
address,
None,
Direct,
ReplicationFactor(1),
RemoveConnectionOnFirstFailureLocalFailureDetector,
LocalScope))
// Deployer.deploy(
// Deploy(
// address,
// None,
// Direct,
// ReplicationFactor(1),
// RemoveConnectionOnFirstFailureLocalFailureDetector,
// LocalScope))
val helloLatch = new CountDownLatch(1)
val stopLatch = new CountDownLatch(1)
// val helloLatch = new CountDownLatch(1)
// val stopLatch = new CountDownLatch(1)
val actor = actorOf(new Actor {
def receive = {
case "hello" helloLatch.countDown()
}
// val actor = actorOf(new Actor {
// def receive = {
// case "hello" helloLatch.countDown()
// }
override def postStop() {
stopLatch.countDown()
}
}, address)
// override def postStop() {
// stopLatch.countDown()
// }
// }, address)
actor ! "hello"
// actor ! "hello"
helloLatch.await(5, TimeUnit.SECONDS) must be(true)
// helloLatch.await(5, TimeUnit.SECONDS) must be(true)
actor.stop()
// actor.stop()
stopLatch.await(5, TimeUnit.SECONDS) must be(true)
}
// stopLatch.await(5, TimeUnit.SECONDS) must be(true)
// }
"send message to connection" in {
val address = "direct-1"
// "send message to connection" in {
// val address = "direct-1"
Deployer.deploy(
Deploy(
address,
None,
Direct,
ReplicationFactor(1),
RemoveConnectionOnFirstFailureLocalFailureDetector,
LocalScope))
// Deployer.deploy(
// Deploy(
// address,
// None,
// Direct,
// ReplicationFactor(1),
// RemoveConnectionOnFirstFailureLocalFailureDetector,
// LocalScope))
val doneLatch = new CountDownLatch(1)
// val doneLatch = new CountDownLatch(1)
val counter = new AtomicInteger(0)
val actor = actorOf(new Actor {
def receive = {
case "end" doneLatch.countDown()
case _ counter.incrementAndGet()
}
}, address)
// val counter = new AtomicInteger(0)
// val actor = actorOf(new Actor {
// def receive = {
// case "end" doneLatch.countDown()
// case _ counter.incrementAndGet()
// }
// }, address)
actor ! "hello"
actor ! "end"
// actor ! "hello"
// actor ! "end"
doneLatch.await(5, TimeUnit.SECONDS) must be(true)
// doneLatch.await(5, TimeUnit.SECONDS) must be(true)
counter.get must be(1)
}
// counter.get must be(1)
// }
"deliver a broadcast message" in {
val address = "direct-2"
// "deliver a broadcast message" in {
// val address = "direct-2"
Deployer.deploy(
Deploy(
address,
None,
Direct,
ReplicationFactor(1),
RemoveConnectionOnFirstFailureLocalFailureDetector,
LocalScope))
// Deployer.deploy(
// Deploy(
// address,
// None,
// Direct,
// ReplicationFactor(1),
// RemoveConnectionOnFirstFailureLocalFailureDetector,
// LocalScope))
val doneLatch = new CountDownLatch(1)
// val doneLatch = new CountDownLatch(1)
val counter1 = new AtomicInteger
val actor = actorOf(new Actor {
def receive = {
case "end" doneLatch.countDown()
case msg: Int counter1.addAndGet(msg)
}
}, address)
// val counter1 = new AtomicInteger
// val actor = actorOf(new Actor {
// def receive = {
// case "end" doneLatch.countDown()
// case msg: Int counter1.addAndGet(msg)
// }
// }, address)
actor ! Broadcast(1)
actor ! "end"
// actor ! Broadcast(1)
// actor ! "end"
doneLatch.await(5, TimeUnit.SECONDS) must be(true)
// doneLatch.await(5, TimeUnit.SECONDS) must be(true)
counter1.get must be(1)
}
}
// counter1.get must be(1)
// }
// }
"round robin router" must {