The monitor process



Data Structures/Variables:

ipAddr : A string that contains the ip-address of the co-ordinator that this monitor
            process has to monitor.
msgQueueId : Contains the reference to the message queue from which the monitor process
            will pick messages from.

nodeId    : The id of the co-ordinator that this monitor has to monitor.


 
    A monitor process is an RPC client only. It periodically monitors its adjacent coordinator process in a ring to find if it is alive or failed. If the failed coordinator is a leader, an alive coordinator that most recently performed as leader resumes as the new leader.
 

When the monitor process is started by the local co-ordinator process. It is given the
id of the last co-ordinator in the ring that it has to monitor. The co-ordinator and the
monitor processes running on a machine communicate with each other through a local message queue. The monitors form a monitoring ring as shown below:




Following are the steps/functions performed by the monitor process:

            1)SIGUSR1 : Whenever a new co-ordinator joins the ARC ring, there is change
            in the ARC ring at one link. When this happens, the last monitor process
            must start monitoring this newly joined co-ordinator. This is told to the
            monitor by the last leader local co-ordinator by putting this information
            in the message queue and sending this signal to the monitor process. The
            last leader co-ordinator sends the address of the new coordinator to be
            monitored to the monitor process when it receives the broadcast_join()from the newly joined
            co-ordinator.

            The handler for this signal is the function called handler().
            handler() gets invoked every time the signal,SIGUSR1 is received.

      2)SIGALRM : This is an alarm signal that is set by the monitor process itself, so
            that it can be receive the alarm periodically. Now, whenever the monitor
            process receives this signal, it tests whether the co-ordinator it
            has to monitor is alive or it has failed, by trying to create a client handle
            to the coordinator. This is done in a function live_test().
            The handler for this signal is time_out() and it is invoked whenever
            this alarm signal is received.
 


Following are the helper functions used:

Following functions have been defined in the file "/usr/src/generalRoutine.c"