Changeset 20316

Show
Ignore:
Timestamp:
06/21/07 15:30:14 (1 year ago)
Author:
aronb
Message:

Hack to ensure that we don't start listening for connections until we have fully configured all other nodes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.0/modules/gadgeteer/gadget/AbstractNetworkManager.cpp

    r18315 r20316  
    381381   } 
    382382 
     383   struct ElementPred 
     384   { 
     385      ElementPred(const std::string& type) 
     386         : mType(type) 
     387      { 
     388         /* Do nothing. */ ; 
     389      } 
     390 
     391      bool operator()(const jccl::ConfigManager::PendingElement& p) 
     392      { 
     393         return p.mElement->getID() == mType; 
     394      } 
     395 
     396      const std::string mType; 
     397   }; 
     398 
    383399   bool AbstractNetworkManager::configAdd(jccl::ConfigElementPtr element) 
    384400   { 
     
    393409         if (isLocalHost( element->getProperty<std::string>( "host_name" ) )) 
    394410         { 
     411            // XXX: Hack to ensure that we don't start listening for connections until 
     412            //      we have fully configured all other nodes. 
     413            ElementPred pred(getClusterNodeElementType()); 
     414 
     415            jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance(); 
     416            unsigned int num_pending_nodes = 
     417               std::count_if(cfg_mgr->getPendingBegin(), cfg_mgr->getPendingEnd(), pred); 
     418 
     419            if (num_pending_nodes > 1) 
     420            { 
     421               vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrRED) 
     422                  << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" ) 
     423                  << " Some nodes not configured yet: " << num_pending_nodes 
     424                  << clrRESET << std::endl << vprDEBUG_FLUSH; 
     425               return false; 
     426            } 
     427 
    395428            // NOTE: Add all machine dependent ConfigElementPtr's here 
    396429            vprASSERT( element->getNum("display_system") == 1