cluster::ClusterNode Class Reference

Cluster node. More...

#include <cluster/ClusterNode.h>

Inheritance diagram for cluster::ClusterNode:

Inheritance graph
[legend]
Collaboration diagram for cluster::ClusterNode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ClusterNode (const std::string &name, const std::string &host_name, const vpr::Uint16 &port, vpr::SocketStream *socket_stream)
 Create a Node with the given attributes.
virtual ~ClusterNode ()
 Shutdown the update thread and close the SocketStream.
bool isUpdated ()
 Return if this node is updated or not.
void setUpdated (bool update)
 Set the update status for this node.
virtual void controlLoop (void *nullParam)
 Control loop for updating this thread.
void signalUpdate ()
 Signal a semaphore to let the update thread fall into the code to update the UserData structures.
void sync ()
 Blocks until the end of the frame.

Detailed Description

Cluster node.

Definition at line 48 of file ClusterNode.h.


Constructor & Destructor Documentation

cluster::ClusterNode::ClusterNode ( const std::string &  name,
const std::string &  host_name,
const vpr::Uint16 &  port,
vpr::SocketStream *  socket_stream 
)

Create a Node with the given attributes.

Parameters:
name Name of the Cluster Node from the config file
host_name Hostname of the remote machine
port The scoket port that we should connect to
socket_stream SocketStream used to communicate with remote machine

virtual cluster::ClusterNode::~ClusterNode (  )  [virtual]

Shutdown the update thread and close the SocketStream.


Member Function Documentation

bool cluster::ClusterNode::isUpdated (  )  [inline]

Return if this node is updated or not.

Reimplemented from gadget::Node.

Definition at line 70 of file ClusterNode.h.

00071    {
00072       return mUpdated;
00073    }

void cluster::ClusterNode::setUpdated ( bool  update  )  [inline]

Set the update status for this node.

Reimplemented from gadget::Node.

Definition at line 78 of file ClusterNode.h.

00079    {
00080       mUpdated = update;
00081    }

void cluster::ClusterNode::controlLoop ( void *  nullParam  )  [virtual]

Control loop for updating this thread.

Reimplemented from gadget::Node.

Definition at line 42 of file ClusterNode.cpp.

References gadget::Node::debugDump(), gadget::Node::DISCONNECTED, gadgetDBG_RIM(), cluster::ClusterException::getMessage(), gadget::Node::getName(), gadget::Node::getPort(), gadget::Node::mRunning, gadget::Node::setStatus(), and gadget::Node::update().

00043 {
00044    // - Block on an update call
00045    // - Update Local Data
00046    // - Send
00047    // - Signal Sync
00048 
00049    boost::ignore_unused_variable_warning(nullParam);
00050    
00051    while( mRunning )
00052    {
00053       // Wait for trigger
00054       if( mRunning )
00055       {
00056          mUpdateTriggerSema.acquire();
00057       }
00058          
00059       mUpdated = false;
00060       while ( mRunning && !mUpdated )
00061       {
00062          try
00063          {
00064             update();
00065          }
00066          catch(cluster::ClusterException cluster_exception)
00067          {
00068             vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) << clrSetBOLD(clrRED)
00069                << cluster_exception.getMessage() << clrRESET
00070                << std::endl << vprDEBUG_FLUSH;
00071             
00072             vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) <<
00073                "ClusterNode::update() We have lost our connection to: " << getName() << ":" << getPort()
00074                << std::endl << vprDEBUG_FLUSH;
00075 
00076             debugDump(vprDBG_CONFIG_LVL);
00077             
00078             // Set the ClusterNode as disconnected since we have lost the connection
00079             setStatus(DISCONNECTED);
00080             
00081             // Shut down manually instead of calling shutdown since
00082             // we are in the control thread.
00083             mRunning = false;
00084             //if (NULL != mSockStream)
00085             //{
00086                //if(mSockStream->isOpen())
00087                //{
00088                //   mSockStream->close();
00089                //}
00090                //delete mSockStream;
00091                //mSockStream = NULL;
00092             //}
00093          }
00094       }
00095       
00096       // Signal done with Update
00097       mNodeDoneSema.release();
00098    }
00099    vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) << "ClusterNode: " << getName() << " is stopping."
00100                                              << std::endl << vprDEBUG_FLUSH;
00101 }

void cluster::ClusterNode::signalUpdate (  ) 

Signal a semaphore to let the update thread fall into the code to update the UserData structures.

Reimplemented from gadget::Node.

Definition at line 103 of file ClusterNode.cpp.

References gadgetDBG_RIM(), and gadget::Node::mThreadActive.

00104 {
00105    while(!mThreadActive)
00106    {
00107       vprDEBUG(gadgetDBG_RIM, vprDBG_HVERB_LVL) << "Waiting for thread to start ClusterNode::start().\n" << vprDEBUG_FLUSH;
00108       vpr::Thread::yield();
00109    }
00110    //vprDEBUG(gadgetDBG_RIM,/*vprDBG_HVERB_LVL*/1) << getName() << "Signaling ClusterNode\n" << vprDEBUG_FLUSH;
00111    mUpdateTriggerSema.release();
00112 }

void cluster::ClusterNode::sync (  ) 

Blocks until the end of the frame.

Postcondition:
The frame has been drawn.

Reimplemented from gadget::Node.

Definition at line 118 of file ClusterNode.cpp.

References gadget::Node::mThreadActive.

00119 {
00120    vprASSERT(mThreadActive == true);
00121    mNodeDoneSema.acquire();
00122 }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:17 2007 for Gadgeteer by  doxygen 1.5.1