Source code: org/activemq/management/RangeStatisticImpl.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.activemq.management;
19
20
21 /**
22 * A range statistic implementation
23 *
24 * @version $Revision: 1.1.1.1 $
25 */
26 public class RangeStatisticImpl extends StatisticImpl {
27 private long highWaterMark;
28 private long lowWaterMark;
29 private long current;
30
31 public RangeStatisticImpl(String name, String unit, String description) {
32 super(name, unit, description);
33 }
34
35 public void reset() {
36 super.reset();
37 current = 0;
38 lowWaterMark = 0;
39 highWaterMark = 0;
40 }
41
42 public long getHighWaterMark() {
43 return highWaterMark;
44 }
45
46 public long getLowWaterMark() {
47 return lowWaterMark;
48 }
49
50 public long getCurrent() {
51 return current;
52 }
53
54 public void setCurrent(long current) {
55 this.current = current;
56 if (current > highWaterMark) {
57 highWaterMark = current;
58 }
59 if (current < lowWaterMark || lowWaterMark == 0) {
60 lowWaterMark = current;
61 }
62 updateSampleTime();
63 }
64
65 protected void appendFieldDescription(StringBuffer buffer) {
66 buffer.append(" current: ");
67 buffer.append(Long.toString(current));
68 buffer.append(" lowWaterMark: ");
69 buffer.append(Long.toString(lowWaterMark));
70 buffer.append(" highWaterMark: ");
71 buffer.append(Long.toString(highWaterMark));
72 super.appendFieldDescription(buffer);
73 }
74 }