01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.stats;
06:
07: import com.tc.stats.counter.sampled.SampledCounter;
08: import com.tc.stats.counter.sampled.TimeStampedCounterValue;
09: 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(
20: TimeStampedCounterValue sample) {
21: CountStatisticImpl stat = new CountStatisticImpl();
22: // TODO: we could include the min/max/avg in the returned stat
23: stat.setLastSampleTime(sample.getTimestamp());
24: stat.setCount(sample.getCounterValue());
25: return stat;
26: }
27:
28: }
|