incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r832343 - in /incubator/esme/trunk/server/src/main/scala: bootstrap/liftweb/ org/apache/esme/actor/ org/apache/esme/model/
Date Tue, 03 Nov 2009 08:49:22 GMT
Author: rhirsch
Date: Tue Nov  3 08:49:22 2009
New Revision: 832343

URL: http://svn.apache.org/viewvc?rev=832343&view=rev
Log:
[ESME-18] JMX support
Patch from Andrew Headrick applied

Modified:
    incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/MessagePullActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/SchedulerActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala

Modified: incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Tue Nov  3 08:49:22
2009
@@ -41,12 +41,14 @@
 import snippet._
 import api._
 import net.liftweb._
+import common.Full
 import mapper._
 import provider.HTTPRequest
 import org.compass.core._
 import org.compass.core.config.CompassConfiguration
 
 import net.liftweb.widgets.tablesorter._  
+import com.twitter.stats._
 
 /**
  * A class that's instantiated early and run.  It allows the application
@@ -161,12 +163,19 @@
     LiftRules.dispatch.append(TwitterJsonAPI.dispatch)
 
     LiftRules.early.append(makeUtf8)
+    
+    //JMX
+    if (Props.getBool("jmx.enable", false))
+        StatsMBean("org.apache.esme.stats")
 
     Distributor.touch
     SchedulerActor.touch
     MessagePullActor.touch
     // ScalaInterpreter.touch
     
+    Stats.makeGauge("users"){Distributor.getUsersCount}
+    Stats.makeGauge("listener"){Distributor.getListenersCount}
+    
     val resentPeriod = Props.getLong("stats.resent.period", 1 week)
     val resentRefreshInterval: Long = Props.getLong("stats.resent.refresh") match {
       case Full(interval) if interval > (1 minute) => interval
@@ -299,6 +308,7 @@
   val tenMinutes: Long = 10 minutes
   protected def messageHandler = {
     case SessionWatcherInfo(sessions) =>
+     Stats.getCounter("liftSessions").update(sessions.size)
       if ((millis - tenMinutes) > lastTime) {
         lastTime = millis
         val rt = Runtime.getRuntime

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala Tue
Nov  3 08:49:22 2009
@@ -140,4 +140,7 @@
     }
   }
 
+  def getUsersCount = users.size
+  def getListenersCount = listeners.size
+
 }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/MessagePullActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/MessagePullActor.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/MessagePullActor.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/MessagePullActor.scala
Tue Nov  3 08:49:22 2009
@@ -25,6 +25,7 @@
 import common._
 import actor._
 import org.apache.esme.actor.Distributor.{UserCreatedMessage=>Msg}
+import com.twitter.stats.Stats
 
 object MessagePullActor extends LiftActor {
   
@@ -77,6 +78,7 @@
       for (message <- lastMessages) {
         messageProcessor ! message
         lastMessage = Some(message)
+        Stats incr "messagesPulled"
       }
       
       case FetchMessages => 

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/SchedulerActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/SchedulerActor.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/SchedulerActor.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/SchedulerActor.scala
Tue Nov  3 08:49:22 2009
@@ -28,6 +28,8 @@
 import net.liftweb.util._
 import Helpers._
 import net.liftweb.common._
+import com.twitter.stats.Stats
+import com.twitter.stats.Stats
 
 
 object SchedulerActor extends LiftActor{
@@ -92,6 +94,10 @@
         messageProcessor ! Distributor.AddMessageToMailbox(user, msg, reason)
               // }
             }
+            Stats incr "schedulerMessagesCreated"
+            Stats incr "messagesCreated"
+            Stats incr "schedulerMessagesCreated"
+            Stats incr "messagesCreated"
     }
     
   }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala Tue Nov
 3 08:49:22 2009
@@ -35,6 +35,7 @@
 import java.util.logging._
 import java.util.{TimeZone, Calendar}
 import scala.xml.{Elem}
+import com.twitter.stats.Stats
 
 object UserActor {
   private[actor] case class StartMeUp(user: Long)
@@ -100,6 +101,8 @@
 
         this ! UpdateTracking(Distributor.TrackTrackingType)
         this ! UpdateTracking(Distributor.PerformTrackingType)
+
+        Stats incr "userCount"
         
       case RefreshMe(user) => 
          pools = Privilege.findViewablePools(user)
@@ -133,6 +136,8 @@
                  else null
 
           msg.saveMe
+          Stats incr "userMessagesCreated"
+          Stats incr "messagesCreated"
 
           Distributor ! Distributor.AddMessageToMailbox(userId, msg, NoReason)
         
@@ -231,13 +236,18 @@
         val mb = Mailbox.create.user(userId).message(msg)
         reason match {
           case TrackReason(trackId) => mb.viaTrack(trackId)
+              Stats incr "messagesDeliveredTrackReason"
           case DirectReason(fromId) => mb.directlyFrom(fromId)
+              Stats incr "messagesDeliveredDirectReason"
           case ConversationReason(convId) => mb.conversation(convId)
+              Stats incr "messagesDeliveredConversationReason"
           case ResendReason(resender) => mb.resentBy(resender)
+              Stats incr "messagesDeliveredResendReason"
           case _ =>
         }
         mb.saveMe
-          
+        Stats incr "messagesDelivered"
+
         _mailbox = ((msg.id.is, reason, false) :: _mailbox.toList).take(500).toArray
 
         listeners.foreach(_ ! MessageReceived(msg, reason))
@@ -249,11 +259,11 @@
             case m @ MailTo(_, _) =>
               User.find(userId).foreach( u =>
                 HttpSender ! HttpSender.SendAMessage(m, msg, u, reason, td.uniqueId))
-             
+                Stats incr "messagesMailed"
             case h @ HttpTo(_, _, _, _, _) =>
               User.find(userId).foreach( u =>
                 HttpSender ! HttpSender.SendAMessage(h, msg, u, reason, td.uniqueId))
-
+                Stats incr "messagesSentViaHTTP"
             case PerformResend =>
               if (! msg.saved_?) msg.save
               for (id <- followers)
@@ -267,7 +277,7 @@
               ScalaInterpreter ! ScalaInterpreter.ScalaExcerpt(userId, msg.id.is, msg.pool.is,
msg.getText)
 	      */
 
-            case PerformFilter => // IGNORE
+            case PerformFilter => Stats incr "messagesFiltered" // IGNORE
           }
         }
       }

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala?rev=832343&r1=832342&r2=832343&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala Tue Nov  3
08:49:22 2009
@@ -45,6 +45,7 @@
 import org.apache.esme.view._
 import java.net.URL
 import java.util.logging._
+import com.twitter.stats.Stats
 
 object User extends User with KeyedMetaMapper[Long, User] {
   override def afterSave = profileChanged _ :: notifyActors _ :: super.afterSave
@@ -149,6 +150,8 @@
     curUser.remove()
     curUserId(Full(who.id.toString))
     onLogIn.foreach(_(who))
+
+    Stats incr "usersLoggedIn"
   }
 
   def logoutCurrentUser = logUserOut()
@@ -158,6 +161,7 @@
     curUserId.remove()
     curUser.remove()
     S.request.foreach(_.request.session.terminate)
+    Stats getCounter "usersLoggedIn" incr -1
   }
 
   private object curUserId extends SessionVar[Box[String]](Empty)



Mime
View raw message