1 23 24 28 29 34 35 36 package com.sun.enterprise.admin.monitor.stats; 37 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 38 import com.sun.enterprise.util.i18n.StringManager; 39 40 47 48 public final class BoundedRangeStatisticImpl extends StatisticImpl implements 49 BoundedRangeStatistic { 50 51 private final long currentVal; 52 private final long highWaterMark; 53 private final long lowWaterMark; 54 private final long upperBound; 55 private final long lowerBound; 56 private static final StringManager localStrMgr = 57 StringManager.getManager(BoundedRangeStatisticImpl.class); 58 59 60 public static final long DEFAULT_MAX_BOUND = java.lang.Long.MAX_VALUE; 61 62 public static final long DEFAULT_MIN_BOUND = DEFAULT_VALUE; 63 64 79 public BoundedRangeStatisticImpl(String name) { 80 this(name, DEFAULT_UNIT); 81 } 82 83 98 public BoundedRangeStatisticImpl(String name, String unit) { 99 this(name, unit, DEFAULT_VALUE); 100 } 101 102 117 public BoundedRangeStatisticImpl(String name, String unit, String desc, long value, long max, long min) { 118 this (value, 119 value, 120 value, 121 max, 122 min, 123 name, 124 unit, 125 desc, 126 Util.getInitTime()[0], 127 Util.getInitTime()[1] 128 ); 129 130 } 131 132 145 public BoundedRangeStatisticImpl(String name, String unit, long value) { 146 this(name, unit, value, DEFAULT_MAX_BOUND, DEFAULT_MIN_BOUND); 147 } 148 149 164 public BoundedRangeStatisticImpl(String name, String unit, long value, 165 long max, long min) { 166 this(name, unit, value, max, min, value, value); 167 } 168 169 184 public BoundedRangeStatisticImpl(String name, String unit, long value, 185 long max, long min, long highMark, long lowMark) { 186 this (value, 187 highMark, 188 lowMark, 189 max, 190 min, 191 name, 192 unit, 193 Util.getDescriptionFromName(name), 194 Util.getInitTime()[0], 195 Util.getInitTime()[1] 196 ); 197 } 198 199 214 215 public BoundedRangeStatisticImpl(long curVal, long highMark, long lowMark, 216 long upper, long lower, String name, 217 String unit, String desc, long startTime, 218 long sampleTime) { 219 super(name, unit, desc, startTime, sampleTime); 220 currentVal = curVal; 221 highWaterMark = highMark; 222 lowWaterMark = lowMark; 223 upperBound = upper; 224 lowerBound = lower; 225 } 226 227 231 public long getCurrent() { 232 return currentVal; 233 } 234 235 239 public long getHighWaterMark() { 240 return highWaterMark; 241 } 242 243 247 public long getLowWaterMark() { 248 return lowWaterMark; 249 } 250 251 255 public long getLowerBound() { 256 return lowerBound; 257 } 258 259 263 public long getUpperBound() { 264 return upperBound; 265 } 266 267 private static class Util { 268 272 private static String getDescriptionFromName(String name) { 273 return (localStrMgr.getString("describes_string") + name); 274 } 275 276 280 private static long[] getInitTime() { 281 final long time = System.currentTimeMillis(); 282 return ( new long[]{time, time} ); 283 } 284 } 285 } 286 | Popular Tags |