01: /*
02: @COPYRIGHT@
03: */
04: package demo.jmx;
05:
06: import java.text.SimpleDateFormat;
07: import java.util.Date;
08:
09: /**
10: * Basic container to hold performance metrics for time interval
11: */
12: public class HistoryData {
13: private final long intervalStart;
14:
15: private int counter;
16:
17: public HistoryData(long intervalStart, int counter) {
18: this .intervalStart = intervalStart;
19: this .counter = counter;
20: }
21:
22: public long getIntervalStart() {
23: return this .intervalStart;
24: }
25:
26: public Date getTime() {
27: return new Date(intervalStart);
28: }
29:
30: public int getCounter() {
31: return this .counter;
32: }
33:
34: public void incrementCounter() {
35: this .counter++;
36: }
37:
38: public void update(int duration, String error) {
39: this .counter++;
40: }
41:
42: public String toString() {
43: SimpleDateFormat df = new SimpleDateFormat(
44: "yyyy-MM-dd HH:mm:ss");
45: return df.format(new Date(intervalStart)) + " : " + counter;
46: }
47: }
|