The initialization Interface
(Part of Server Process)
Data Structures:
-
msgQueueId : An integer variable that stores the id of
the message queue
-
monitorNode : The id of the node that is being monitored
by the monitor process.
-
pidArr : An integer array consisting of process-ids of
all the registered user programs.
There are three RPC services defined in this interface :
-
int* boot_up_1_svc(int isFirstNode)
-
NodeArr* broadcast_subscribe_1_svc(StrArr* strArr)
-
int* broadcast_join_1_svc(Node* node)
Client for the first service,boot_up_1_svc()
is the join process which executes on the same machine as that of the co-ordinator
process. This service is responsible for doing all the initialization of
the coordinator and getting an nodeId for it.
The algorithms of these three service are given below.
int* boot_up_1_svc(int isFirstNode)
Arguments : The integer variable isFirstNode
that tells whether the coordinator is the first on to come up.
Returns : The function returns the status value
obtained after calling the function broadcast_join() on other co-ordinators
from within this function.
At Client side:
The client for this
service is the boot-Up process. The first RPC service, boot_up_1_svc()
is called by the
join process after starting
the co-ordinator. The calling routine is present at the same place where
the co-ordinator is running. Show details
At the Server Side:
The call is received
by the co-ordinator at the same node as the bootup-process.
The following steps are then followed by the co-ordinator within
this function:
-
Get the name of the node on which it is running.
-
Call the function loadTable(),
defined in the file loadTable.c
that will get the details of the host machine such as the machine-name,
ip address, the computation capacity, machine architecture etc. All these
details are present in the file "kernel/src/coordinator/node_inf_file".
-
If the coordinator is the first one to come up, then call a function
initializeFirstNode()
that will do the initialization that includes assigning a id for itself
and creating a node-array.
-
If the coordinator is not the first one, then broadcast the request
( by the invoking the method
broadcast_subscribe()
) to get an id for itself.
-
In the broadcast, a local function-name replySubscribe(NodeArr*
nodeArr) is specified and this function will be called by the broadcast-RPC
routine automatically when it receives the response from other co-ordinator.
-
At this stage we have a array consisting of all the co-ordinators in
the ARC ring. Note that if the coordinator is the first one to come, then
there will be only one entry in the node array. From this node-array passed,
get the id of the co-ordinator.
-
Call RPC function broadcast_join_1_svc() on each of the other
co-ordinators.
-
Calculate the load on the node and store it in a data-structure. This
is done by executing the system command w to obtain the weight and
then parsing the result obtained to get the result.
-
Initialize the message queues for setting up communication path between
the coordinator and other other processes.
-
Start the timer process.
-
Initialize a array that will contain the process-ids, pids of all the
user programs that will register with the coordinator.
NodeArr* broadcast_subscribe_1_svc(StrArr* strArr)
Arguments : The string array consisting of the information about
the machine.
Returns : Co-ordinators return different values depending on the
fact whether they
are the last one in the ARC ring or not.( See details below )
At Client side:
This function is called from within the function
boot_up_1_svc() of the new coordinator that wants to join the ARC ring.
The service broadcast_subscribe_1_svc(StrArr* strArr)
is called
on each of the existing co-ordinators to tell them that it wishes to join
the ARC ring. This is actually to broadcast a "subscribe-request". The
new node supplies its identity as an array argument in the functions, which
contains the information read from the file "kernel/src/coordinator/node_inf_file".
The return value of this function depends on the node that is responding
to the broadcast-request. (Explained below)
At Server side:
All the existing co-ordinators receive this
request. The co-ordinator on
receiving this call create a new entry in their list of nodes for
the new
up-coming node. Then the co-ordinator checks the status of the
flag, globLastMe to find if it is the last one in ARC ring. If not,
it sends a dummy array back to the calling process. If yes then do the
following :
-
Check the node-array( that contains the list of all the nodes present
in the ARC ring) to see if there is already an entry for the new request.
An existing entry means that this node might have been failed earlier and
now it has come up again.
-
If there is no entry for the new node make an entry now.
-
Set the flag, globLastMe to false if the newly added node's entry comes
after the emtry of coordinator in the node-array.
-
Return the modified node-array that now includes the new node also.
int* broadcast_join_1_svc(Node* node)
Arguments : A data-structure of type Node that contains the
id and details about
the co-ordinator that call this function.
Returns : Highest sequence number in the array of co-ordinators.
At client side:
The call to this service is made from within
the boot_up_1_svc() service of
the co-ordinator on each of the existing co-ordinators to tell
them that it has
actually joined the ARC ring. The argument to the function is a
node
structure
that
describes about the details of the machine on which the co-ordinator
is running.
At Server side:
At the server receiving this request: The existing
servers that receive this request
update their data-structures to reflect the join of the new node
that indicates that
the new node is now ready. If the monitor process running at the
coordinator is not monitoring any node(this happens if the coordinator
is the only one present in the ARC ring), then it will now start monitoring
the newly come-up coordinator. The monitor process at the coordinator is
informed about this by sending it a message through message queue.
Following are the helper functions.
-
int replySubscribe(NodeArr* nodeArr)
-
The argument in this function is the list of all the co-ordinators.
-
This is called automatically every time the reply (of the broadcast
message ) is received.
-
If the last node in the already established ARC ring has responded
then the host need not wait for any more replies otherwise wait till the
last coordinator's response is received.
-
In the response, the last node sends the list of all the co-ordinators
forming the ARC ring and their respective id's.
-
The nodes that are not the last ones simply send a dummy reply.
-
The node-array that is received is copied onto local node-array.
-
void initializeFirstNode(StrArr* strArr)
-
The argument is the array consisting of the information about the node
that is being initialized. This includes the machine name, ip address,
computation power, etc.( Show details )
-
This function is called only if the coordinator that is broadcasting
the broadcast_subscribe_svc_1() message is the first in the ARC
system and there are no co-ordinators already present.
-
The purpose of this function is to initialize a node array consisting
of two nodes:
* First node entry contains all the information about
the host machine and its node-id is "zero".
* Second node-entry is similar to the first-node entry
expect that its node-id field is -1.