KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > stats > StatsUtil


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.stats;
6
7 import com.tc.stats.counter.sampled.SampledCounter;
8 import com.tc.stats.counter.sampled.TimeStampedCounterValue;
9 import com.tc.stats.statistics.CountStatistic;
10 import com.tc.stats.statistics.CountStatisticImpl;
11
12 public class StatsUtil {
13
14   public static CountStatistic makeCountStat(SampledCounter counter) {
15     TimeStampedCounterValue sample = counter.getMostRecentSample();
16     return makeCountStat(sample);
17   }
18
19   public static CountStatistic makeCountStat(TimeStampedCounterValue sample) {
20     CountStatisticImpl stat = new CountStatisticImpl();
21     // TODO: we could include the min/max/avg in the returned stat
22
stat.setLastSampleTime(sample.getTimestamp());
23     stat.setCount(sample.getCounterValue());
24     return stat;
25   }
26
27 }
28
Popular Tags