01: package com.sun.portal.rproxy.monitoring;
02:
03: import com.sun.portal.monitoring.statistics.*;
04: import com.sun.portal.monitoring.Subsystem;
05: import com.sun.portal.monitoring.utilities.ActivityTime;
06: import com.sun.portal.rproxy.monitoring.statistics.CountStatisticSupport;
07: import com.sun.portal.util.SRAEvent;
08:
09: /**
10: * author: Noble Paul
11: * Date: Feb 16, 2005, 5:27:44 PM
12: */
13: public class ISLoggingStatistics extends RProxyStatisticBase {
14: public static final String BYTES_SENT = "BytesSent";
15: public static final String PROCESS_TIME = "ProcessTime";
16: private static ActivityTime activityTime = new ActivityTime();
17:
18: private static CountStatisticSupport bytesSent = new CountStatisticSupport();
19: private static RollingAvgTimeStatisticImpl processTime = new RollingAvgTimeStatisticImpl();
20:
21: public ISLoggingStatistics(Subsystem subsystem) {
22: super (subsystem);
23: }
24:
25: protected String getMbeanType() {
26: return "ISLogging";
27: }
28:
29: protected String[] getMBeanNames() {
30: return new String[] { BYTES_SENT, PROCESS_TIME };
31: }
32:
33: protected StatisticImpl[] getStatistics() {
34: return new StatisticImpl[] { bytesSent, processTime };
35: }
36:
37: protected StatisticWrapper getStatistic(String name) {
38: if (PROCESS_TIME == name) {
39: return getRAStatistic(name);
40: } else {
41: return getCountStatistic(name);
42: }
43: }
44:
45: public void startWrite(Object o) {
46: bytesSent.increment(((Integer) o).intValue());
47: activityTime.mark();
48: }
49:
50: public void endWrite() {
51: processTime.setTime(activityTime.measure());
52:
53: }
54:
55: public void handleEvent(SRAEvent event, Object obj) {
56: if (event == SRAEvent.IS_LOGGING_END) {
57: endWrite();
58: } else if (event == SRAEvent.IS_LOGGING_START) {
59: startWrite(obj);
60: }
61: }
62:
63: public SRAEvent[] getInterestedEvents() {
64: return new SRAEvent[] { SRAEvent.IS_LOGGING_START,
65: SRAEvent.IS_LOGGING_END };
66: }
67: }
|