Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jbossmx.cluster.watchdog.mbean
Class Watchdog  view Watchdog download Watchdog.java

java.lang.Object
  extended byorg.jbossmx.cluster.watchdog.mbean.Startable
      extended byorg.jbossmx.cluster.watchdog.mbean.Watchdog
All Implemented Interfaces:
java.util.EventListener, javax.management.MBeanRegistration, javax.management.NotificationListener, org.jbossmx.cluster.watchdog.util.SkinableMBean, StartableMBean, WatchdogMBean

public class Watchdog
extends Startable
implements WatchdogMBean, javax.management.MBeanRegistration, javax.management.NotificationListener

The Watchdog class monitors all the StartableMBean MBeans on a JMX Agent.


Nested Class Summary
private  class Watchdog.ObjectNameAndValue
          Wrapper class for storing a Watched MBean's ObjectInstance and running state.
 
Field Summary
private static int DEFAULT_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART
          The default number of times to attempt agent restart
private static int DEFAULT_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART
          The default number of times to attempt machine restart
private static int DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER
          The default number of times to attempt MBean reregister
private static int DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART
          The default number of times to attempt MBean restart
private static org.jboss.logging.Logger LOG
           
private  org.jbossmx.cluster.watchdog.agent.AgentRemoteInterface m_agentRemoteInterface
          The remote interface of the JMX Agent being watched
private  long m_granularity
          The amount of time to wait between watching runs
private  boolean m_isWatching
          The current watching state
private  java.util.HashSet m_mbeansWatched
           
private  org.jbossmx.cluster.watchdog.util.MirroringServiceMBean m_mirroringServiceMBean
           
private  javax.management.ObjectName m_mirroringServiceMBeanObjectName
           
private  java.lang.String m_myAgentRmiBinding
          The RMI Binding of the JMX Agent this Watchdog is running in
private  int m_numRunning
          The number of MBeans that are in a RUNNING state
private  int m_numTimesToAttemptAgentRestart
          The number of times to attempt Agent restart
private  int m_numTimesToAttemptMachineRestart
          The number of times to attempt machine restart
private  int m_numTimesToAttemptMBeanReregister
          The number of times to attempt MBean reregister
private  int m_numTimesToAttemptMBeanRestart
          The number of times to attempt MBean restart
private  int m_numWatched
          The number of MBeans being watched
private  javax.management.ObjectName m_objectName
          The ObjectName of this Watchdog
private  org.jboss.jmx.adaptor.rmi.RMIAdaptor m_rmiAdaptor
           
(package private)  java.lang.String m_rmiAgentBinding
          The resolved RMI Binding of the watched agent, eg "/machineName/JMSAgent"
private  javax.management.MBeanServer m_server
          The MBeanServer this watchdog is running in
private  long m_timeLastDidSomething
          The System time that something was last done
private  long m_timeLastWatched
          The System time that watching last occured
private  long m_timeStartedWatching
          The System time that watching started
(package private)  java.lang.String m_unresolvedRmiAgentBinding
          The unresolved RMI Binding of the watched agent, eg "{/JMSAgent}"
private  java.util.Map m_watchdogCorrectiveActions
          A map of watched MBeans to CorrectiveActions
private  javax.management.ObjectName m_watchdogEventManagerObjectName
           
private  WatchdogEventManagerRemoteInterface m_watchdogEventManagerRemoteInterface
           
private  javax.management.ObjectName m_watchedDomainObjectName
          The domain that is being watched on the remote JMX Agent
private  java.lang.Object m_watchingLock
          An Object used for synchoronization on read/writes to m_isWatching
private  java.lang.Object m_watchingStartStopLock
          An Object used for synchoronization on calls to startWatching and stopWatching
private  java.lang.Thread m_watchingThread
          The Thread that does the watching
private static int MAX_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART
          The maximum number of times to attempt agent restart
private static int MAX_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART
          The maximum number of times to attempt machine restart
private static int MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER
          The maximum number of times to attempt MBean reregister
private static int MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART
          The maximum number of times to attempt MBean restart
 
Fields inherited from class org.jbossmx.cluster.watchdog.mbean.Startable
FAILED, FAILED_TO_START, FAILED_TO_STOP, m_sStateStrings, RESTARTING, RUNNING, STARTING, STOPPED, STOPPING
 
Constructor Summary
Watchdog(java.lang.String unresolvedWatchedRmiAgentBinding, java.lang.String watchedDomain, java.lang.String myAgentRmiBinding)
          Constructor for Watchdog
Watchdog(java.lang.String rmiAgentBinding, java.lang.String watchedDomain, java.lang.String myAgentRmiAgentBinding, long granularity)
          Constructor for Watchdog
Watchdog(java.lang.String rmiAgentBinding, java.lang.String watchedDomain, java.lang.String myAgentRmiAgentBinding, long granularity, int numTimesToAttemptMBeanRestart, int numTimesToAttemptMBeanReregister, int numTimesToAttemptAgentRestart, int numTimesToAttemptMachineRestart)
          Constructor for Watchdog
 
Method Summary
private  void addWatchedMBean(javax.management.ObjectName objectName)
           
private  boolean anyMBeanHasCorrectiveAction(java.util.Set mbeans, int matchingCorrectiveAction)
          Determines whether any of mbean has the matchingCorrectiveAction Corrective Action
 void dispatchEvent(WatchdogEvent watchdogEvent)
          Dispatch a WatchdgoEvent to all WatchdogListener listening.
private  void doWatching()
          Worker method called by startWatching to perform watching 'runs'.
private  javax.management.ObjectName generateMirroringServiceObjectName()
           
private  org.jbossmx.cluster.watchdog.agent.AgentRemoteInterface getAgentRemoteInterface()
          Gets the remote interface of the JMX Agent being watched.
 boolean getAllRunning()
          Get whether all the StartableMBeans being watched are running.
private  boolean getBooleanValue(java.lang.Object object)
          Casts object to a Boolean, returns false if object isn't a Boolean
private  WatchdogCorrectiveAction getEntry(javax.management.ObjectName objectName)
          Obtains the CorrectiveAction associated with an ObjectInstance.
 long getGranularity()
          Get the amount of time in milliseconds between watching.
 int getMaxNumTimesToAttemptAgentRestart()
          Gets the maximum number of times to attempt an Agent restart
 int getMaxNumTimesToAttemptMachineRestart()
          Gets the maximum number of times to attempt a machine restart
 int getMaxNumTimesToAttemptMBeanReregister()
          Gets the maximum number of times to attempt an MBean reregister
 int getMaxNumTimesToAttemptMBeanRestart()
          Gets the maximum number of times to attempt an MBean restart
private  java.util.Set getMBeanWatched()
           
private  org.jbossmx.cluster.watchdog.util.MirroringServiceMBean getMirroringServiceMBean()
           
private  javax.management.ObjectName getMirroringServiceMBeanObjectName()
           
private  int getNonNegativeMinimum(int a, int b)
          Utility function for trimDomain
 int getNumRunning()
          Gets the number of StartableMBeans that are running.
 int getNumStopped()
          Gets the number of StartableMBeans that are not running.
 int getNumTimesToAttemptAgentRestart()
          Gets the number of times to attempt Agent restart
 int getNumTimesToAttemptMachineRestart()
          Gets the number of times to attempt machine restart
 int getNumTimesToAttemptMBeanReregister()
          Gets the number of times to attempt MBean reregister
 int getNumTimesToAttemptMBeanRestart()
          Gets the number of times to attempt MBean restart
 int getNumWatched()
          Gets the number of StartableMBeans that are being watched.
private  java.lang.Class getObjectNameClass(javax.management.ObjectName objectName)
           
private  org.jboss.jmx.adaptor.rmi.RMIAdaptor getRMIAdaptor()
           
 java.lang.String getRmiAgentBinding()
          Gets the RMI Binding of the JMX Agent that is being watched.
 long getTimeLastDidSomething()
          Gets the last time something was done.
 long getTimeLastWatched()
          Gets the System time that the last watching run started.
 long getTimeStartedWatching()
          Gets the System time that watching started.
private  javax.management.ObjectName getWatchedDomainObjectName()
          Gets the Domain being watched
private  java.lang.Thread getWatchingThread()
          Gets the Thread that is doing the watching.
 void handleNotification(javax.management.Notification notification, java.lang.Object handback)
           
private  void handleRegisterNotification(javax.management.MBeanServerNotification mbeanServerNotification)
           
private  void handleUnregisterNotification(javax.management.MBeanServerNotification mbeanServerNotification)
           
protected  boolean hasMBeanFailed()
          Gets whether this Watchdog MBean has failed.
private  void initialiseCorrectiveActions()
          Initialise the Corrective Actions
private  void initialiseEventManager()
           
private  java.lang.Object invokeMethod(javax.management.ObjectName objectName, java.lang.String methodName)
          Invokes a method on an ObjectInstance
private  boolean invokeRestartMethod(Watchdog.ObjectNameAndValue objectNameAndValue)
          Invokes either restartMBean or startMBean methods on an ObjectInstance depending on whether the MBean is in a FAILED state or not.
private  boolean invokeStartMethod(javax.management.ObjectName objectName)
          Invokes the startMBean method on an ObjectInstance
protected  boolean isMBeanRunning()
          Gets whether this Watchdog MBean is running.
private  boolean isMBeanStateSuitableForWatching()
          Returns whether this Watchdog MBean is in a suitable state for Watching.
private  boolean isMirroringServiceMBeanRegistered()
           
private  boolean isRunning(javax.management.ObjectName objectName)
          Determines whether objectInstance is running by calling its 'retrieveMBeanState' method.
private  boolean isWatching()
          Determines whether this Watchdog is watching
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationDone)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
          Pre registers this MBean
private  void registerMirroringServiceMBean()
           
private  void removeWatchedMBean(javax.management.ObjectName objectName)
           
private  boolean requireAgentRestart(java.util.Set failingMBeans)
          Determines whether any of failingMBeans requires an Agent restart
private  boolean requireMachineReboot(java.util.Set failingMBeans)
          Determines whether any of failingMBeans requires a machine reboot
private  boolean reregisterMBean(javax.management.ObjectName objectName)
          Reregisters an MBean
private  void resetRmiAgentBinding()
          Resolves the incomplete RMI Binding of the Agent being watched.
private  void restartAgent()
          Restart the JMX Agent that is being watched.
protected  boolean restartMBeanImpl()
          Delegates to startMBeanImpl
 java.lang.String retrieveOneLiner(java.lang.String defaultString)
           
private  void setAgentRemoteInterface(org.jbossmx.cluster.watchdog.agent.AgentRemoteInterface agentRemoteInterface)
          Sets the remote interface of the JMX Agent being watched.
 void setGranularity(long granularity)
          Sets the amount of time in milliseconds between watching runs.
private  void setIsWatching(boolean isWatching)
          Sets whether this Watchdog is watching.
private  void setMirroringServiceMBean(org.jbossmx.cluster.watchdog.util.MirroringServiceMBean mirroringServiceMBean)
           
private  void setMirroringServiceMBeanObjectName(javax.management.ObjectName objectName)
           
 void setNumTimesToAttemptAgentRestart(int numTimesToAttemptAgentRestart)
          Sets the number of times to attempt Agent restart
 void setNumTimesToAttemptMachineRestart(int numTimesToAttemptMachineRestart)
          Sets the number of times to attempt machine restart
 void setNumTimesToAttemptMBeanReregister(int numTimesToAttemptMBeanReregister)
          Sets the number of times to attempt MBean reregister
 void setNumTimesToAttemptMBeanRestart(int numTimesToAttemptMBeanRestart)
          Sets the number of times to attempt MBean restart
private  void setRMIAdaptor(org.jboss.jmx.adaptor.rmi.RMIAdaptor rmiAdaptor)
           
private  void setRmiAgentBinding(java.lang.String rmiAgentBinding)
          Sets the RMI Binding of the Agent being watched
private  void setupTransientWatchdogData()
          Sets up some data used for watching which may change, for instance the RMI Binding of the Agent to be watched - the Agent may have been moved to another machine so the RMI Binding will have changed.
private  void setupWatchdogEventManager(javax.management.ObjectName objectName)
           
private  void setupWatchdogNumbers()
          Sets the number of MBeans that are being watched.
private  void setWatchedDomainObjectName(javax.management.ObjectName objectName)
          Sets the Domain being watched
private  void setWatchingThread(java.lang.Thread watchingThread)
          Sets the Thread that is doing the watching.
private  void startAgent()
          Starts the JMX Agent that this Watchdog is watching, if the Agent is running nothing will be done.
protected  boolean startMBeanImpl()
          Starts Watchdog, starts the Agent that is being watched (if necessary) then starts watching it.
private  void startMirroring()
           
private  void startWatching()
          Start watching the JMX Agent.
private  void stopAgent()
          Stops the JMX Agent that this watchdog is watching, if the Agent is not running then nothing will be done.
protected  boolean stopMBeanImpl()
          Stops Watchdog.
private  void stopMirroring()
           
private  void stopWatching()
          Stop Watching the JMX Agent.
private  void takeCorrectiveAction(java.util.Set failingMBeans)
          Takes corrective action on a Set of failed MBeans
private  void takeCorrectiveAction(Watchdog.ObjectNameAndValue objectNameAndValue)
          Take corrective action on a single ObjectInstance
private  void tearDownTransientWatchdogData()
          Sets all the transient data to null, done to prevent clients for using old data.
private  void testRMIAdaptor()
           
private  void ThrowInterruptedExceptionIfInterrupted()
          Throws an InterruptedException if isInterrupted is set on the current Thread.
private  java.lang.String trimDomain(java.lang.String input)
          Cleans up a String used to represent ObjectName domains
private  void unregisterMirroringServiceMBean()
           
private  void updateEntries(java.util.Set objectNames)
          Updates the associated Corrective Actions of all the MBeans in objectInstances
private  void updateEntry(javax.management.ObjectName objectName)
          Updates the associated Corrective Action of objectInstance by obtaining the running state of objectInstance
private  void updateTimeLastDidSomething()
          Updates the time that something was last done.
private  void updateTimeLastWatched()
          Updates the time watching last occured.
private  void updateTimeStartedWatching()
          Updates the time watching starts.
private  void watchOnce()
          Performs a single watching run.
 
Methods inherited from class org.jbossmx.cluster.watchdog.mbean.Startable
getMBeanStateString, getStateAsString, restartMBean, retrieveMBeanState, simulateFailure, startMBean, stopMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jbossmx.cluster.watchdog.mbean.StartableMBean
getMBeanStateString, restartMBean, retrieveMBeanState, simulateFailure, startMBean, stopMBean
 

Field Detail

m_unresolvedRmiAgentBinding

java.lang.String m_unresolvedRmiAgentBinding
The unresolved RMI Binding of the watched agent, eg "{/JMSAgent}"


m_rmiAgentBinding

java.lang.String m_rmiAgentBinding
The resolved RMI Binding of the watched agent, eg "/machineName/JMSAgent"


m_watchedDomainObjectName

private javax.management.ObjectName m_watchedDomainObjectName
The domain that is being watched on the remote JMX Agent


m_granularity

private long m_granularity
The amount of time to wait between watching runs


m_agentRemoteInterface

private org.jbossmx.cluster.watchdog.agent.AgentRemoteInterface m_agentRemoteInterface
The remote interface of the JMX Agent being watched


m_server

private javax.management.MBeanServer m_server
The MBeanServer this watchdog is running in


m_objectName

private javax.management.ObjectName m_objectName
The ObjectName of this Watchdog


m_myAgentRmiBinding

private java.lang.String m_myAgentRmiBinding
The RMI Binding of the JMX Agent this Watchdog is running in


m_rmiAdaptor

private org.jboss.jmx.adaptor.rmi.RMIAdaptor m_rmiAdaptor

m_mirroringServiceMBean

private org.jbossmx.cluster.watchdog.util.MirroringServiceMBean m_mirroringServiceMBean

m_mirroringServiceMBeanObjectName

private javax.management.ObjectName m_mirroringServiceMBeanObjectName

m_watchdogCorrectiveActions

private java.util.Map m_watchdogCorrectiveActions
A map of watched MBeans to CorrectiveActions


m_numTimesToAttemptMBeanRestart

private int m_numTimesToAttemptMBeanRestart
The number of times to attempt MBean restart


m_numTimesToAttemptMBeanReregister

private int m_numTimesToAttemptMBeanReregister
The number of times to attempt MBean reregister


m_numTimesToAttemptAgentRestart

private int m_numTimesToAttemptAgentRestart
The number of times to attempt Agent restart


m_numTimesToAttemptMachineRestart

private int m_numTimesToAttemptMachineRestart
The number of times to attempt machine restart


m_numWatched

private int m_numWatched
The number of MBeans being watched


m_numRunning

private int m_numRunning
The number of MBeans that are in a RUNNING state


m_timeStartedWatching

private long m_timeStartedWatching
The System time that watching started


m_timeLastWatched

private long m_timeLastWatched
The System time that watching last occured


m_timeLastDidSomething

private long m_timeLastDidSomething
The System time that something was last done


m_watchingLock

private java.lang.Object m_watchingLock
An Object used for synchoronization on read/writes to m_isWatching


m_watchingStartStopLock

private java.lang.Object m_watchingStartStopLock
An Object used for synchoronization on calls to startWatching and stopWatching


m_isWatching

private boolean m_isWatching
The current watching state


m_watchingThread

private java.lang.Thread m_watchingThread
The Thread that does the watching


m_mbeansWatched

private java.util.HashSet m_mbeansWatched

m_watchdogEventManagerRemoteInterface

private WatchdogEventManagerRemoteInterface m_watchdogEventManagerRemoteInterface

m_watchdogEventManagerObjectName

private javax.management.ObjectName m_watchdogEventManagerObjectName

DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART

private static final int DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART
The default number of times to attempt MBean restart

See Also:
Constant Field Values

DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER

private static final int DEFAULT_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER
The default number of times to attempt MBean reregister

See Also:
Constant Field Values

DEFAULT_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART

private static final int DEFAULT_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART
The default number of times to attempt agent restart

See Also:
Constant Field Values

DEFAULT_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART

private static final int DEFAULT_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART
The default number of times to attempt machine restart

See Also:
Constant Field Values

MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART

private static final int MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_RESTART
The maximum number of times to attempt MBean restart

See Also:
Constant Field Values

MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER

private static final int MAX_NUM_TIMES_TO_ATTEMPT_MBEAN_REREGISTER
The maximum number of times to attempt MBean reregister

See Also:
Constant Field Values

MAX_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART

private static final int MAX_NUM_TIMES_TO_ATTEMPT_AGENT_RESTART
The maximum number of times to attempt agent restart

See Also:
Constant Field Values

MAX_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART

private static final int MAX_NUM_TIMES_TO_ATTEMPT_MACHINE_RESTART
The maximum number of times to attempt machine restart

See Also:
Constant Field Values

LOG

private static org.jboss.logging.Logger LOG
Constructor Detail

Watchdog

public Watchdog(java.lang.String unresolvedWatchedRmiAgentBinding,
                java.lang.String watchedDomain,
                java.lang.String myAgentRmiBinding)
         throws javax.management.JMException,
                java.rmi.RemoteException,
                java.net.MalformedURLException,
                java.rmi.NotBoundException
Constructor for Watchdog


Watchdog

public Watchdog(java.lang.String rmiAgentBinding,
                java.lang.String watchedDomain,
                java.lang.String myAgentRmiAgentBinding,
                long granularity)
         throws javax.management.JMException,
                java.rmi.RemoteException,
                java.net.MalformedURLException,
                java.rmi.NotBoundException
Constructor for Watchdog


Watchdog

public Watchdog(java.lang.String rmiAgentBinding,
                java.lang.String watchedDomain,
                java.lang.String myAgentRmiAgentBinding,
                long granularity,
                int numTimesToAttemptMBeanRestart,
                int numTimesToAttemptMBeanReregister,
                int numTimesToAttemptAgentRestart,
                int numTimesToAttemptMachineRestart)
         throws javax.management.JMException,
                java.rmi.RemoteException,
                java.net.MalformedURLException,
                java.rmi.NotBoundException
Constructor for Watchdog

Method Detail

retrieveOneLiner

public java.lang.String retrieveOneLiner(java.lang.String defaultString)
Specified by:
retrieveOneLiner in interface org.jbossmx.cluster.watchdog.util.SkinableMBean
Overrides:
retrieveOneLiner in class Startable

startMBeanImpl

protected boolean startMBeanImpl()
                          throws java.lang.Exception
Starts Watchdog, starts the Agent that is being watched (if necessary) then starts watching it.

Specified by:
startMBeanImpl in class Startable

stopMBeanImpl

protected boolean stopMBeanImpl()
                         throws java.lang.Exception
Stops Watchdog. Doesn't not stop the Agent that is being watched.

Specified by:
stopMBeanImpl in class Startable

restartMBeanImpl

protected boolean restartMBeanImpl()
                            throws java.lang.Exception
Delegates to startMBeanImpl

Specified by:
restartMBeanImpl in class Startable

hasMBeanFailed

protected boolean hasMBeanFailed()
                          throws java.lang.Exception
Gets whether this Watchdog MBean has failed.

Specified by:
hasMBeanFailed in class Startable

isMBeanRunning

protected boolean isMBeanRunning()
                          throws java.lang.Exception
Gets whether this Watchdog MBean is running.


getRmiAgentBinding

public java.lang.String getRmiAgentBinding()
Gets the RMI Binding of the JMX Agent that is being watched.

Specified by:
getRmiAgentBinding in interface WatchdogMBean

getNumWatched

public int getNumWatched()
Gets the number of StartableMBeans that are being watched.

Specified by:
getNumWatched in interface WatchdogMBean

getNumRunning

public int getNumRunning()
Gets the number of StartableMBeans that are running.

Specified by:
getNumRunning in interface WatchdogMBean

getNumStopped

public int getNumStopped()
Gets the number of StartableMBeans that are not running. TODO: Change name of this, not running doesn't imply stopped, the mbeans can be in either FAILED, FAILED_TO_START, FAILED_TO_STOP, STARTING, STOPPING, RESTARTING, OR STOPPED states.

Specified by:
getNumStopped in interface WatchdogMBean

getAllRunning

public boolean getAllRunning()
Get whether all the StartableMBeans being watched are running.

Specified by:
getAllRunning in interface WatchdogMBean

getGranularity

public long getGranularity()
Get the amount of time in milliseconds between watching.

Specified by:
getGranularity in interface WatchdogMBean

setGranularity

public void setGranularity(long granularity)
Sets the amount of time in milliseconds between watching runs.

Specified by:
setGranularity in interface WatchdogMBean

getTimeStartedWatching

public long getTimeStartedWatching()
Gets the System time that watching started.

Specified by:
getTimeStartedWatching in interface WatchdogMBean

getTimeLastWatched

public long getTimeLastWatched()
Gets the System time that the last watching run started.

Specified by:
getTimeLastWatched in interface WatchdogMBean

getNumTimesToAttemptMBeanRestart

public int getNumTimesToAttemptMBeanRestart()
Gets the number of times to attempt MBean restart

Specified by:
getNumTimesToAttemptMBeanRestart in interface WatchdogMBean

getNumTimesToAttemptMBeanReregister

public int getNumTimesToAttemptMBeanReregister()
Gets the number of times to attempt MBean reregister

Specified by:
getNumTimesToAttemptMBeanReregister in interface WatchdogMBean

getNumTimesToAttemptAgentRestart

public int getNumTimesToAttemptAgentRestart()
Gets the number of times to attempt Agent restart

Specified by:
getNumTimesToAttemptAgentRestart in interface WatchdogMBean

getNumTimesToAttemptMachineRestart

public int getNumTimesToAttemptMachineRestart()
Gets the number of times to attempt machine restart

Specified by:
getNumTimesToAttemptMachineRestart in interface WatchdogMBean

setNumTimesToAttemptMBeanRestart

public void setNumTimesToAttemptMBeanRestart(int numTimesToAttemptMBeanRestart)
Sets the number of times to attempt MBean restart

Specified by:
setNumTimesToAttemptMBeanRestart in interface WatchdogMBean

setNumTimesToAttemptMBeanReregister

public void setNumTimesToAttemptMBeanReregister(int numTimesToAttemptMBeanReregister)
Sets the number of times to attempt MBean reregister

Specified by:
setNumTimesToAttemptMBeanReregister in interface WatchdogMBean

setNumTimesToAttemptAgentRestart

public void setNumTimesToAttemptAgentRestart(int numTimesToAttemptAgentRestart)
Sets the number of times to attempt Agent restart

Specified by:
setNumTimesToAttemptAgentRestart in interface WatchdogMBean

setNumTimesToAttemptMachineRestart

public void setNumTimesToAttemptMachineRestart(int numTimesToAttemptMachineRestart)
Sets the number of times to attempt machine restart

Specified by:
setNumTimesToAttemptMachineRestart in interface WatchdogMBean

getMaxNumTimesToAttemptMBeanRestart

public int getMaxNumTimesToAttemptMBeanRestart()
Gets the maximum number of times to attempt an MBean restart

Specified by:
getMaxNumTimesToAttemptMBeanRestart in interface WatchdogMBean

getMaxNumTimesToAttemptMBeanReregister

public int getMaxNumTimesToAttemptMBeanReregister()
Gets the maximum number of times to attempt an MBean reregister

Specified by:
getMaxNumTimesToAttemptMBeanReregister in interface WatchdogMBean

getMaxNumTimesToAttemptAgentRestart

public int getMaxNumTimesToAttemptAgentRestart()
Gets the maximum number of times to attempt an Agent restart

Specified by:
getMaxNumTimesToAttemptAgentRestart in interface WatchdogMBean

getMaxNumTimesToAttemptMachineRestart

public int getMaxNumTimesToAttemptMachineRestart()
Gets the maximum number of times to attempt a machine restart

Specified by:
getMaxNumTimesToAttemptMachineRestart in interface WatchdogMBean

postDeregister

public void postDeregister()
Description copied from interface: javax.management.MBeanRegistration
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Description copied from interface: javax.management.MBeanRegistration
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
Description copied from interface: javax.management.MBeanRegistration
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface javax.management.MBeanRegistration

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
Pre registers this MBean

Specified by:
preRegister in interface javax.management.MBeanRegistration

handleNotification

public void handleNotification(javax.management.Notification notification,
                               java.lang.Object handback)
Specified by:
handleNotification in interface javax.management.NotificationListener

getObjectNameClass

private java.lang.Class getObjectNameClass(javax.management.ObjectName objectName)
                                    throws java.lang.ClassNotFoundException,
                                           javax.management.InstanceNotFoundException

handleRegisterNotification

private void handleRegisterNotification(javax.management.MBeanServerNotification mbeanServerNotification)
                                 throws java.lang.ClassNotFoundException,
                                        javax.management.InstanceNotFoundException,
                                        javax.management.MBeanException,
                                        javax.management.ReflectionException

handleUnregisterNotification

private void handleUnregisterNotification(javax.management.MBeanServerNotification mbeanServerNotification)

dispatchEvent

public void dispatchEvent(WatchdogEvent watchdogEvent)
Dispatch a WatchdgoEvent to all WatchdogListener listening.


startAgent

private void startAgent()
                 throws java.rmi.RemoteException
Starts the JMX Agent that this Watchdog is watching, if the Agent is running nothing will be done.


stopAgent

private void stopAgent()
                throws java.rmi.RemoteException
Stops the JMX Agent that this watchdog is watching, if the Agent is not running then nothing will be done.


startWatching

private void startWatching()
                    throws java.rmi.RemoteException,
                           javax.management.JMException,
                           javax.naming.NamingException
Start watching the JMX Agent.


stopWatching

private void stopWatching()
                   throws javax.management.InstanceNotFoundException,
                          javax.management.MBeanRegistrationException
Stop Watching the JMX Agent.


doWatching

private void doWatching()
Worker method called by startWatching to perform watching 'runs'. Continues running as long as isWatching is true.


startMirroring

private void startMirroring()
                     throws javax.management.JMException,
                            java.rmi.RemoteException,
                            javax.naming.NamingException

stopMirroring

private void stopMirroring()
                    throws javax.management.MBeanRegistrationException,
                           javax.management.InstanceNotFoundException

setupTransientWatchdogData

private void setupTransientWatchdogData()
                                 throws java.rmi.RemoteException,
                                        javax.management.InstanceAlreadyExistsException,
                                        javax.management.JMException,
                                        javax.management.MBeanRegistrationException,
                                        javax.naming.NamingException
Sets up some data used for watching which may change, for instance the RMI Binding of the Agent to be watched - the Agent may have been moved to another machine so the RMI Binding will have changed.


testRMIAdaptor

private void testRMIAdaptor()

tearDownTransientWatchdogData

private void tearDownTransientWatchdogData()
                                    throws javax.management.InstanceNotFoundException,
                                           javax.management.MBeanRegistrationException
Sets all the transient data to null, done to prevent clients for using old data.


isMirroringServiceMBeanRegistered

private boolean isMirroringServiceMBeanRegistered()

registerMirroringServiceMBean

private void registerMirroringServiceMBean()
                                    throws javax.management.NotCompliantMBeanException,
                                           javax.management.MBeanRegistrationException,
                                           javax.management.InstanceAlreadyExistsException

unregisterMirroringServiceMBean

private void unregisterMirroringServiceMBean()
                                      throws javax.management.MBeanRegistrationException,
                                             javax.management.InstanceNotFoundException

updateTimeStartedWatching

private void updateTimeStartedWatching()
Updates the time watching starts.


updateTimeLastDidSomething

private void updateTimeLastDidSomething()
Updates the time that something was last done.


updateTimeLastWatched

private void updateTimeLastWatched()
Updates the time watching last occured.


trimDomain

private java.lang.String trimDomain(java.lang.String input)
Cleans up a String used to represent ObjectName domains


getNonNegativeMinimum

private int getNonNegativeMinimum(int a,
                                  int b)
Utility function for trimDomain


setupWatchdogNumbers

private void setupWatchdogNumbers()
Sets the number of MBeans that are being watched.


isMBeanStateSuitableForWatching

private boolean isMBeanStateSuitableForWatching()
Returns whether this Watchdog MBean is in a suitable state for Watching.


watchOnce

private void watchOnce()
                throws java.lang.InterruptedException
Performs a single watching run.


takeCorrectiveAction

private void takeCorrectiveAction(java.util.Set failingMBeans)
                           throws java.lang.InterruptedException,
                                  java.rmi.RemoteException,
                                  java.net.MalformedURLException,
                                  java.rmi.NotBoundException
Takes corrective action on a Set of failed MBeans


restartAgent

private void restartAgent()
Restart the JMX Agent that is being watched.


takeCorrectiveAction

private void takeCorrectiveAction(Watchdog.ObjectNameAndValue objectNameAndValue)
Take corrective action on a single ObjectInstance


requireAgentRestart

private boolean requireAgentRestart(java.util.Set failingMBeans)
Determines whether any of failingMBeans requires an Agent restart


requireMachineReboot

private boolean requireMachineReboot(java.util.Set failingMBeans)
Determines whether any of failingMBeans requires a machine reboot


anyMBeanHasCorrectiveAction

private boolean anyMBeanHasCorrectiveAction(java.util.Set mbeans,
                                            int matchingCorrectiveAction)
Determines whether any of mbean has the matchingCorrectiveAction Corrective Action


invokeStartMethod

private boolean invokeStartMethod(javax.management.ObjectName objectName)
Invokes the startMBean method on an ObjectInstance


invokeRestartMethod

private boolean invokeRestartMethod(Watchdog.ObjectNameAndValue objectNameAndValue)
Invokes either restartMBean or startMBean methods on an ObjectInstance depending on whether the MBean is in a FAILED state or not.


getBooleanValue

private boolean getBooleanValue(java.lang.Object object)
Casts object to a Boolean, returns false if object isn't a Boolean


invokeMethod

private java.lang.Object invokeMethod(javax.management.ObjectName objectName,
                                      java.lang.String methodName)
Invokes a method on an ObjectInstance


reregisterMBean

private boolean reregisterMBean(javax.management.ObjectName objectName)
Reregisters an MBean


getEntry