01: package com.sun.portal.rproxy.monitoring;
02:
03: import com.sun.portal.monitoring.Subsystem;
04: import com.sun.portal.monitoring.statistics.*;
05: import com.sun.portal.rproxy.monitoring.statistics.CountStatisticSupport;
06: import com.sun.portal.rproxy.monitoring.util.RProxyEvent;
07: import com.sun.portal.util.SRAEvent;
08:
09: import java.util.Map;
10:
11: /**
12: * author: Noble Paul
13: * Date: Feb 7, 2005, 10:30:12 AM
14: */
15: public class RProxyRequestsStatistic extends RProxyStatisticBase {
16: public static final String LOGIN_REDIRECTS = "LoginRedirects";
17: public static final String PDC_AUTH_REQ = "PDCAuthenticationRequests";
18: public static final String SERVER_ERR = "ServerErrors";
19: public static final String TOTAL_REQ = "TotalRequests";
20: public static final String TOTAL_RESP = "TotalResponses";
21: public static final String TOTAL_EXTERNAL_URL_REQS = "TotalExternalURLRequests";
22:
23: private static CountStatisticSupport loginRedirect = new CountStatisticSupport();
24: private static CountStatisticSupport pdcAuthReq = new CountStatisticSupport();
25: private static CountStatisticSupport serverError = new CountStatisticSupport();
26: private static CountStatisticSupport totalReq = new CountStatisticSupport();
27: private static CountStatisticSupport totalResp = new CountStatisticSupport();
28: private static CountStatisticSupport totalExternalUrlReq = new CountStatisticSupport();
29:
30: public RProxyRequestsStatistic(Subsystem subsystem) {
31: super (subsystem);
32: }
33:
34: protected String getMbeanType() {
35: return "RProxy";
36: }
37:
38: protected String[] getMBeanNames() {
39: return new String[] { LOGIN_REDIRECTS, PDC_AUTH_REQ,
40: SERVER_ERR, TOTAL_REQ, TOTAL_EXTERNAL_URL_REQS,
41: TOTAL_RESP };
42: }
43:
44: protected StatisticImpl[] getStatistics() {
45: return new StatisticImpl[] { loginRedirect, pdcAuthReq,
46: serverError, totalReq, totalExternalUrlReq, totalResp };
47: }
48:
49: protected StatisticWrapper getStatistic(String name) {
50: return getCountStatistic(name);
51: }
52:
53: public void handleEvent(SRAEvent event, Object obj) {
54: if (event == RProxyEvent.EXTERNAL_URL_REQ) {
55: totalExternalUrlReq.increment();
56: return;
57: }
58: if (event == RProxyEvent.SERVER_ERROR) {
59: serverError.increment();
60: return;
61: }
62: if (event == RProxyEvent.PDC_AUTH_REQ) {
63: pdcAuthReq.increment();
64: return;
65: }
66: if (event == RProxyEvent.LOGIN_REDIRECT) {
67: loginRedirect.increment();
68: return;
69: }
70: if (event == RProxyEvent.NEW_REQ) {
71: totalReq.increment();
72: return;
73: }
74: if (event == RProxyEvent.RESPONSE_SENT) {
75: totalResp.increment();
76: }
77: }
78:
79: public SRAEvent[] getInterestedEvents() {
80: return new SRAEvent[] { RProxyEvent.EXTERNAL_URL_REQ,
81: RProxyEvent.SERVER_ERROR, RProxyEvent.PDC_AUTH_REQ,
82: RProxyEvent.LOGIN_REDIRECT, RProxyEvent.NEW_REQ,
83: RProxyEvent.RESPONSE_SENT };
84: }
85: }
|