001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.jmx.stats;
030:
031: import com.caucho.util.Alarm;
032:
033: /**
034: * Statistics for a range of values.
035: */
036: public class RangeStats {
037: private String _name;
038: private long _startTime;
039:
040: private long _current;
041: private long _lowWaterMark;
042: private long _highWaterMark;
043:
044: /**
045: * Create a null range stats.
046: */
047: public RangeStats() {
048: _startTime = Alarm.getCurrentTime();
049: }
050:
051: /**
052: * Create a null range stats.
053: */
054: public RangeStats(String name) {
055: _startTime = Alarm.getCurrentTime();
056:
057: _name = name;
058: }
059:
060: /**
061: * Returns the current value.
062: */
063: public long getCurrent() {
064: return _current;
065: }
066:
067: /**
068: * Returns the low water mark value.
069: */
070: public long getLowWaterMark() {
071: return _lowWaterMark;
072: }
073:
074: /**
075: * Returns the high water mark value.
076: */
077: public long getHighWaterMark() {
078: return _highWaterMark;
079: }
080:
081: /**
082: * Sets the current value.
083: */
084: public void setCurrent(long current) {
085: _current = current;
086:
087: if (current < _lowWaterMark)
088: _lowWaterMark = current;
089:
090: if (_highWaterMark < current)
091: _highWaterMark = current;
092: }
093:
094: /**
095: * Resets the range.
096: */
097: public void reset() {
098: _lowWaterMark = _highWaterMark = _current;
099: }
100: }
|