KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > stats > counter > sampled > SampledCounterConfig


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

4 package com.tc.stats.counter.sampled;
5
6 /**
7  * Configuration for any given timed counter
8  */

9 public class SampledCounterConfig {
10   private final int intervalSecs;
11   private final int historySize;
12   private final boolean isReset;
13   private final long initialValue;
14
15   /**
16    * Make a new timed counter config (duh)
17    *
18    * @param intervalSecs the interval (in seconds) between sampling
19    * @param historySize number of counter samples that will be retained in memory
20    * @param isResetOnSample true if the counter should be reset to 0 upon each sample
21    */

22   public SampledCounterConfig(int intervalSecs, int historySize, boolean isResetOnSample, long initialValue) {
23     if (intervalSecs < 1) { throw new IllegalArgumentException JavaDoc("Interval (" + intervalSecs
24                                                                + ") must be greater than or equal to 1"); }
25     if (historySize < 1) { throw new IllegalArgumentException JavaDoc("History size (" + historySize
26                                                               + ") must be greater than or equal to 1"); }
27
28     this.intervalSecs = intervalSecs;
29     this.historySize = historySize;
30     this.isReset = isResetOnSample;
31     this.initialValue = initialValue;
32   }
33
34   public int getHistorySize() {
35     return historySize;
36   }
37
38   public int getIntervalSecs() {
39     return intervalSecs;
40   }
41
42   public boolean isResetOnSample() {
43     return this.isReset;
44   }
45
46   public long getInitialValue() {
47     return this.initialValue;
48   }
49
50 }
Popular Tags