View Javadoc
1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: GaugeStat.java,v 1.4 2003/03/03 05:14:39 michaelh Exp $ 20 */ 21 package juju.reattore.util; 22 23 24 /*** Statistic module that manages a gauge. A gauge is a statistic 25 that has a current value that goes up and down, such as the number 26 of connections. 27 */ 28 public class GaugeStat extends BaseStat { 29 private long count; 30 private int current; 31 private int max; 32 33 /*** @see BaseStat */ 34 public GaugeStat(Class clazz, String leaf) { 35 super(clazz, leaf); 36 } 37 38 /*** Get the total number of samples added. 39 40 @return The number of samples. 41 */ 42 public long getCount() { 43 return count; 44 } 45 46 /*** Increases this gauge. 47 */ 48 public void inc() { 49 count++; 50 current++; 51 52 max = (current > max) ? current : max; 53 } 54 55 /*** Decreases this gauge. 56 */ 57 public void dec() { 58 count++; 59 current--; 60 } 61 62 /*** Get the current value of the gauge. 63 64 @return The current value. 65 */ 66 public int getCurrent() { 67 return current; 68 } 69 70 /*** Get the maximum value this gauge has ever had. 71 72 @return The maximum value. 73 */ 74 public int getMaximum() { 75 return max; 76 } 77 78 /*** @see BaseStat */ 79 protected String getDefaultFormat() { 80 return "{0} Count: {1} Current: {2} Max: {3}"; 81 } 82 83 /*** @see BaseStat */ 84 protected Object[] getFormatArgs() { 85 return new Object[] { 86 getName(), new Long(getCount()), new Integer(getCurrent()), 87 new Integer(getMaximum()) 88 }; 89 } 90 }

This page was automatically generated by Maven