1 19 20 package org.apache.excalibur.instrument.manager.impl; 21 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 25 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager; 26 import org.apache.excalibur.instrument.manager.CounterInstrumentListener; 27 28 34 class CounterInstrumentSample 35 extends AbstractInstrumentSample 36 implements CounterInstrumentListener 37 { 38 39 protected int m_count; 40 41 44 55 CounterInstrumentSample( InstrumentProxy instrumentProxy, 56 String name, 57 long interval, 58 int size, 59 String description, 60 long lease ) 61 { 62 super( instrumentProxy, name, interval, size, description, lease ); 63 64 m_count = 0; 66 } 67 68 71 76 public int getType() 77 { 78 return DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER; 79 } 80 81 89 public final int getInstrumentType() 90 { 91 return DefaultInstrumentManager.INSTRUMENT_TYPE_COUNTER; 92 } 93 94 101 public int getValueInner() 102 { 103 return m_count; 104 } 105 106 109 117 protected void advanceToNextSample( boolean reset ) 118 { 119 m_count = 0; 121 } 122 123 128 protected int getFillValue() 129 { 130 return 0; 131 } 132 133 144 protected void loadState( int value, Configuration state ) 145 throws ConfigurationException 146 { 147 m_count = value; 148 } 149 150 153 160 public void increment( String instrumentName, int count, long time ) 161 { 162 increment( count, time ); 164 } 165 166 169 175 private void increment( int count, long time ) 176 { 177 int sampleValue; 178 long sampleTime; 179 180 synchronized(this) 181 { 182 update( time, false ); 183 184 m_count += count; 185 186 sampleValue = m_count; 187 sampleTime = m_time; 188 } 189 190 updateListeners( sampleValue, sampleTime ); 191 } 192 } 193 | Popular Tags |