incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r884504 - in /incubator/esme/trunk/server/src: main/scala/org/apache/esme/actor/PopStatsActor.scala test/scala/org/apache/esme/actor/PopStatsActorTest.scala
Date Thu, 26 Nov 2009 11:03:50 GMT
Author: vdichev
Date: Thu Nov 26 11:03:49 2009
New Revision: 884504

URL: http://svn.apache.org/viewvc?rev=884504&view=rev
Log:
Fixed PopStatsActor expiration

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/PopStatsActor.scala
    incubator/esme/trunk/server/src/test/scala/org/apache/esme/actor/PopStatsActorTest.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/PopStatsActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/PopStatsActor.scala?rev=884504&r1=884503&r2=884504&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/PopStatsActor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/PopStatsActor.scala Thu
Nov 26 11:03:49 2009
@@ -101,8 +101,9 @@
       reply(topList)
       
       case Expire => {
-        val (live, expired) = queue.partition(_.when < now)
+        val (live, expired) = queue.partition(_.when > now)
         expired.foreach(stats -= _.id)
+        ActorPing.schedule(this, Expire, refreshInterval)
         live
       }
     }

Modified: incubator/esme/trunk/server/src/test/scala/org/apache/esme/actor/PopStatsActorTest.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/actor/PopStatsActorTest.scala?rev=884504&r1=884503&r2=884504&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/test/scala/org/apache/esme/actor/PopStatsActorTest.scala
(original)
+++ incubator/esme/trunk/server/src/test/scala/org/apache/esme/actor/PopStatsActorTest.scala
Thu Nov 26 11:03:49 2009
@@ -33,19 +33,25 @@
   
   "Popularity Stats" should {
     "Update top hits after inrcementing statistics" in {
-      PopStatsActor !? (500, PopStatsActor.StartStats(ResendStat, 5000, 5000))
+      PopStatsActor !? (100, PopStatsActor.StartStats(ResendStat, 2000, 1000))
 
-      PopStatsActor !? (500, PopStatsActor.IncrStats(ResendStat, 1))
-      val stats1 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 5000)
+      PopStatsActor !? (100, PopStatsActor.IncrStats(ResendStat, 1))
+      val stats1 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 2000)
       stats1 must beEqualTo(List(1 -> 1))
 
-      PopStatsActor !? (500, PopStatsActor.IncrStats(ResendStat, 3))
-      val stats2 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 5000)
+      PopStatsActor !? (100, PopStatsActor.IncrStats(ResendStat, 3))
+      val stats2 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 2000)
       stats2 must beEqualTo(List(3 -> 1, 1 -> 1))
 
-      PopStatsActor !? (500, PopStatsActor.IncrStats(ResendStat, 1))
-      val stats3 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 5000)
+      PopStatsActor !? (100, PopStatsActor.IncrStats(ResendStat, 1))
+      val stats3 = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 2000)
       stats3 must beEqualTo(List(1 -> 2, 3 -> 1))
     }
+    
+    "Information should expire after timeout" in {
+      Thread.sleep(2000)
+      val stats = PopStatsActor !? PopStatsActor.TopStats(ResendStat, 5, 2000)
+      stats must beEqualTo(Nil)
+    }
   }
 }



Mime
View raw message