1 23 24 28 29 34 35 package com.sun.enterprise.admin.monitor.stats; 36 37 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 38 import com.sun.enterprise.admin.monitor.stats.BoundedRangeStatisticImpl; 39 import javax.management.j2ee.statistics.Statistic ; 40 41 50 51 public class MutableBoundedRangeStatisticImpl implements BoundedRangeStatistic , MutableCountStatistic { 52 53 private final BoundedRangeStatistic initial; 54 private long current; 55 private long lastSampleTime; 56 private long startTime; 57 private long lowWaterMark; 58 private long highWaterMark; 59 60 66 public MutableBoundedRangeStatisticImpl(BoundedRangeStatistic initial) { 67 this.initial = initial; 68 this.current = initial.getCurrent(); 69 this.lastSampleTime = initial.getLastSampleTime(); 70 this.startTime = initial.getStartTime(); 71 this.lowWaterMark = initial.getLowWaterMark(); 72 this.highWaterMark = initial.getHighWaterMark(); 73 } 74 75 87 public void reset() { 88 this.current = initial.getCurrent(); 89 this.lastSampleTime = System.currentTimeMillis(); 90 this.startTime = this.lastSampleTime; 91 this.highWaterMark = initial.getHighWaterMark(); 92 this.lowWaterMark = initial.getLowWaterMark(); 93 } 94 95 107 public void setCount(long current) { 108 this.current = current; 109 this.lastSampleTime = System.currentTimeMillis(); 110 111 this.lowWaterMark = (current < this.lowWaterMark) ? (current) : (this.lowWaterMark); 112 this.highWaterMark = (current > this.highWaterMark) ? (current) : (this.highWaterMark); 113 this.lastSampleTime = System.currentTimeMillis(); 114 } 115 116 126 public Statistic unmodifiableView() { 127 return ( new BoundedRangeStatisticImpl( 128 this.current, this.highWaterMark, this.lowWaterMark, initial.getUpperBound(), initial.getLowerBound(), initial.getName(), initial.getUnit(), initial.getDescription(), this.startTime, this.lastSampleTime )); 139 } 140 141 public String getDescription() { 142 return ( initial.getDescription()); 143 } 144 145 public long getLastSampleTime() { 146 return ( this.lastSampleTime ); 147 } 148 149 public String getName() { 150 return ( initial.getName() ); 151 } 152 153 public long getStartTime() { 154 return ( initial.getStartTime() ); 155 } 156 157 public String getUnit() { 158 return ( initial.getUnit() ); 159 } 160 161 public Statistic modifiableView() { 162 return ( this ); 163 } 164 165 public long getCurrent() { 166 return ( this.current ); 167 } 168 169 public long getHighWaterMark() { 170 return ( this.highWaterMark ); 171 } 172 173 public long getLowWaterMark() { 174 return ( this.lowWaterMark ); 175 } 176 177 public long getLowerBound() { 178 return ( initial.getLowerBound() ); 179 } 180 181 public long getUpperBound() { 182 return ( initial.getUpperBound() ); 183 } 184 185 public void setDescription (final String s) { 186 try { 187 ((StatisticImpl)this.initial).setDescription(s); 188 } 189 catch(final Exception e) { 190 } 191 } 192 } 193 | Popular Tags |