org.ourgrid.common.fd
Class MonitoringUnit

java.lang.Object
  extended by org.ourgrid.common.fd.MonitoringUnit
Direct Known Subclasses:
FakeMonitoringUnit

public class MonitoringUnit
extends java.lang.Object

Create to organize the monitoring action this class knows all information necessary to monitor a Monitorable.

We have the remote entity and an local state to recover at any time.


Field Summary
static java.lang.String UNDEFINED_MONITORABLE_NAME
          This is the name used when the MonitoringUnit does not know (or can not get yet) the Monitorable name
 
Constructor Summary
MonitoringUnit(GenericState initialState, java.lang.String remoteFailureDetectorAddress, java.lang.String monitorableServiceIndex)
          Constructor
 
Method Summary
 void addInterested(java.lang.String notifiableName, Notifiable notifiable)
          Adds a Notifiable like interested in this Monitorable.
 void changeState(GenericState newState)
          The state should be changed by this method only
 java.lang.String getAddress()
          Returns the object remote address.
 java.util.Map<java.lang.String,Notifiable> getInteresteds()
           
 double getLastEncarnationNumber()
           
 GenericState getLastState()
           
 java.lang.String getMonitorableIdentifier()
          An index name given by the Notifier when register it interests to the Monitorable.
protected  Monitorable getSynchronizedRemoteReference()
          This method is used to synchronize the reference the the MonitoringUnit has with the remote one.
 boolean hasInteresteds()
           
 void removeInterested(java.lang.String notifiableName)
          Remove a Notifiable like interested in this Monitorable.
 void updateState()
          Executes a call (note that call can be remote or local), asking to the Monitorable the new state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED_MONITORABLE_NAME

public static final java.lang.String UNDEFINED_MONITORABLE_NAME
This is the name used when the MonitoringUnit does not know (or can not get yet) the Monitorable name

See Also:
Constant Field Values
Constructor Detail

MonitoringUnit

public MonitoringUnit(GenericState initialState,
                      java.lang.String remoteFailureDetectorAddress,
                      java.lang.String monitorableServiceIndex)
Constructor

Parameters:
initialState - The MonitoringUnit initial state
remoteFailureDetectorAddress - The address of the MonitoringUnit to be created
monitorableServiceIndex - An index name given by the Notifier when register it interests to the Monitorable. It will be used to notify that a state has changed.
Method Detail

getInteresteds

public java.util.Map<java.lang.String,Notifiable> getInteresteds()
Returns:
Returns the interesteds.

getLastState

public GenericState getLastState()
Returns:
Returns the state.

addInterested

public void addInterested(java.lang.String notifiableName,
                          Notifiable notifiable)
Adds a Notifiable like interested in this Monitorable.

Parameters:
notifiableName - The name of the Notifiable to be used as key.
notifiable - The Notifiable implementation.

removeInterested

public void removeInterested(java.lang.String notifiableName)
Remove a Notifiable like interested in this Monitorable.

Parameters:
notifiableName - The Notifiable name

hasInteresteds

public boolean hasInteresteds()
Returns:
Returns true if the Monitorable at least one Notifiable interested.

updateState

public void updateState()
Executes a call (note that call can be remote or local), asking to the Monitorable the new state. If anything wrong occurs sets the monitorable state to State.DOWN Here, it is necessary to getSynchronizedRemoteReference when the object goes down. This synchronization is necessary because the remote references are modified at startup moment and old (deprecated) references could point to wrong remote references.

See Also:
getSynchronizedRemoteReference()

getSynchronizedRemoteReference

protected Monitorable getSynchronizedRemoteReference()
                                              throws java.rmi.RemoteException,
                                                     java.net.MalformedURLException,
                                                     java.rmi.NotBoundException
This method is used to synchronize the reference the the MonitoringUnit has with the remote one.

Returns:
A synchronized object remote reference.
Throws:
java.rmi.RemoteException - If could not contact the remote server
java.rmi.NotBoundException - If the object in exported remotely.
java.net.MalformedURLException - If the address is a not valid RMI url.

getAddress

public java.lang.String getAddress()
Returns the object remote address.

Returns:
The object remote address.

getLastEncarnationNumber

public double getLastEncarnationNumber()
Returns:
Returns the last Reencarnation number associated with this MonitoringUnit

changeState

public void changeState(GenericState newState)
The state should be changed by this method only

Parameters:
newState -

getMonitorableIdentifier

public java.lang.String getMonitorableIdentifier()
An index name given by the Notifier when register it interests to the Monitorable.

Returns:
An index name given by the Notifier when register it interests to the Monitorable.