Fixing #706
This commit is contained in:
parent
2d80ff4e04
commit
fadd30e96b
2 changed files with 45 additions and 45 deletions
|
|
@ -65,17 +65,9 @@ trait DefaultActorPool extends ActorPool { this: Actor =>
|
|||
self reply_? Stats(_delegates length)
|
||||
case max: MaximumNumberOfRestartsWithinTimeRangeReached =>
|
||||
_delegates = _delegates filterNot { _.uuid == max.victim.uuid }
|
||||
|
||||
case msg =>
|
||||
_capacity()
|
||||
_select() foreach { delegate =>
|
||||
self.senderFuture match {
|
||||
case None =>
|
||||
delegate ! msg
|
||||
case Some(future) =>
|
||||
delegate.!!!(msg, TimeUnit.NANOSECONDS.toMillis(future.timeoutInNanos)).onComplete( future.completeWith(_) )
|
||||
}
|
||||
}
|
||||
_select() foreach { _ forward msg }
|
||||
}
|
||||
|
||||
private def _capacity() = {
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
|
|||
// make sure the pool is of the fixed, expected capacity
|
||||
//
|
||||
@Test def testFixedCapacityActorPool = {
|
||||
|
||||
val latch = new CountDownLatch(2)
|
||||
val counter = new AtomicInteger(0)
|
||||
class TestPool extends Actor with DefaultActorPool
|
||||
|
|
@ -198,6 +197,7 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
|
|||
case _ =>
|
||||
counter.incrementAndGet
|
||||
latch.countDown
|
||||
self reply_? "success"
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -208,11 +208,19 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
|
|||
def receive = _route
|
||||
}
|
||||
|
||||
val successes = new CountDownLatch(2)
|
||||
implicit val successCounterActor = Some(actorOf(new Actor {
|
||||
def receive = {
|
||||
case "success" => successes.countDown
|
||||
}
|
||||
}).start)
|
||||
|
||||
val pool = actorOf(new TestPool).start
|
||||
pool ! "a"
|
||||
pool ! "b"
|
||||
val done = latch.await(1,TimeUnit.SECONDS)
|
||||
done must be (true)
|
||||
|
||||
latch.await(1,TimeUnit.SECONDS) must be (true)
|
||||
successes.await(1,TimeUnit.SECONDS) must be (true)
|
||||
counter.get must be (2)
|
||||
(pool !! ActorPool.Stat).asInstanceOf[Option[ActorPool.Stats]].get.size must be (2)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue