how do I enable speed4j stats in jmx

65 views
Skip to first unread message

David Hawthorne

unread,
Aug 24, 2011, 3:10:48 AM8/24/11
to hector-users
I need an example of how to do this.

Thanks.

Patricio Echagüe

unread,
Aug 25, 2011, 12:46:28 PM8/25/11
to hector...@googlegroups.com
Hi David, sorry for the late response.

cassandraHostConfigurator.setOpTimer(new SpeedForJOpTimer("cluster name"));

In addition to have this entry in your log4j:

me.prettyprint.cassandra.hector.TimingLogger


Please let me know if that works. 


Thanks

David Hawthorne

unread,
Aug 25, 2011, 8:51:03 PM8/25/11
to hector-users
Excellent, and that was almost enough to get it to work.

I added this line to log4j.conf:

log4j.category.me.prettyprint.cassandra.hector.TimingLogger=info,
stdout

I added this line in my client class:

CassandraHostConfigurator cassandraHostConfigurator =
new CassandraHostConfigurator(cassandra_host);

cassandraHostConfigurator.setOpTimer(new
SpeedForJOpTimer("foo"));

And after that I see speed4j in the mbeans list in jmx, but the only
two attributes available are:

DroppedStopWatches and StopWatchQueueLength

So I did some more digging based on another answer I got a while back
about exporting tags. DEEEEEEP in hector, in
me.pp.cassandra.connection.SpeedForJOpTimer, I added this line:

PeriodicalLog slog = new PeriodicalLog();
slog.setName("hector-" + clusterName);
slog.setPeriod(60); // 60 seconds
+
slog.setJmx("READ.success_,WRITE.success_,READ.fail_,WRITE.fail_,META_READ.success_,META_READ.fail_");

slog.setSlf4jLogname("me.prettyprint.cassandra.hector.TimingLogger");

stopWatchFactory = StopWatchFactory.getInstance(slog);

I rebuilt the hector library, restarted my cassandra client, and
voila, everything is showing up as it should.

I also changed the setPeriod from 60 to 10 because I'm feeding this to
statsd, which works on 10-second intervals.

It might not be a bad idea to create another constructor for the
SpeedForJOpTimer class that takes a pre-configured PeriodicalLog
object as the only argument.


On Aug 25, 9:46 am, Patricio Echagüe <patric...@gmail.com> wrote:
> Hi David, sorry for the late response.
>
> cassandraHostConfigurator.setOpTimer(new SpeedForJOpTimer("cluster name"));
>
> In addition to have this entry in your log4j:
>
> me.prettyprint.cassandra.hector.TimingLogger
>
> Please let me know if that works.
>
> Thanks
>

Patricio Echagüe

unread,
Aug 26, 2011, 12:29:53 PM8/26/11
to hector...@googlegroups.com
Hi David, a rebuild is not necessary.

That info should be added to speed4j.properties

Patricio Echagüe

unread,
Aug 26, 2011, 12:58:18 PM8/26/11
to hector...@googlegroups.com
I wrote this page in the wiki for future references: https://github.com/rantav/hector/wiki/Performance-Metrics-with-Speed4j and can be accessed through the main wiki page: https://github.com/rantav/hector/wiki

2011/8/26 Patricio Echagüe <patr...@gmail.com>

David Hawthorne

unread,
Aug 26, 2011, 6:45:12 PM8/26/11
to hector-users
ok, I switched back to stock hector, fixed the speed4j.properties
file, and it's doing something different but it's still not enough.

Problem:

statistics appear as expected under speed4j -> hector -> attributes.
Values are all 0 and do not get updated.
statistics do *not* appear as expected under speed4j -> hector-foo ->
attributes. The only two attributes available there are:
DroppedStopWatches and StopWatchQueueLength

hector-foo because of the call:
cassandraHostConfigurator.setOpTimer(new SpeedForJOpTimer("foo"));

I experimented with changing the speed4j.properties file to look like
this:

speed4j.hector-foo = com.ecyrd.speed4j.log.PeriodicalLog
speed4j.hector-foo.period = 10
speed4j.hector-
foo.jmx=READ.success_,WRITE.success_,READ.fail_,WRITE.fail_,META_READ.success_,META_READ.fail_
speed4j.hector-foo.slf4jLogname=me.prettyprint.hector.TimingLogger

And I *do* see the attributes under speed4j -> hector-foo, but they
never update, so that's a bust.


On Aug 26, 9:58 am, Patricio Echagüe <patric...@gmail.com> wrote:
> I wrote this page in the wiki for future references:https://github.com/rantav/hector/wiki/Performance-Metrics-with-Speed4jand
> can be accessed through the main wiki page:https://github.com/rantav/hector/wiki
>
> 2011/8/26 Patricio Echagüe <patric...@gmail.com>
>
>
>
>
>
>
>
> > Hi David, a rebuild is not necessary.
>
> > That info should be added to speed4j.properties<http://pastebin.com/MHeV3iHi>
>
> > On Thu, Aug 25, 2011 at 5:51 PM, David Hawthorne <dsrtho...@gmail.com>wrote:
>
> >> Excellent, and that was almost enough to get it to work.
>
> >> I added this line to log4j.conf:
>
> >> log4j.category.me.prettyprint.cassandra.hector.TimingLogger=info,
> >> stdout
>
> >> I added this line in my client class:
>
> >>                CassandraHostConfigurator cassandraHostConfigurator =
> >>                        new CassandraHostConfigurator(cassandra_host);
>
> >>                cassandraHostConfigurator.setOpTimer(new
> >> SpeedForJOpTimer("foo"));
>
> >> And after that I see speed4j in the mbeans list in jmx, but the only
> >> two attributes available are:
>
> >> DroppedStopWatches and StopWatchQueueLength
>
> >> So I did some more digging based on another answer I got a while back
> >> about exporting tags.  DEEEEEEP in hector, in
> >> me.pp.cassandra.connection.SpeedForJOpTimer, I added this line:
>
> >>    PeriodicalLog slog = new PeriodicalLog();
> >>    slog.setName("hector-" + clusterName);
> >>    slog.setPeriod(60); // 60 seconds
> >> +
>
> >> slog.setJmx("READ.success_,WRITE.success_,READ.fail_,WRITE.fail_,META_READ. success_,META_READ.fail_");

Patricio Echagüe

unread,
Aug 26, 2011, 7:01:06 PM8/26/11
to hector...@googlegroups.com
do the stats get printed out on the console every 10 seconds? 

David Hawthorne

unread,
Aug 27, 2011, 3:29:24 PM8/27/11
to hector-users
They do. That part works.

On Aug 26, 4:01 pm, Patricio Echagüe <patric...@gmail.com> wrote:
> do the stats get printed out on the console every 10 seconds?
>
> On Fri, Aug 26, 2011 at 3:45 PM, David Hawthorne <dsrtho...@gmail.com>wrote:
>
>
>
>
>
>
>
> > ok, I switched back to stock hector, fixed the speed4j.properties
> > file, and it's doing something different but it's still not enough.
>
> > Problem:
>
> > statistics appear as expected under speed4j -> hector -> attributes.
> > Values are all 0 and do not get updated.
> > statistics do *not* appear as expected under speed4j -> hector-foo ->
> > attributes.  The only two attributes available there are:
> > DroppedStopWatches and StopWatchQueueLength
>
> > hector-foo because of the call:
> > cassandraHostConfigurator.setOpTimer(new SpeedForJOpTimer("foo"));
>
> > I experimented with changing the speed4j.properties file to look like
> > this:
>
> > speed4j.hector-foo = com.ecyrd.speed4j.log.PeriodicalLog
> > speed4j.hector-foo.period = 10
> > speed4j.hector-
>
> > foo.jmx=READ.success_,WRITE.success_,READ.fail_,WRITE.fail_,META_READ.succe ss_,META_READ.fail_
> > speed4j.hector-foo.slf4jLogname=me.prettyprint.hector.TimingLogger
>
> > And I *do* see the attributes under speed4j -> hector-foo, but they
> > never update, so that's a bust.
>
> > On Aug 26, 9:58 am, Patricio Echagüe <patric...@gmail.com> wrote:
> > > I wrote this page in the wiki for future references:
> >https://github.com/rantav/hector/wiki/Performance-Metrics-with-Speed4...
Reply all
Reply to author
Forward
0 new messages