Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

eqn_cruncher::node_manager Class Reference

The Node manager is responsible for effectively and correctly maintaining the list of all clients currently connected to the master after the server has recognized such clients and has accepted their connections. More...

#include <node_manager.hpp>

List of all members.

Public Types

enum  { data, command }
enum  {
  quit, start, result, reset_client,
  reset_subclient
}

Public Methods

int test_and_get ()
 This function is the atomic test_and_get function. It atomically checks for a free socket in the list of free sockets.

void recycle_socket (int sock_id)
 Atomically adds the file descriptor of the socket given by sock_id to the list of free sockets.

void send_vector (eqn_cruncher::matrix_t const &dv, eqn_cruncher::socket s)
 This function sends a square matrix to the remote client for solving the determinant.

void server (server_data *psd)
 This is the main listening server thread.

double get_vector (eqn_cruncher::socket s, unsigned int mat_size, double(*det_proc)(matrix_t const &))
 This function gets the square matrix from the server and then processes it to compute its determinant. It is called from the client context.

void close_sockets ()
 Closes all the sockets of the clients cached in the list of free clients.

void send_message (eqn_cruncher::pkt_header ph)
 Sends a message having the packet header ph to all the clients connected to the current object.

void send_reset_client_msg ()
 Sends a 'reset_client' message to all the clients connected to the current object.

void send_reset_subclient_msg ()
 Sends a 'reset_subclient' message to all the clients connected to the current object.

void send_quit_msg ()
 Sends a 'quit' message to all the clients connected to the current object.


Detailed Description

The Node manager is responsible for effectively and correctly maintaining the list of all clients currently connected to the master after the server has recognized such clients and has accepted their connections.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
data  Signifies that the current packet is a data packet.
command  Signifies that the current packet is a command packet.

anonymous enum
 

Enumeration values:
quit  When the client receives a quit command, it closes the connection with all it's clients, and its server, and gracefully exits.
start  When the client receives a start command, it first receives the complete matrix from its server, and then starts evaluating the determinant of that square matrix received. When the determinant calculation is complete, it sends the server a result command in return along with the actual result.
result  This comamnd is sent only by a client to its current server signifying that the result of the computation has been determined, and this result is sent along with the packet in the reserved field.
reset_client  When the client receives a reset_client command, it performs 2 main functions. Firstly, it sends all its clients a reset_subclient command, and secondly it disconnects itself from its server by closing the open socket, and then starts waiting for a connection once again on the same IP address and port as before.
reset_subclient  When the SubClients receive a reset_subclient command, they just display the appropriate message to the user, and propagate the message to their clients.


Member Function Documentation

void eqn_cruncher::node_manager::close_sockets  
 

Closes all the sockets of the clients cached in the list of free clients.

Hence, it disconnects itself from all the clients currently connected to the server which owns the current object.

double eqn_cruncher::node_manager::get_vector eqn_cruncher::socket    s,
unsigned int    mat_size,
double(*    det_proc)(matrix_t const &)
 

This function gets the square matrix from the server and then processes it to compute its determinant. It is called from the client context.

This procedure is called by the remote client when it catches the start command. It basically parses the input data stream, and stores the data in a local matrix. Then, the procedure specified by the parameter det_proc is called on the matrix of type matrix_t.

Parameters:
s  The socket containg the server on the oteher side.
mat_size  The number of rows/columns in the square matrix that this function will receive from the server through the socket s.
det_proc  Pointer to a function having a signature: double(matrix_t const&). This function typically computes sthe determinat of the matrix passed to it, and retruns the computed value.
Returns:
The determinant of the matrix that it received from the server.

void eqn_cruncher::node_manager::recycle_socket int    sock_id [inline]
 

Atomically adds the file descriptor of the socket given by sock_id to the list of free sockets.

Parameters:
sock_id  The file descriptor of the free socket.

void eqn_cruncher::node_manager::send_message eqn_cruncher::pkt_header    ph
 

Sends a message having the packet header ph to all the clients connected to the current object.

Parameters:
ph  The packet header to insert at the start of the message being sent to all the clients connected to the current object.

void eqn_cruncher::node_manager::send_quit_msg  
 

Sends a 'quit' message to all the clients connected to the current object.

void eqn_cruncher::node_manager::send_reset_client_msg  
 

Sends a 'reset_client' message to all the clients connected to the current object.

void eqn_cruncher::node_manager::send_reset_subclient_msg  
 

Sends a 'reset_subclient' message to all the clients connected to the current object.

void eqn_cruncher::node_manager::send_vector eqn_cruncher::matrix_t const &    dv,
eqn_cruncher::socket    s
 

This function sends a square matrix to the remote client for solving the determinant.

First send a header containing only a command. This command header shold contain only the start command, and the size of the square matrix in the form of row size ONLY in the reserved field. The client can then calculate the total size of the matrix from the row size, knowing that the matrix is a square matrix, and each field is a double data type. The command header contains the size member as 0, because there is no data to be transmitted. The client always verifies the packet size by adding the size field to the sizeof(pkt_header), and checking if it is equal to the value returned by the receive function.

Parameters:
dv  Reference to constant matrix_t object representing the square matrix whose detreminant we wish to compute.
s  The socket having the remote client on the other side.

void eqn_cruncher::node_manager::server server_data   psd
 

This is the main listening server thread.

This is the main server thread, which continuously listens for at most max_queue connections. As and when they come along, the sockets are connected, and they socket IDs are added to the list of socket IDs. This lets us reuse and recycle the socket IDs at will.

Parameters:
psd  Pointer to server_data object, which contains the various details that the server thread requires.

int eqn_cruncher::node_manager::test_and_get   [inline]
 

This function is the atomic test_and_get function. It atomically checks for a free socket in the list of free sockets.

Returns:
The file descriptor of the socker if the socket list is non-empty, else -1.


The documentation for this class was generated from the following file:
Generated on Mon Oct 11 13:09:26 2004 for Equation Cruncher by doxygen1.2.18