gadget::AbstractNetworkManager Class Reference

Network abstraction. More...

#include <gadget/AbstractNetworkManager.h>

Inheritance diagram for gadget::AbstractNetworkManager:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 AbstractNetworkManager ()
 Construct an empty representation of a network.
virtual ~AbstractNetworkManager ()
 Disconnect all nodes in network and release memory.
void handlePacket (cluster::Packet *packet, Node *node)
 Process an incoming packet.
void updateNewConnections ()
vpr::ReturnStatus addNode (const std::string &name, const std::string &host_name, const vpr::Uint16 &port, vpr::SocketStream *socketStream=NULL)
 Creates a Node with the given parameters and adds this new node the std::map of Nodes.
void addNode (Node *node)
 Adds the given Node to the std::map of Nodes.
void removeNode (const std::string &nodeHostname)
 Removes the Node with the given hostname.
gadget::NodegetNodeByHostname (const std::string &host_name)
 Returns the Node with the given hostname If no Node with this hostname exists, NULL is returned.
gadget::NodegetNodeByName (const std::string &node_name)
 Returns the Node with the given name If no Node with this name exists, NULL is returned.
size_t getNumNodes ()
 Get the number of nodes in network.
void debugDumpNodes (int debug_level)
 Print out debug information about all nodes.
std::vector< gadget::Node
* >::iterator 
getNodesBegin ()
 Get an iterator to the beginning of the Nodes std::vector.
std::vector< gadget::Node
* >::iterator 
getNodesEnd ()
 Get an iterator to the end of the Nodes std::vector.
vpr::Uint16 getNumPendingNodes ()
 Return the number of Nodes in the Pending Nodes list.
void shutdown ()
 Kill the listen thread and the update thread.
bool recognizeClusterMachineConfig (jccl::ConfigElementPtr element)
 Determine if the given jccl::ConfigElement is a cluster_node element.
bool configCanHandle (jccl::ConfigElementPtr element)
 Determine if we can handle the given jccl::ConfigElement.
bool configAdd (jccl::ConfigElementPtr element)
 Configure the given jccl::ConfigElement because it was just added to the active configuration.
bool configRemove (jccl::ConfigElementPtr element)
 Remove the given jccl::ConfigElement from the active configuration .
PacketHandlergetHandlerByGUID (const vpr::GUID &handler_guid)
void addHandler (PacketHandler *new_handler)
 Adds a new plugin to the ClusterManager.
virtual vpr::ReturnStatus attemptConnect (Node *node)=0
virtual void startListening (int listen_port, bool accept_anonymous)=0

Static Public Member Functions

static std::string getClusterNodeElementType ()
 Return the element type for cluster_node element that we configure here.
static bool isLocalHost (const std::string &testHostName)
 Determine if the given hostname matches the local machine's hostname.

Detailed Description

Network abstraction.

Definition at line 71 of file AbstractNetworkManager.h.


Constructor & Destructor Documentation

gadget::AbstractNetworkManager::AbstractNetworkManager (  ) 

Construct an empty representation of a network.

Definition at line 58 of file AbstractNetworkManager.cpp.

00059       : mNodes(0), mHandlerMap()
00060    {;}

gadget::AbstractNetworkManager::~AbstractNetworkManager (  )  [virtual]

Disconnect all nodes in network and release memory.

Definition at line 62 of file AbstractNetworkManager.cpp.

References shutdown().

00063    {
00064       shutdown();
00065    }


Member Function Documentation

void gadget::AbstractNetworkManager::handlePacket ( cluster::Packet packet,
Node node 
)

Process an incoming packet.

Definition at line 167 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR(), getHandlerByGUID(), gadget::PacketHandler::getHandlerName(), cluster::Packet::getPacketType(), cluster::Packet::getPluginId(), gadget::PacketHandler::handlePacket(), cluster::Header::RIM_CONNECTION_ACK, cluster::Header::RIM_CONNECTION_REQ, cluster::Header::RIM_END_BLOCK, and gadget::Node::setUpdated().

Referenced by gadget::Node::update().

00168    {
00169       // If the ClusterManager should handle this packet, then do so.
00170       if (packet->getPacketType() == cluster::Header::RIM_END_BLOCK)
00171       {
00172          // -Set New State
00173          if (node == NULL)
00174          {
00175             return;
00176          }
00177 
00178          node->setUpdated( true );
00179          return;
00180       }
00181       else if (packet->getPacketType() == cluster::Header::RIM_CONNECTION_REQ ||
00182                packet->getPacketType() == cluster::Header::RIM_CONNECTION_ACK)
00183       {
00184          //handleLocalPacket(packet, node);
00185          
00186          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CRITICAL_LVL )
00187             << clrOutBOLD( clrRED, "[ERROR] " )
00188             << "RIM_CONNECTION_REQ & RIM_CONNECTION_ACK data packet types are depreciated."
00189             << std::endl << vprDEBUG_FLUSH;
00190          return;
00191       }
00192 
00193       vpr::GUID handler_guid = packet->getPluginId();
00194 
00195       PacketHandler* temp_handler = getHandlerByGUID( handler_guid );
00196 
00197       if (NULL != temp_handler)
00198       {
00199          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00200             << clrOutBOLD(clrMAGENTA,"[AbstractNetworkManager]")
00201             << " Handler \"" << temp_handler->getHandlerName() << "\" will handle this packet."
00202             << std::endl << vprDEBUG_FLUSH;
00203 
00204 
00205          temp_handler->handlePacket( packet, node );
00206       }
00207       else
00208       {
00209          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00210             << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00211             << " Handler " << handler_guid.toString() << " does not exist to handle this packet."
00212             << std::endl << vprDEBUG_FLUSH;
00213       }
00214    }

void gadget::AbstractNetworkManager::updateNewConnections (  ) 

Definition at line 460 of file AbstractNetworkManager.cpp.

References gadget::Node::CONNECTED, debugDumpNodes(), gadgetDBG_NET_MGR(), getNumPendingNodes(), and gadget::Node::NEWCONNECTION.

00461    {
00462       // This fuction is needed in order to gurantee that all cluster
00463       // nodes become active at the same time, the beginning of the frame
00464       //
00465       // -Loop over all Nodes checking for new connections
00466       // -If Node is a new connection
00467       //   - Set it to connected
00468 
00469       bool new_connection = false;
00470       
00471       for (std::vector<Node*>::iterator i = mNodes.begin() ;
00472             i != mNodes.end() ; i++)
00473       {
00474          if ((*i)->getStatus() == Node::NEWCONNECTION)
00475          {
00476             vprDEBUG( gadgetDBG_NET_MGR, vprDBG_STATE_LVL )
00477                << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00478                << " Node: " << (*i)->getName()
00479                << " is now CONNECTED."
00480                << std::endl << vprDEBUG_FLUSH;
00481 
00482             new_connection = true;
00483             (*i)->start();
00484             (*i)->setStatus( Node::CONNECTED );
00485          }
00486       }
00487 
00488       // If we have pending nodes, attempt to connect to them.
00489       if (getNumPendingNodes() > 0)
00490       {
00491          attemptPendingNodes();
00492       }
00493       
00494       if (new_connection)
00495       {
00496          // - If the pending list is stale
00497          //   - Refresh the list
00498          if (jccl::ConfigManager::instance()->isPendingStale())
00499          {
00500             vprDEBUG( gadgetDBG_NET_MGR, vprDBG_STATE_LVL )
00501                << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00502                << " New connections were made, so refresh the pending list."
00503                << std::endl << vprDEBUG_FLUSH;
00504             jccl::ConfigManager::instance()->refreshPendingList();
00505          }
00506 
00507          debugDumpNodes(0);
00508       }
00509    }

vpr::ReturnStatus gadget::AbstractNetworkManager::addNode ( const std::string &  name,
const std::string &  host_name,
const vpr::Uint16 &  port,
vpr::SocketStream *  socketStream = NULL 
)

Creates a Node with the given parameters and adds this new node the std::map of Nodes.

The caller of this method mustlock the Nodes list first by callinf lockNodes()

Definition at line 216 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR().

Referenced by configAdd().

00218    {
00219       // -Create a new Node using the given information
00220       // -Add the new node to the AbstractNetworkManager
00221       
00222       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00223          << clrOutBOLD(clrMAGENTA,"[AbstractNetworkManager]")
00224          << " Adding node: " << name
00225          << std::endl << vprDEBUG_FLUSH;
00226 
00227       Node* temp_node = new Node(name, host_name, port, socketStream, this);
00228       mNodes.push_back( temp_node );
00229       
00230       return vpr::ReturnStatus::Succeed;
00231    }

void gadget::AbstractNetworkManager::addNode ( Node node  ) 

Adds the given Node to the std::map of Nodes.

The caller of this method mustlock the Nodes list first by callinf lockNodes()

Definition at line 233 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR(), and gadget::Node::getName().

00234    {
00235       // -Add the given node to the AbstractNetworkManager
00236       
00237       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00238          << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00239          << " Adding node: " << node->getName()
00240          << std::endl << vprDEBUG_FLUSH;
00241 
00242       mNodes.push_back( node );
00243    }

void gadget::AbstractNetworkManager::removeNode ( const std::string &  nodeHostname  ) 

Removes the Node with the given hostname.

Definition at line 245 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR().

00246    {
00247       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00248          << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00249          << " Removing node: " << nodeHostname
00250          << std::endl << vprDEBUG_FLUSH;
00251 
00252       for (std::vector<gadget::Node*>::iterator itr = mNodes.begin() ; itr != mNodes.end() ; itr++)
00253       {
00254          if ((*itr)->getHostname() == nodeHostname)
00255          {
00256             mNodes.erase(itr);
00257             return;
00258          }
00259       }
00260    }

Node * gadget::AbstractNetworkManager::getNodeByHostname ( const std::string &  host_name  ) 

Returns the Node with the given hostname If no Node with this hostname exists, NULL is returned.

Definition at line 262 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR().

00263    {
00264       vpr::DebugOutputGuard dbg_output( gadgetDBG_NET_MGR, vprDBG_VERB_LVL,
00265          std::string("-------- getNodeByHostname() --------\n"),
00266          std::string("--------------------------------------------\n"));
00267 
00268       vpr::InetAddr searching_for_node;
00269       searching_for_node.setAddress( host_name, 0 );
00270 
00271       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_VERB_LVL )
00272          << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00273          << " Looking for Node with hostname: " << host_name
00274          << std::endl << vprDEBUG_FLUSH;
00275  
00276          
00277       // -Find Node with given hostname and return a pointer to it.
00278       // -If we do not find one, return NULL
00279       for (std::vector<Node*>::iterator i = mNodes.begin();
00280            i != mNodes.end() ; i++)
00281       {
00282          vpr::InetAddr testing_node;
00283          testing_node.setAddress( (*i)->getHostname(), 0 );
00284          
00285          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_VERB_LVL )
00286             << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00287             << " Searcing for: " << searching_for_node.getAddressString()
00288             << " Testing: " << testing_node.getAddressString()
00289             << std::endl << vprDEBUG_FLUSH;
00290 
00291          if (searching_for_node.getAddressString() == testing_node.getAddressString())
00292          {
00293             return(*i);
00294          }
00295       }
00296 
00297       return(NULL);
00298    }

Node * gadget::AbstractNetworkManager::getNodeByName ( const std::string &  node_name  ) 

Returns the Node with the given name If no Node with this name exists, NULL is returned.

Definition at line 300 of file AbstractNetworkManager.cpp.

00301    {
00302       // -Find Node with given name and return a pointer to it.
00303       // -If we do not find one, return NULL
00304       for (std::vector<Node*>::iterator i = mNodes.begin();
00305            i != mNodes.end() ; i++)
00306       {
00307          if ((*i)->getName() == node_name)
00308          {
00309             return *i;
00310          }
00311       }
00312 
00313       return NULL;
00314    }

size_t gadget::AbstractNetworkManager::getNumNodes (  )  [inline]

Get the number of nodes in network.

Definition at line 138 of file AbstractNetworkManager.h.

00139    {
00140       return mNodes.size();
00141    }

void gadget::AbstractNetworkManager::debugDumpNodes ( int  debug_level  ) 

Print out debug information about all nodes.

Definition at line 362 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR().

Referenced by updateNewConnections().

00363    {
00364       vpr::DebugOutputGuard dbg_output(gadgetDBG_NET_MGR,debug_level,
00365          std::string("-------------- Cluster Network --------------\n"),
00366          std::string("---------------------------------------------\n"));
00367       for(std::vector<Node*>::iterator j = mNodes.begin(); j != mNodes.end(); j++)
00368       {
00369          (*j)->debugDump( debug_level );
00370       }
00371    }

std::vector<gadget::Node*>::iterator gadget::AbstractNetworkManager::getNodesBegin (  )  [inline]

Get an iterator to the beginning of the Nodes std::vector.

The caller of this method must have locked the Nodes list.

Definition at line 152 of file AbstractNetworkManager.h.

00153    {
00154       return mNodes.begin();
00155    }

std::vector<gadget::Node*>::iterator gadget::AbstractNetworkManager::getNodesEnd (  )  [inline]

Get an iterator to the end of the Nodes std::vector.

The caller of this method must have locked the Nodes list.

Definition at line 161 of file AbstractNetworkManager.h.

00162    {
00163       return mNodes.end();
00164    }

vpr::Uint16 gadget::AbstractNetworkManager::getNumPendingNodes (  ) 

Return the number of Nodes in the Pending Nodes list.

Definition at line 316 of file AbstractNetworkManager.cpp.

References gadget::Node::PENDING.

Referenced by updateNewConnections().

00317    {
00318       int num_pending = 0;
00319       
00320       for (std::vector<Node*>::iterator i = mNodes.begin();
00321            i != mNodes.end() ; i++)
00322       {
00323          if (Node::PENDING == (*i)->getStatus())
00324          {
00325             ++num_pending;
00326          }
00327       }
00328 
00329       return num_pending;
00330    }

void gadget::AbstractNetworkManager::shutdown (  ) 

Kill the listen thread and the update thread.

Definition at line 353 of file AbstractNetworkManager.cpp.

Referenced by ~AbstractNetworkManager().

00354    {
00355       for (std::vector<Node*>::iterator j = mNodes.begin(); j != mNodes.end(); j++)
00356       {
00357           (*j)->shutdown();
00358       }
00359    }

bool gadget::AbstractNetworkManager::recognizeClusterMachineConfig ( jccl::ConfigElementPtr  element  ) 

Determine if the given jccl::ConfigElement is a cluster_node element.

Definition at line 373 of file AbstractNetworkManager.cpp.

References getClusterNodeElementType().

Referenced by configAdd(), configCanHandle(), and configRemove().

00374    {
00375       return (element->getID() == getClusterNodeElementType());
00376    }

bool gadget::AbstractNetworkManager::configCanHandle ( jccl::ConfigElementPtr  element  ) 

Determine if we can handle the given jccl::ConfigElement.

Definition at line 378 of file AbstractNetworkManager.cpp.

References recognizeClusterMachineConfig().

00379    {
00380        return recognizeClusterMachineConfig(element);
00381    }

bool gadget::AbstractNetworkManager::configAdd ( jccl::ConfigElementPtr  element  ) 

Configure the given jccl::ConfigElement because it was just added to the active configuration.

Returns:
true If we successfully configured the given cluster_node element.

false If we failed to configure the given cluster_node element.

Definition at line 383 of file AbstractNetworkManager.cpp.

References addNode(), gadgetDBG_NET_MGR(), isLocalHost(), recognizeClusterMachineConfig(), and startListening().

00384    {
00385       if (recognizeClusterMachineConfig(element))
00386       {
00387          // -If local machine element
00388          //   -Add machine specific ConfigElements to the pending list.
00389          //   -Start Listening thread
00390          // -Else
00391          //   -Add Node to AbstractNetworkManager
00392 
00393          if (isLocalHost( element->getProperty<std::string>( "host_name" ) ))
00394          {
00395             // NOTE: Add all machine dependent ConfigElementPtr's here
00396             vprASSERT( element->getNum("display_system") == 1 
00397                && "A Cluster System element must have exactly 1 display_system element" );
00398 
00399             std::vector<jccl::ConfigElementPtr> cluster_node_elements =
00400                element->getChildElements();
00401 
00402             for (std::vector<jccl::ConfigElementPtr>::iterator i = cluster_node_elements.begin();
00403                  i != cluster_node_elements.end();
00404                  ++i)
00405             {
00406                jccl::ConfigManager::instance()->addConfigElement(*i, jccl::ConfigManager::PendingElement::ADD);
00407 
00408                vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrCYAN)
00409                   << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" )
00410                   << " Adding Machine specific ConfigElement: "
00411                   << (*i)->getName() << clrRESET << std::endl << vprDEBUG_FLUSH;
00412             }
00413 
00414             const int listen_port = element->getProperty<int>( "listen_port" );
00415             startListening( listen_port, false );
00416          }
00417          else
00418          {
00419             vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00420                << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00421                << " Adding Node: " << element->getName()
00422                << " to the Cluster Network\n" << vprDEBUG_FLUSH;
00423 
00424             std::string    name        = element->getName();
00425             std::string    host_name   = element->getProperty<std::string>( "host_name" );
00426             vpr::Uint16    listen_port = element->getProperty<int>( "listen_port" );
00427 
00428             addNode(name, host_name, listen_port);
00429          }
00430          return true;
00431       }
00432       return false;
00433    }

std::string gadget::AbstractNetworkManager::getClusterNodeElementType (  )  [static]

Return the element type for cluster_node element that we configure here.

Definition at line 455 of file AbstractNetworkManager.cpp.

Referenced by cluster::ClusterDepChecker::canHandle(), cluster::ClusterDepChecker::debugOutDependencies(), cluster::ClusterDepChecker::depSatisfied(), and recognizeClusterMachineConfig().

00456    {
00457       return "cluster_node";
00458    }

bool gadget::AbstractNetworkManager::configRemove ( jccl::ConfigElementPtr  element  ) 

Remove the given jccl::ConfigElement from the active configuration .

Returns:
true If we successfully removed the given cluster_node element.

false If we failed to removed the given cluster_node element.

Definition at line 435 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR(), and recognizeClusterMachineConfig().

00436    {
00437       if (recognizeClusterMachineConfig( element ))
00438       {
00439          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00440             << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00441             << " Removing the Node: " << element->getName()
00442             << " from the Cluster Network\n" << vprDEBUG_FLUSH;
00443          return true;
00444       }
00445       else
00446       {
00447          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00448             << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" )
00449             << " ERROR, Something is seriously wrong, we should never get here\n"
00450             << vprDEBUG_FLUSH;
00451          return false;
00452       }
00453    }

bool gadget::AbstractNetworkManager::isLocalHost ( const std::string &  testHostName  )  [static]

Determine if the given hostname matches the local machine's hostname.

Definition at line 70 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR().

Referenced by cluster::ApplicationDataManager::addSerializableObject(), cluster::SwapLockWiredPlugin::configAdd(), cluster::SwapLockTCPPlugin::configAdd(), cluster::StartBarrierPlugin::configAdd(), cluster::ClusterManager::configAdd(), cluster::ApplicationDataManager::configAdd(), configAdd(), and cluster::ClusterManager::recognizeRemoteDeviceConfig().

00071    {
00072       // Resolve the address of the hostname given to test.
00073       vpr::InetAddr remote_address;
00074       remote_address.setAddress(testHostName, 0);
00075 
00076       vprDEBUG(gadgetDBG_NET_MGR,vprDBG_HVERB_LVL)
00077          << "+======= Resolved addresses for given hostname ======+"
00078          << std::endl << vprDEBUG_FLUSH;
00079 
00080       std::string remote_hostname;
00081       if ( remote_address.getHostname(remote_hostname).failure() )
00082       {
00083          remote_hostname = "Error resolving remote hostname";
00084       }
00085 
00086       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00087             << "| Name: " << std::setw(25) << remote_hostname << " | "
00088             << std::setw(16) << remote_address.getAddressString() << " | "
00089             << std::endl << vprDEBUG_FLUSH;
00090 
00091       // Get all local interfaces.
00092       std::vector<vpr::InetAddr> local_interfaces;
00093       vpr::ReturnStatus status;
00094       status = vpr::InetAddr::getAllLocalAddrs(local_interfaces);
00095 
00096       if ( status.failure() )
00097       {
00098          vprDEBUG(gadgetDBG_NET_MGR, vprDBG_WARNING_LVL)
00099             << clrOutBOLD(clrYELLOW, "WARNING: ")
00100             << "Failed to get list of local interfaces!\n"
00101             << vprDEBUG_FLUSH;
00102 
00103          local_interfaces.clear();
00104          vpr::InetAddr local_addr;
00105          status = vpr::InetAddr::getLocalHost(local_addr);
00106 
00107          if ( status.success() )
00108          {
00109             local_interfaces.push_back(local_addr);
00110          }
00111          else
00112          {
00113             vprDEBUG(gadgetDBG_NET_MGR, vprDBG_WARNING_LVL)
00114                << clrOutBOLD(clrYELLOW, "WARNING: ")
00115                << "Failed to get local host!\n" << vprDEBUG_FLUSH;
00116          }
00117       }
00118 
00119       // Print debug information about all local interfaces.
00120       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00121          << "+================= Local interfaces =================+"
00122          << std::endl << vprDEBUG_FLUSH;
00123       for (std::vector<vpr::InetAddr>::iterator itr = local_interfaces.begin() ; itr != local_interfaces.end() ; ++itr)
00124       {
00125          std::string temp_hostname;
00126          if ( (*itr).getHostname(temp_hostname).failure() )
00127          {
00128             temp_hostname = "Error getting hostname";
00129          }
00130          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00131             << "| Name: " << std::setw(25) << temp_hostname << " | "
00132             << std::setw(16) << (*itr).getAddressString() << " | "
00133             << std::endl << vprDEBUG_FLUSH;
00134       }
00135 
00136       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00137          << "+====================================================+"
00138          << std::endl << vprDEBUG_FLUSH;
00139 
00140       bool result(false);
00141       for (std::vector<vpr::InetAddr>::iterator itr = local_interfaces.begin() ; itr != local_interfaces.end() ; ++itr)
00142       {
00143          if ((*itr).getAddressValue() == remote_address.getAddressValue())
00144          {
00145             vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00146                << "| We have a match.                  "
00147                << std::setw(16) << (*itr).getAddressString() << " |"
00148                << std::endl << vprDEBUG_FLUSH;
00149             result = true;
00150          }
00151          else
00152          {
00153             vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00154                << "| NO match.                         "
00155                << std::setw(16) << (*itr).getAddressString() << " |"
00156                << std::endl << vprDEBUG_FLUSH;
00157          }
00158       }
00159       vprDEBUG( gadgetDBG_NET_MGR, vprDBG_HVERB_LVL )
00160          << "+====================================================+"
00161          << std::endl << vprDEBUG_FLUSH;
00162 
00163       return result;
00164    }

PacketHandler * gadget::AbstractNetworkManager::getHandlerByGUID ( const vpr::GUID &  handler_guid  ) 

Definition at line 511 of file AbstractNetworkManager.cpp.

Referenced by handlePacket().

00512    {
00513       std::map<vpr::GUID, PacketHandler*>::const_iterator i = mHandlerMap.find( handler_guid );
00514       if (i != mHandlerMap.end())
00515       {
00516          return ((*i).second);
00517       }
00518       return NULL;
00519    }

void gadget::AbstractNetworkManager::addHandler ( PacketHandler new_handler  ) 

Adds a new plugin to the ClusterManager.

Definition at line 524 of file AbstractNetworkManager.cpp.

References gadgetDBG_NET_MGR(), gadget::PacketHandler::getHandlerGUID(), and gadget::PacketHandler::getHandlerName().

Referenced by cluster::ClusterManager::addPlugin().

00525    {
00526          std::pair<vpr::GUID, PacketHandler*> p 
00527             = std::make_pair( new_handler->getHandlerGUID(), new_handler );
00528          mHandlerMap.insert( p );
00529 
00530          vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL )
00531             << clrOutBOLD( clrMAGENTA, "[Reactor] " )
00532             << "Adding Handler: " << new_handler->getHandlerName() << std::endl << vprDEBUG_FLUSH;
00533    }

virtual vpr::ReturnStatus gadget::AbstractNetworkManager::attemptConnect ( Node node  )  [pure virtual]

Implemented in gadget::NetworkManager< A, C >.

virtual void gadget::AbstractNetworkManager::startListening ( int  listen_port,
bool  accept_anonymous 
) [pure virtual]

Implemented in gadget::NetworkManager< A, C >.

Referenced by configAdd().


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