FountainNode Class Reference
[Fountain master and slave nodes]

A class for maintaining all aspects of a Fountain node. More...

#include <FountainNode.h>

Inheritance diagram for FountainNode:

FountainMasterNode List of all members.

Public Member Functions

virtual void checkConnections ()
 Checks the listening sockets for incoming connection requests and checks existing connections for incoming message requests.

Protected Types

typedef TreeTopology::ChildNodeContainer::iterator childIterator
 Makes it easy to use an iterator for our children vector.
typedef TreeTopology::ChildNodeContainer::const_iterator constChildIterator
 Makes it easy to use a const_iterator for our children vector.

Protected Member Functions

virtual NodeResponsePtr processRequest (FountainMessage::MessageAction action, ConstParseMsgPtr request, time_t timeout=0)
 Process and respond to a request message from our parent.
virtual NodeResponsePtr processPingPong (ConstParseMsgPtr request, time_t timeout=0)
 Handles an incoming pingPong message request.
void handleParentMessage ()
 Handles a request message from our parent Fountain node.
void checkChildren ()
 Check the status the FountainNode's children and report them as lost if their connection dies.
void handleJoin (ConstParseMsgPtr request, FountainWireProtPtr requestConnection)
 Handles join requests from an incoming connection.
 FountainNode (const NodeID &myID, const NodeID &masterNodeID)
 Protected Constructor since we're using a singleton design pattern.
virtual ~FountainNode ()
 Protected destructor since we're using a singleton design pattern.

Protected Attributes

FountainSocketHandlers socketHandlers_
 An object that creates sockets to listen for incoming connection requests.
TreeTopology::ChildNodeContainer children_
NodeID myID_
NodeID parentID_
FountainWireProtPtr parentConnectionPtr_

Private Member Functions

int handleChildMessage (FountainWireProtPtr childCon, const NodeID &childID)
 Handles a request message from a child node.
virtual int handleLostChild (const NodeID &childID)
 Handles a lost child Fountain node.
virtual void handleLostParent (const char *message)
 Handles a lost parent Fountain node.
void pokeParent ()
 Send our parent connection a pulse request message if we haven't heard from them in a while.
void pokeChildren ()
 Send our child nodes a pulse message if it's time to do so.
void handleSync (ConstParseMsgPtr request, FountainWireProtPtr requestCon)
 Handles syncMsg requests.
void handleWakeup ()
 Handles an FountainMessage::wakeup request from the master Fountain node.
virtual void joinMasterNode ()
 Joins the master Fountain Node using the hostname and port specified in the FountainNode constructor.
int joinParentNode (const NodeID &newParentID)
 Joins a new parent Fountain node.
void checkParent ()
 Check the status of our parent node.
FountainNodeoperator= (const FountainNode &rhs)
 Private assignment operator singe we're using a singleton design pattern.
 FountainNode (const FountainNode &rhs)
 Private copy constructor singe we're using a singleton design pattern.

Private Attributes

NodeID masterNodeID_
NodeMonitorBase::NodeMonitorPtr myNodeInfoPtr_
time_t parentPulseLastSeen_

Friends

class FountainNodeCreator

Classes

class  forwardMessageToChildren
 Functor class to forward a ConstParseMsgPtr message to all child nodes. More...

Detailed Description

A class for maintaining all aspects of a Fountain node.

This is a singleton class since it really does not make sense for any application to maintain multiple Fountain node objects. A FountainNode object maintains connections with a parent Fountain node and multiple child Fountain nodes. Each FountainNode object is responsible for responding to requests from its parent node and forwarding them to their children in a timely fashion. Each node also maintains detailed usage information that is aggregated together by the Fountain Server by parsing the node query response messages.


Constructor & Destructor Documentation

FountainNode::FountainNode const NodeID myID,
const NodeID masterNodeID
[protected]
 

Protected Constructor since we're using a singleton design pattern.

Parameters:
[in] myID NodeID of this Fountain node
[in] masterNodeID NodeID of the master Fountain node


Member Function Documentation

void FountainNode::checkParent  )  [private]
 

Check the status of our parent node.

Exceptions:
FountainException if the parent node was lost and we could not connect to a new parent

int FountainNode::handleChildMessage FountainWireProtPtr  childCon,
const NodeID childID
[private]
 

Handles a request message from a child node.

Parameters:
childCon connection to the child node
childID The NodeID of the child Fountain node
Precondition:
childCon != NULL
Return values:
int SUCCESS if handling the child's request was successful, FAILURE if the child should be removed from our connection container
Exceptions:
FountainException if handling a lost child was not possible

void FountainNode::handleJoin ConstParseMsgPtr  request,
FountainWireProtPtr  requestConnection
[protected]
 

Handles join requests from an incoming connection.

Parameters:
request the request message from the node attempting to join us
requestConnection the connection that sent the join request
Precondition:
valid request and requestConnection

Reimplemented in FountainMasterNode.

int FountainNode::handleLostChild const NodeID childID  )  [private, virtual]
 

Handles a lost child Fountain node.

Parameters:
childID The NodeID of the lost child Fountain node
Return values:
int SUCCESS if the lost child node should be removed from the children vector, FAILURE if the lost child node should NOT be removed from the children vector
Exceptions:
FountainException if the lost child node could not be reported to the master node

Reimplemented in FountainMasterNode.

void FountainNode::handleLostParent const char *  message  )  [private, virtual]
 

Handles a lost parent Fountain node.

Parameters:
message A c-string to add as the Message element in the request to the master Fountain node
Exceptions:
FountainException if handling the lost parent Fountain node was not successful

Reimplemented in FountainMasterNode.

void FountainNode::handleParentMessage  )  [protected]
 

Handles a request message from our parent Fountain node.

Precondition:
parentConnectionPtr_ != NULL

void FountainNode::handleSync ConstParseMsgPtr  request,
FountainWireProtPtr  requestCon
[private]
 

Handles syncMsg requests.

Parameters:
request The request message from the master Fountain node
requestCon connection to the master Fountain node

void FountainNode::handleWakeup  )  [private]
 

Handles an FountainMessage::wakeup request from the master Fountain node.

When our node is reported as a lost node to the master Fountain node, sometimes we might not actually be "lost" but we were asleep for an extended period of time for whatever reason and one of our children did not receive a pulseMsg request during the specified threshold of time. The purpose of this function is to ensure our parent connection and all child node connections are active and healthy, then return a success or failure response to the master Fountain node.

Exceptions:
FountainException If the wakeup request could not be handled successfully

void FountainNode::joinMasterNode  )  [private, virtual]
 

Joins the master Fountain Node using the hostname and port specified in the FountainNode constructor.

Exceptions:
FountainException if we could not join the master Fountain node

Reimplemented in FountainMasterNode.

int FountainNode::joinParentNode const NodeID newParentID  )  [private]
 

Joins a new parent Fountain node.

Parameters:
newParentID The NodeID to join
Return values:
int SUCCESS if joining the new parent node was successful, FAILURE otherwise
Exceptions:
FountainException If we could not connect to the parent node

void FountainNode::pokeParent  )  [private]
 

Send our parent connection a pulse request message if we haven't heard from them in a while.

Exceptions:
FountainException if the lost parent node could not be reported to the master node

NodeResponsePtr FountainNode::processPingPong ConstParseMsgPtr  request,
time_t  timeout = 0
[protected, virtual]
 

Handles an incoming pingPong message request.

Parameters:
request The request message from the parent node
timeout The number of seconds to wait for child responses before timing out, by default a timeout of 0 means wait forever
Return values:
NodeResponsePtr The response message to send
Precondition:
request != NULL

NodeResponsePtr FountainNode::processRequest FountainMessage::MessageAction  action,
ConstParseMsgPtr  request,
time_t  timeout = 0
[protected, virtual]
 

Process and respond to a request message from our parent.

Parameters:
[in] action The message action
[in] request The request message from our parent
[in] timeout The number of seconds to wait for a response from each child node
Return values:
NodeResponsePtr The response message to send back to our parent
Precondition:
request != NULL

Reimplemented in FountainMasterNode.


Member Data Documentation

TreeTopology::ChildNodeContainer FountainNode::children_ [protected]
 

Container for our child nodes

NodeID FountainNode::masterNodeID_ [private]
 

The ID of the master Fountain node

NodeID FountainNode::myID_ [protected]
 

A unique identifier for this Fountain node

NodeMonitorBase::NodeMonitorPtr FountainNode::myNodeInfoPtr_ [private]
 

Each Fountain node maintains a NodeMonitor derived object responsible for parsing various system files to obtain the requested data

FountainWireProtPtr FountainNode::parentConnectionPtr_ [protected]
 

The primary link to other Fountain nodes is through the parentConnection handler

NodeID FountainNode::parentID_ [protected]
 

The ID of this node's parent Fountain node

time_t FountainNode::parentPulseLastSeen_ [private]
 

Time in seconds since epoch representing the last time any message was received on the parentConnection.

FountainSocketHandlers FountainNode::socketHandlers_ [protected]
 

An object that creates sockets to listen for incoming connection requests.

Responsible for creating our listener port and accepting incoming connections. This is protected so the FountainMasterNode class can open a listening port for the Fountain server.


The documentation for this class was generated from the following files:
Generated on Wed Mar 8 14:43:33 2006 for Fountain by  doxygen 1.4.6