org.ourgrid.common.fd
Class AbstractFailureDetector

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.ourgrid.common.rmi.OurgridUnicastRemoteObject
                  extended by org.ourgrid.common.fd.AbstractFailureDetector
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, Shutdownable, Monitor, Monitorable
Direct Known Subclasses:
CorePeerFailureDetector, MyGridFailureDetector, PeerFailureDetector, SimpleTestFailureDetector, UserAgentFailureDetector

public abstract class AbstractFailureDetector
extends OurgridUnicastRemoteObject
implements Shutdownable, Monitor, Monitorable, java.rmi.Remote

This object is responsible for providing an updated information about Monitorables fails.

The rationale behind the abstract is that the Monitorable interface methods will be implemented by the failure detector. We plan three main implementors to this interface:



P.S.: Remember that the UserAgent has three states. :-)

See Also:
Shutdownable, Monitor, Monitorable, Serialized Form

Field Summary
static java.lang.String BOUND_NAME
          The name to be used to bound the remote service.
static java.lang.String DEFAULT_PROTOCOL
           
static long serialVersionUID
          Serial identification of the class.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
AbstractFailureDetector()
          Initializes an AbstractFailureDetector with AbstractFailureDetector#DEFAULT_QUERY_FREQUENCY
AbstractFailureDetector(int queryFrequency)
          Initializes an AbstractFailureDetector
AbstractFailureDetector(int queryFrequency, MonitoringUnitFactory factory)
           
AbstractFailureDetector(MonitoringUnitFactory factory)
           
 
Method Summary
abstract  GenericState getCurrentState()
          Retrieves the monitorable current status.
 double getEncarnationNumber()
          Return an unique identifier of the Monitorable session.
protected  java.lang.String getFailureDetectorAddress(java.lang.String monitorableAddress)
          This method gets the address of the FailureDetector service bounded at the same machine of the monitorable service given by parameter.
 java.util.Map<java.lang.String,MonitoringUnit> getMonitorables()
          Retrieves a collection of monitorables
 void pingNow(java.lang.String monitorableAddress)
           
 void register(Notifiable notifiable, java.lang.String monitorableAddress)
          Adds an object interested in receiving Grid Machine state changes notifications of the specified Grid Machine.
 void register(Notifiable notifiable, java.lang.String monitorableAddress, boolean imediatePing)
           
 void setMonitorableState(java.lang.String monitorableAddress, GenericState newState)
          Allows that an external entity updates the state of a monitorable
 void shutdown()
          Informs the service thread associated with the object that it must shutdown.
 void startMonitoring()
          The pingerTimerTask is initialized here because in certain situations (e.g.
 void unregister(Notifiable notifiable)
          Removes the object interested in receiving Grid Machine state changes notifications of all monitorables interested list.
 void unregister(Notifiable notifiable, java.lang.String monitorableAddress)
          Removes the object interested in receiving Grid Machine state changes notifications.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial identification of the class. It need to be changed only if the class interface is changed.

See Also:
Constant Field Values

BOUND_NAME

public static final java.lang.String BOUND_NAME
The name to be used to bound the remote service.

See Also:
Constant Field Values

DEFAULT_PROTOCOL

public static final java.lang.String DEFAULT_PROTOCOL
See Also:
Constant Field Values
Constructor Detail

AbstractFailureDetector

public AbstractFailureDetector()
                        throws java.rmi.RemoteException
Initializes an AbstractFailureDetector with AbstractFailureDetector#DEFAULT_QUERY_FREQUENCY

Throws:
java.rmi.RemoteException - If something wrong occurs at the initialization of the OurgridUnicastRemoteObject

AbstractFailureDetector

public AbstractFailureDetector(MonitoringUnitFactory factory)
                        throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

AbstractFailureDetector

public AbstractFailureDetector(int queryFrequency)
                        throws java.rmi.RemoteException
Initializes an AbstractFailureDetector

Parameters:
queryFrequency - The frequency when the state of Monitorable objects will me verified.
Throws:
java.rmi.RemoteException - If something wrong occurs at the initialization of the OurgridUnicastRemoteObject

AbstractFailureDetector

public AbstractFailureDetector(int queryFrequency,
                               MonitoringUnitFactory factory)
                        throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

register

public void register(Notifiable notifiable,
                     java.lang.String monitorableAddress,
                     boolean imediatePing)
              throws java.rmi.RemoteException,
                     java.net.MalformedURLException
Throws:
java.rmi.RemoteException
java.net.MalformedURLException

pingNow

public void pingNow(java.lang.String monitorableAddress)
             throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

register

public void register(Notifiable notifiable,
                     java.lang.String monitorableAddress)
              throws java.rmi.RemoteException,
                     java.net.MalformedURLException
Description copied from interface: Monitor
Adds an object interested in receiving Grid Machine state changes notifications of the specified Grid Machine.

Specified by:
register in interface Monitor
Parameters:
notifiable - object interested in receiving the notifications
monitorableAddress - the address of the service (FailureDetector .. Monitorable) to monitor
Throws:
java.net.MalformedURLException - If has something wrong with monitorable URL.
java.rmi.RemoteException - if anything wrong occurs in communication.
See Also:
Monitor.register(org.ourgrid.common.fd.Notifiable, String)

unregister

public void unregister(Notifiable notifiable)
                throws java.rmi.RemoteException
Description copied from interface: Monitor
Removes the object interested in receiving Grid Machine state changes notifications of all monitorables interested list.

Specified by:
unregister in interface Monitor
Parameters:
notifiable - the object to be removed
Throws:
java.rmi.RemoteException - if anything wrong occurs in communication.
See Also:
Monitor.unregister(org.ourgrid.common.fd.Notifiable)

unregister

public void unregister(Notifiable notifiable,
                       java.lang.String monitorableAddress)
                throws java.rmi.RemoteException
Description copied from interface: Monitor
Removes the object interested in receiving Grid Machine state changes notifications.

Specified by:
unregister in interface Monitor
Parameters:
notifiable - the object to be removed
monitorableAddress - the Monitorable address that the Notifiable will not be interested.
Throws:
java.rmi.RemoteException - if anything wrong occurs in communication.
See Also:
Monitor.unregister(org.ourgrid.common.fd.Notifiable, String)

startMonitoring

public void startMonitoring()
                     throws java.rmi.RemoteException
The pingerTimerTask is initialized here because in certain situations (e.g. Sensors) the monitoring will not occurs.

Specified by:
startMonitoring in interface Monitor
Throws:
java.rmi.RemoteException - if anything wrong occurs in communication.
See Also:
Monitor.startMonitoring()

getMonitorables

public java.util.Map<java.lang.String,MonitoringUnit> getMonitorables()
                                                               throws java.rmi.RemoteException
Description copied from interface: Monitor
Retrieves a collection of monitorables

Specified by:
getMonitorables in interface Monitor
Returns:
The entities to be monitored
Throws:
java.rmi.RemoteException - If anything wrong occurs in communication.
See Also:
Monitor.getMonitorables()

getEncarnationNumber

public double getEncarnationNumber()
                            throws java.rmi.RemoteException
Description copied from interface: Monitorable
Return an unique identifier of the Monitorable session.

Specified by:
getEncarnationNumber in interface Monitorable
Returns:
a unique identifier of the Monitorable session.
Throws:
java.rmi.RemoteException - if anything wrong occurs in communication.
See Also:
Monitorable.getEncarnationNumber()

setMonitorableState

public void setMonitorableState(java.lang.String monitorableAddress,
                                GenericState newState)
Allows that an external entity updates the state of a monitorable

Parameters:
monitorableAddress -
newState -

getFailureDetectorAddress

protected java.lang.String getFailureDetectorAddress(java.lang.String monitorableAddress)
                                              throws java.net.MalformedURLException
This method gets the address of the FailureDetector service bounded at the same machine of the monitorable service given by parameter.

Parameters:
monitorableAddress - The service the user would like to monitor
Returns:
the address of the FailureDetector service bounded at the same machine of the monitorable service given by parameter.
Throws:
java.net.MalformedURLException - If has something wrong with monitorable URL.

shutdown

public void shutdown()
Description copied from interface: Shutdownable
Informs the service thread associated with the object that it must shutdown.

Specified by:
shutdown in interface Shutdownable
See Also:
Shutdownable.shutdown()

getCurrentState

public abstract GenericState getCurrentState()
                                      throws java.rmi.RemoteException
Description copied from interface: Monitorable
Retrieves the monitorable current status.

Specified by:
getCurrentState in interface Monitorable
Returns:
the Monitorable state.
Throws:
java.rmi.RemoteException - if anything wrong occurs in communication.