incubator-esme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy the destroyer <andythedestro...@gmail.com>
Subject Re: Patch is in email body this time.
Date Sat, 24 Oct 2009 08:19:54 GMT
Done.

-A

On Fri, Oct 23, 2009 at 8:11 PM, Richard Hirsch <hirsch.dick@gmail.com>wrote:

> looks good but I still can't use it, because it isn't licensed for
> inclusion in the ASF.
>
> If you can add the patch to the Jira item, I'll add to our source.
>
> D,
>
>
>
> On Fri, Oct 23, 2009 at 9:21 PM, Andy the destroyer
> <andythedestroyer@gmail.com> wrote:
> > Here is the patch with the stats code.
> > -Andy
> >
> > ==================
> >
> > Index: src/main/scala/org/apache/esme/model/User.scala
> > ===================================================================
> > --- src/main/scala/org/apache/esme/model/User.scala (revision 828904)
> > +++ src/main/scala/org/apache/esme/model/User.scala (working copy)
> > @@ -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)
> > Index: src/main/scala/org/apache/esme/actor/SchedulerActor.scala
> > ===================================================================
> > --- src/main/scala/org/apache/esme/actor/SchedulerActor.scala (revision
> > 828904)
> > +++ src/main/scala/org/apache/esme/actor/SchedulerActor.scala (working
> copy)
> > @@ -28,6 +28,7 @@
> > import net.liftweb.util._
> > import Helpers._
> > import net.liftweb.common._
> > +import com.twitter.stats.Stats
> >
> >
> > object SchedulerActor extends LiftActor{
> > @@ -92,6 +93,8 @@
> > messageProcessor ! Distributor.AddMessageToMailbox(user, msg, reason)
> > // }
> > }
> > + Stats incr "schedulerMessagesCreated"
> > + Stats incr "messagesCreated"
> > }
> >
> > }
> > Index: src/main/scala/org/apache/esme/actor/UserActor.scala
> > ===================================================================
> > --- src/main/scala/org/apache/esme/actor/UserActor.scala (revision
> 828904)
> > +++ src/main/scala/org/apache/esme/actor/UserActor.scala (working copy)
> > @@ -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
> > }
> > }
> > }
> > Index: src/main/scala/org/apache/esme/actor/Distributor.scala
> > ===================================================================
> > --- src/main/scala/org/apache/esme/actor/Distributor.scala (revision
> 828904)
> > +++ src/main/scala/org/apache/esme/actor/Distributor.scala (working copy)
> > @@ -140,4 +140,7 @@
> > }
> > }
> >
> > + def getUsersCount = users.size
> > + def getListenersCount = listeners.size
> > +
> > }
> > Index: src/main/scala/org/apache/esme/actor/MessagePullActor.scala
> > ===================================================================
> > --- src/main/scala/org/apache/esme/actor/MessagePullActor.scala (revision
> > 828904)
> > +++ src/main/scala/org/apache/esme/actor/MessagePullActor.scala (working
> > copy)
> > @@ -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 =>
> > Index: src/main/scala/bootstrap/liftweb/Boot.scala
> > ===================================================================
> > --- src/main/scala/bootstrap/liftweb/Boot.scala (revision 828904)
> > +++ src/main/scala/bootstrap/liftweb/Boot.scala (working copy)
> > @@ -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 net.liftweb.widgets.tablesorter._
> > +import com.twitter.stats.Stats
> >
> > /**
> > * A class that's instantiated early and run. It allows the application
> > @@ -160,10 +162,15 @@
> >
> > LiftRules.early.append(makeUtf8)
> >
> > + ESMEStatsMBean("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 {
> > @@ -297,6 +304,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
> > Index: pom.xml
> > ===================================================================
> > --- pom.xml (revision 828904)
> > +++ pom.xml (working copy)
> > @@ -13,6 +13,7 @@
> > <compass.version>2.1.1</compass.version>
> > <lucene.version>2.4.0</lucene.version>
> > <netbeans.hint.deploy.server>gfv3</netbeans.hint.deploy.server>
> > + <scala.stats.version>1.3</scala.stats.version>
> > </properties>
> >
> > <repositories>
> > @@ -32,6 +33,21 @@
> > <name>Compass</name>
> > <url>http://repo.compass-project.org</url>
> > </repository>
> > + <repository>
> > + <id>scala-stats</id>
> > + <name>Twitter Repo</name>
> > + <url>http://www.lag.net/nest</url>
> > + </repository>
> > + <repository>
> > + <id>configgy</id>
> > + <name>Another Twitter Repo</name>
> > + <url>http://www.lag.net/repo</url>
> > + </repository>
> > + <repository>
> > + <id>opendmk</id>
> > + <name>Java Dynamic Management Kit</name>
> > + <url>http://maven.tigase.org/</url>
> > + </repository>
> > </repositories>
> >
> > <pluginRepositories>
> > @@ -191,7 +207,22 @@
> > <artifactId>lucene-snowball</artifactId>
> > <version>${lucene.version}</version>
> > </dependency>
> > - <dependency>
> > +
> > + <!-- for stats gathering and jmx -->
> > + <dependency>
> > + <groupId>com.twitter</groupId>
> > + <artifactId>stats</artifactId>
> > + <version>${scala.stats.version}</version>
> > + </dependency>
> > +
> > + <dependency>
> > + <groupId>openDMK</groupId>
> > + <artifactId>jdmkrt</artifactId>
> > + <version>1.0-b02</version>
> > + </dependency>
> > + <!-- end stats and jmx -->
> > +
> > + <dependency>
> > <groupId>org.scala-tools.testing</groupId>
> > <artifactId>specs</artifactId>
> > <version>1.5.0</version>
> > @@ -290,3 +321,4 @@
> > </plugins>
> > </reporting>
> > </project>
> > +
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message