Author: channa
Date: Sun Jan 20 09:42:34 2008
New Revision: 12546
Log:
Adding a monitor status check to poll if the server is running and an MBean
attribute to get/set this value.
Modified:
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/InstanceMonitor.java
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/JMXClient.java
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitor.java
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitorMBean.java
trunk/commons/monitor/modules/server/src/main/resources/mbeans-descriptor.xml
Modified:
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/InstanceMonitor.java
==============================================================================
---
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/InstanceMonitor.java
(original)
+++
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/InstanceMonitor.java
Sun Jan 20 09:42:34 2008
@@ -319,11 +319,15 @@
private void refreshStatus() {
// If we aren't connected, we can't check, so proceed only if we are.
if (jmxClient.isConnected()) {
- // The server status check can only result in a yes/no answer.
- if (jmxClient.isServerErrorFree()) {
- setStatus(ServerState.RUNNING);
+ // Check if the server is running and if it's error free.
+ if (jmxClient.isServerRunning()) {
+ if (jmxClient.isServerErrorFree()) {
+ setStatus(ServerState.RUNNING);
+ } else {
+ setStatus(ServerState.ERROR);
+ }
} else {
- setStatus(ServerState.ERROR);
+ setStatus(ServerState.STOPPED);
}
} else {
if (jmxClient.getHasConnected()) {
Modified:
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/JMXClient.java
==============================================================================
---
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/JMXClient.java
(original)
+++
trunk/commons/monitor/modules/client/src/main/java/org/wso2/monitor/JMXClient.java
Sun Jan 20 09:42:34 2008
@@ -296,6 +296,29 @@
}
/**
+ * Gets the run status of the monitored server.
+ *
+ * @return Messages from the server.
+ */
+ public boolean isServerRunning() {
+ Boolean running = false;
+
+ try {
+ log.debug("Getting status.");
+ running = (Boolean) serverConnection.invoke(serverMgrName,
"isServerRunning", null, null);
+ } catch (InstanceNotFoundException e) {
+ log.error("Named bean not found", e);
+ } catch (MBeanException e) {
+ log.error("MBean error", e);
+ } catch (ReflectionException e) {
+ log.error("Error invoking method", e);
+ } catch (IOException e) {
+ log.error("IO Error invoking method", e);
+ }
+ return running;
+ }
+
+ /**
* Implementation of the NotificationListener's method which handles
notifications. Currently
* just displays the recieved message.
*
Modified:
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitor.java
==============================================================================
---
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitor.java
(original)
+++
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitor.java
Sun Jan 20 09:42:34 2008
@@ -17,7 +17,6 @@
import org.apache.log4j.Logger;
import org.apache.log4j.LogManager;
-import org.jdesktop.jdic.tray.TrayIcon;
import java.util.ArrayList;
import javax.management.MBeanServer;
@@ -35,6 +34,7 @@
public class ServerMonitor extends NotificationBroadcasterSupport implements
ServerMonitorMBean {
protected Logger log = LogManager.getLogger(getClass());
private long notificationSeqNum = 1;
+ private boolean serverRunning;
/**
* Obtains an instance of the MBean Server and registers self as an MBean.
@@ -101,4 +101,20 @@
return beanServer;
}
+
+ /**
+ * Indicates if the monitored server is running.
+ * @return true if the server is running.
+ */
+ public boolean isServerRunning() {
+ return serverRunning;
+ }
+
+ /**
+ * Used to set the server status indication.
+ * @param serverRunning true to indicate that the server is running,
+ */
+ public void setServerRunning(boolean serverRunning) {
+ this.serverRunning = serverRunning;
+ }
}
Modified:
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitorMBean.java
==============================================================================
---
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitorMBean.java
(original)
+++
trunk/commons/monitor/modules/server/src/main/java/org/wso2/monitor/mbeans/ServerMonitorMBean.java
Sun Jan 20 09:42:34 2008
@@ -34,4 +34,16 @@
* @param severity Used to specify message severity.
*/
public void notifyMonitor(String title, String message, int severity);
+
+ /**
+ * Indicates if the monitored server is running.
+ * @return true if the server is running.
+ */
+ public boolean isServerRunning();
+
+ /**
+ * Used to set the server status indication.
+ * @param serverRunning true to indicate that the server is running,
+ */
+ public void setServerRunning(boolean serverRunning);
}
Modified:
trunk/commons/monitor/modules/server/src/main/resources/mbeans-descriptor.xml
==============================================================================
---
trunk/commons/monitor/modules/server/src/main/resources/mbeans-descriptor.xml
(original)
+++
trunk/commons/monitor/modules/server/src/main/resources/mbeans-descriptor.xml
Sun Jan 20 09:42:34 2008
@@ -24,5 +24,20 @@
description="Used to specify message severity."
type="int"/>
</operation>
+
+ <operation name="isServerRunning"
+ description="Indicates if the monitored server is running."
+ impact="ACTION"
+ return="boolean">
+ </operation>
+
+ <operation name="setServerRunning"
+ description="Sets the server status indication."
+ impact="ACTION"
+ return="void">
+ <parameter name="serverRunning"
+ description="Used to specify server status."
+ type="boolean"/>
+ </operation>
</mbean>
</mbeans-descriptors>
\ No newline at end of file
_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev