package com.sun.portal.rproxy.monitoring;
import com.sun.portal.monitoring.statistics.*;
import com.sun.portal.monitoring.Subsystem;
import com.sun.portal.monitoring.utilities.ActivityTime;
import com.sun.portal.rproxy.monitoring.statistics.CountStatisticSupport;
import com.sun.portal.util.SRAEvent;
/**
* author: Noble Paul
* Date: Feb 16, 2005, 5:27:44 PM
*/
public class ISLoggingStatistics extends RProxyStatisticBase{
public static final String BYTES_SENT ="BytesSent";
public static final String PROCESS_TIME ="ProcessTime";
private static ActivityTime activityTime = new ActivityTime();
private static CountStatisticSupport bytesSent = new CountStatisticSupport();
private static RollingAvgTimeStatisticImpl processTime = new RollingAvgTimeStatisticImpl();
public ISLoggingStatistics(Subsystem subsystem) {
super(subsystem);
}
protected String getMbeanType() {
return "ISLogging";
}
protected String[] getMBeanNames() {
return new String[]{BYTES_SENT,PROCESS_TIME};
}
protected StatisticImpl[] getStatistics() {
return new StatisticImpl[]{bytesSent,processTime};
}
protected StatisticWrapper getStatistic(String name) {
if(PROCESS_TIME == name){
return getRAStatistic(name);
}else{
return getCountStatistic(name);
}
}
public void startWrite(Object o){
bytesSent.increment(((Integer)o).intValue() );
activityTime.mark();
}
public void endWrite(){
processTime.setTime(activityTime.measure());
}
public void handleEvent(SRAEvent event, Object obj) {
if (event == SRAEvent.IS_LOGGING_END) {
endWrite();
} else if (event == SRAEvent.IS_LOGGING_START) {
startWrite(obj);
}
}
public SRAEvent[] getInterestedEvents() {
return new SRAEvent[]{SRAEvent.IS_LOGGING_START,SRAEvent.IS_LOGGING_END};
}
}
|