001: package org.objectweb.jonas.webapp.jonasadmin.monitoring;
002:
003: import java.io.IOException;
004:
005: import javax.management.ObjectName;
006: import javax.servlet.ServletException;
007: import javax.servlet.http.HttpServletRequest;
008: import javax.servlet.http.HttpServletResponse;
009:
010: import org.apache.struts.action.ActionForm;
011: import org.apache.struts.action.ActionForward;
012: import org.apache.struts.action.ActionMapping;
013: import org.objectweb.jonas.jmx.JonasManagementRepr;
014: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
015: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
016:
017: public class DisplayNodeInfoAction extends JonasBaseAction {
018:
019: public ActionForward executeAction(ActionMapping p_Mapping,
020: ActionForm p_Form, HttpServletRequest p_Request,
021: HttpServletResponse p_Response) throws IOException,
022: ServletException {
023: // Form used
024: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
025: .getAttribute(WhereAreYou.SESSION_NAME);
026: String sDomainName = oWhere.getCurrentDomainName();
027:
028: String serverName = oWhere.getCurrentJonasServerName();
029:
030: NodeInfoForm oForm = (NodeInfoForm) p_Form;
031: try {
032:
033: /*
034: * Server related info
035: */
036: oForm.setServerName(p_Request.getParameter("node"));
037:
038: ObjectName on = new ObjectName(sDomainName
039: + ":type=ServerProxy,name=" + oForm.getServerName());
040: try {
041: oForm.setState((String) JonasManagementRepr
042: .getAttribute(on, "State", serverName));
043: } catch (RuntimeException e) {
044: // Attibute missing
045: }
046: try {
047: oForm.setHostName((String) JonasManagementRepr
048: .getAttribute(on, "HostName", serverName));
049: } catch (RuntimeException e) {
050: // Attibute missing
051: }
052: try {
053: oForm.setAllThreadsCount((int) new Integer(
054: JonasManagementRepr.getAttribute(on,
055: "AllThreadsCount", serverName)
056: .toString()).intValue());
057: } catch (RuntimeException e) {
058: // Attibute missing
059: }
060: try {
061: oForm.setJavaVersion((String) JonasManagementRepr
062: .getAttribute(on, "JavaVersion", serverName));
063: } catch (RuntimeException e) {
064: // Attibute missing
065: }
066: try {
067: oForm.setJavaVendor((String) JonasManagementRepr
068: .getAttribute(on, "JavaVendor", serverName));
069: } catch (RuntimeException e) {
070: // Attibute missing
071: }
072: try {
073: oForm.setCurrentTotalMemory((int) new Integer(
074: JonasManagementRepr.getAttribute(on,
075: "CurrentTotalMemory", serverName)
076: .toString()).intValue());
077: } catch (RuntimeException e) {
078: // Attibute missing
079: }
080: try {
081: oForm.setCurrentUsedMemory((int) new Integer(
082: JonasManagementRepr.getAttribute(on,
083: "CurrentUsedMemory", serverName)
084: .toString()).intValue());
085: } catch (RuntimeException e) {
086: // Attibute missing
087: }
088: try {
089: oForm.setJOnASVersion((String) JonasManagementRepr
090: .getAttribute(on, "JOnASVersion", serverName));
091: } catch (RuntimeException e) {
092: // Attibute missing
093: }
094: try {
095: oForm.setProtocols((String) JonasManagementRepr
096: .getAttribute(on, "Protocols", serverName));
097: } catch (RuntimeException e) {
098: // Attibute missing
099: }
100: try {
101: oForm.setConnectionUrl((String) JonasManagementRepr
102: .getAttribute(on, "ConnectionUrl", serverName));
103: } catch (RuntimeException e) {
104: // Attibute missing
105: }
106: /*
107: * JDK5
108: */
109:
110: /*
111: * Tomcat
112: */
113: try {
114: oForm.setTomcat(getBooleanAttribute(on, "Tomcat"));
115: if (oForm.getTomcat()) {
116: oForm
117: .setMaxThreadsByConnectorTomcat(getIntegerAttribute(
118: on, "MaxThreadsByConnectorTomcat"));
119: oForm
120: .setCurrentThreadCountByConnectorTomcat(getIntegerAttribute(
121: on,
122: "CurrentThreadCountByConnectorTomcat"));
123: oForm
124: .setCurrentThreadBusyByConnectorTomcat(getIntegerAttribute(
125: on,
126: "CurrentThreadBusyByConnectorTomcat"));
127: oForm
128: .setBytesReceivedByConnectorTomcat(getLongAttribute(
129: on,
130: "BytesReceivedByConnectorTomcat"));
131: oForm
132: .setBytesSentByConnectorTomcat(getLongAttribute(
133: on, "BytesSentByConnectorTomcat"));
134: oForm
135: .setErrorCountByConnectorTomcat(getIntegerAttribute(
136: on, "ErrorCountByConnectorTomcat"));
137: oForm
138: .setProcessingTimeByConnectorTomcat(getLongAttribute(
139: on,
140: "ProcessingTimeByConnectorTomcat"));
141: oForm
142: .setRequestCountByConnectorTomcat(getIntegerAttribute(
143: on, "RequestCountByConnectorTomcat"));
144: }
145: } catch (RuntimeException e) {
146: // Attibute missing
147: }
148: /*
149: * Tx
150: */
151: try {
152: oForm.setTransaction(getBooleanAttribute(on,
153: "Transaction"));
154: if (oForm.getTransaction()) {
155: oForm
156: .setTotalBegunTransactions(getIntegerAttribute(
157: on, "TotalBegunTransactions"));
158: oForm
159: .setTotalCommittedTransactions(getIntegerAttribute(
160: on, "TotalCommittedTransactions"));
161: oForm
162: .setTotalCurrentTransactions(getIntegerAttribute(
163: on, "TotalCurrentTransactions"));
164: oForm
165: .setTotalExpiredTransactions(getIntegerAttribute(
166: on, "TotalExpiredTransactions"));
167: oForm
168: .setTotalRolledbackTransactions(getIntegerAttribute(
169: on, "TotalExpiredTransactions"));
170: }
171: } catch (RuntimeException e) {
172: // Attibute missing
173: }
174: /*
175: * Worker Pool
176: */
177: try {
178: oForm.setWorkers(getBooleanAttribute(on, "Workers"));
179: if (oForm.getWorkers()) {
180: oForm.setCurrentWorkerPoolSize(getIntegerAttribute(
181: on, "CurrentWorkerPoolSize"));
182: oForm.setMaxWorkerPoolSize(getIntegerAttribute(on,
183: "MaxWorkerPoolSize"));
184: oForm.setMinWorkerPoolSize(getIntegerAttribute(on,
185: "MinWorkerPoolSize"));
186: }
187: } catch (RuntimeException e) {
188: // Attibute missing
189: }
190: /*
191: * JCA
192: */
193: try {
194: oForm.setJcaConnection(getBooleanAttribute(on,
195: "JcaConnection"));
196: if (oForm.getJcaConnection()) {
197: oForm
198: .setConnectionFailuresJCAConnection(getIntegerAttribute(
199: on,
200: "ConnectionFailuresJCAConnection"));
201: oForm
202: .setConnectionLeaksJCAConnection(getIntegerAttribute(
203: on, "ConnectionLeaksJCAConnection"));
204: oForm
205: .setCurrentBusyJCAConnection(getIntegerAttribute(
206: on, "CurrentBusyJCAConnection"));
207: oForm
208: .setCurrentOpenedJCAConnection(getIntegerAttribute(
209: on, "CurrentOpenedJCAConnection"));
210: oForm
211: .setRejectedOpenJCAConnection(getIntegerAttribute(
212: on, "RejectedOpenJCAConnection"));
213: oForm
214: .setServedOpenJCAConnection(getIntegerAttribute(
215: on, "ServedOpenJCAConnection"));
216: oForm
217: .setWaiterCountJCAConnection(getIntegerAttribute(
218: on, "WaiterCountJCAConnection"));
219: oForm.setWaitingTimeJCAConnection(getLongAttribute(
220: on, "WaitingTimeJCAConnection"));
221: }
222: } catch (Exception e) {
223: // Attibute missing
224: }
225: /*
226: * JDBC
227: */
228: try {
229: oForm.setJdbcDatasource(getBooleanAttribute(on,
230: "JdbcDatasource"));
231: if (oForm.getJdbcDatasource()) {
232: oForm
233: .setConnectionFailuresJDBCDatasource(getIntegerAttribute(
234: on,
235: "ConnectionFailuresJDBCResource"));
236: oForm
237: .setConnectionLeaksJDBCDatasource(getIntegerAttribute(
238: on, "ConnectionLeaksJDBCResource"));
239: oForm
240: .setCurrentBusyJDBCDatasource(getIntegerAttribute(
241: on, "CurrentBusyJDBCResource"));
242: oForm
243: .setCurrentOpenedJDBCDatasource(getIntegerAttribute(
244: on, "CurrentOpenedJDBCResource"));
245: oForm
246: .setRejectedOpenJDBCDatasource(getIntegerAttribute(
247: on, "RejectedOpenJDBCResource"));
248: oForm
249: .setServedOpenJDBCDatasource(getIntegerAttribute(
250: on, "ServedOpenJDBCResource"));
251: oForm
252: .setWaiterCountJDBCDatasource(getIntegerAttribute(
253: on, "WaiterCountJDBCResource"));
254: oForm
255: .setWaitingTimeJDBCDatasource(getLongAttribute(
256: on, "WaitingTimeJDBCResource"));
257: }
258: } catch (RuntimeException e) {
259: // Attibute missing
260: }
261: /*
262: * JMS
263: */
264: try {
265: oForm.setJmsJoram(getBooleanAttribute(on, "JmsJoram"));
266: if (oForm.getJmsJoram()) {
267: oForm
268: .setJmsQueuesNbMsgsDeliverSinceCreation(getIntegerAttribute(
269: on,
270: "JmsQueuesNbMsgsDeliverSinceCreation"));
271: oForm
272: .setJmsQueuesNbMsgsReceiveSinceCreation(getIntegerAttribute(
273: on,
274: "JmsQueuesNbMsgsReceiveSinceCreation"));
275: int jmsQueuesNbMsgsSendToDMQSinceCreation = getIntegerAttribute(
276: on, "JmsQueuesNbMsgsSendToDMQSinceCreation");
277: oForm
278: .setJmsQueuesNbMsgsSendToDMQSinceCreation(jmsQueuesNbMsgsSendToDMQSinceCreation);
279:
280: oForm
281: .setJmsTopicsNbMsgsDeliverSinceCreation(getIntegerAttribute(
282: on,
283: "JmsTopicsNbMsgsDeliverSinceCreation"));
284: oForm
285: .setJmsTopicsNbMsgsReceiveSinceCreation(getIntegerAttribute(
286: on,
287: "JmsTopicsNbMsgsReceiveSinceCreation"));
288: int jmsTopicsNbMsgsSendToDMQSinceCreation = getIntegerAttribute(
289: on, "JmsTopicsNbMsgsSendToDMQSinceCreation");
290: oForm
291: .setJmsTopicsNbMsgsSendToDMQSinceCreation(jmsTopicsNbMsgsSendToDMQSinceCreation);
292: oForm
293: .setJmsNbMsgsSendToDMQSinceCreation(jmsQueuesNbMsgsSendToDMQSinceCreation
294: + jmsTopicsNbMsgsSendToDMQSinceCreation);
295: }
296: } catch (RuntimeException e) {
297: // Attibute missing
298: }
299: /*
300: * EJB
301: */
302: try {
303: oForm.setCurrentNumberOfEJB(getIntegerAttribute(on,
304: "CurrentNumberOfEJB"));
305: oForm.setCurrentNumberOfEntity(getIntegerAttribute(on,
306: "CurrentNumberOfEntityBean"));
307: oForm.setCurrentNumberOfMDB(getIntegerAttribute(on,
308: "CurrentNumberOfMDB"));
309: oForm.setCurrentNumberOfSBF(getIntegerAttribute(on,
310: "CurrentNumberOfSBF"));
311: oForm.setCurrentNumberOfSBL(getIntegerAttribute(on,
312: "CurrentNumberOfSBL"));
313: } catch (RuntimeException e) {
314: // Attibute missing
315: }
316:
317: } catch (Throwable t) {
318: addGlobalError(t);
319: saveErrors(p_Request, m_Errors);
320: return (p_Mapping.findForward("Global Error"));
321: }
322:
323: // Forward to the jsp.
324: return (p_Mapping.findForward("DisplayNode"));
325: }
326: }
|