1 23 24 28 29 34 35 package com.sun.enterprise.admin.monitor.stats; 36 37 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 38 39 46 47 51 public class AverageRangeStatisticImpl implements 52 AverageRangeStatistic { 53 54 private BoundedRangeStatisticImpl boundedRangeStatistic = null; 55 private long numberOfSamples; 56 private long runningTotal; 57 58 59 76 public AverageRangeStatisticImpl(long curVal, long highMark, long lowMark, 77 long upper, long lower, String name, 78 String unit, String desc, long startTime, 79 long sampleTime, long numberOfSamples, 80 long runningTotal) { 81 82 boundedRangeStatistic = new BoundedRangeStatisticImpl(curVal, highMark, lowMark, 83 upper, lower, name, 84 unit, desc, startTime, 85 sampleTime); 86 87 this.numberOfSamples = numberOfSamples; 88 this.runningTotal = runningTotal; 89 } 90 91 97 public AverageRangeStatisticImpl(BoundedRangeStatisticImpl stats, 98 long numberOfSamples, long runningTotal) { 99 boundedRangeStatistic = stats; 100 this.numberOfSamples = numberOfSamples; 101 this.runningTotal = runningTotal; 102 } 103 104 public long getCurrent() { 105 return boundedRangeStatistic.getCurrent(); 106 } 107 108 public String getDescription() { 109 return boundedRangeStatistic.getDescription(); 110 } 111 112 public long getHighWaterMark() { 113 return boundedRangeStatistic.getHighWaterMark(); 114 } 115 116 public long getLastSampleTime() { 117 return boundedRangeStatistic.getLastSampleTime(); 118 } 119 120 public long getLowWaterMark() { 121 return boundedRangeStatistic.getLowWaterMark(); 122 } 123 128 129 public String getName() { 130 return boundedRangeStatistic.getName(); 131 } 132 133 public long getStartTime() { 134 return boundedRangeStatistic.getStartTime(); 135 } 136 137 public String getUnit() { 138 return boundedRangeStatistic.getUnit(); 139 } 140 145 146 public long getAverage() { 147 if(numberOfSamples == 0) { 148 return -1; 149 } else { 150 return runningTotal / numberOfSamples; 151 } 152 } 153 156 public void setDescription(final String desc) { 157 this.boundedRangeStatistic.setDescription(desc); 158 } 159 160 } 161 | Popular Tags |