Changeset 5838


Ignore:
Timestamp:
Aug 11, 2009, 8:39:47 AM (15 years ago)
Author:
Christoph Mayer
Message:

watchdog bootstrapping und kleine relay fixes

Location:
source/ariba
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/SideportListener.cpp

    r5786 r5838  
    8686        if( overlay == NULL ) return false;
    8787
     88        bool relay = false;
     89
    8890        BOOST_FOREACH( LinkDescriptor* link, overlay->links ){
     91
     92                // is we find a direct connection this is not a relayed node
     93                if(link->relay == false && link->remoteNode == node && link->up)
     94                        return false;
     95
     96                // if we find a relay conenction this can be a relayed node
     97                // but only if we find no direct connection as above
    8998                if( link->relay && link->remoteNode == node && link->up)
    90                         return true;
     99                        relay = true;
    91100        }
    92101
    93         return false;
     102        return relay;
    94103}
    95104
  • source/ariba/overlay/BaseOverlay.cpp

    r5803 r5838  
    370370        }
    371371
    372 
    373372        //ovl.visShowNodeBubble ( ovlId, nodeId, "joining..." );
    374373        logging_info( "Starting to join spovnet " << id.toString() <<
     
    399398                const LinkID& lnk = bc->establishLink( bootstrapEp );
    400399                bootstrapLinks.push_back(lnk);
     400
    401401                logging_info("join process initiated for " << id.toString() << "...");
     402
    402403        }
    403404}
     
    11071108                                state = BaseOverlayStateCompleted;
    11081109                                overlayInterface->createOverlay();
    1109 
    11101110                                overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() );
     1111
     1112                                //record bootstrap ep as good endpoint to join
     1113                                overlayBootstrap.recordJoin( replyMsg->getBootstrapEndpoint() );
    11111114
    11121115                                // update ovlvis
     
    15551558
    15561559vector<NodeID> BaseOverlay::getOverlayNeighbors(bool deep) const {
     1560
     1561        vector<NodeID> nodes = overlayInterface->getKnownNodes(deep);
     1562
    15571563        // the known nodes _can_ also include our node, so we remove ourself
    1558         vector<NodeID> nodes = overlayInterface->getKnownNodes(deep);
    1559 
    15601564        vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId );
    15611565        if( i != nodes.end() ) nodes.erase( i );
  • source/ariba/overlay/OverlayBootstrap.cpp

    r5412 r5838  
    5050                spovnetid( SpoVNetID::UNSPECIFIED ),
    5151                nodeid( NodeID::UNSPECIFIED ),
    52                 overlay( NULL ){
     52                overlay( NULL ),
     53                watchtimer(this) {
     54
     55        srand(time(NULL));
    5356}
    5457
     
    6669        manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
    6770        manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp );
     71
     72        watchtimer.startWatchdog();
    6873}
    6974
     
    7883        manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast );
    7984        manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp );
     85
     86        watchtimer.stopWatchdog();
    8087}
    8188
     
    144151}
    145152
     153void OverlayBootstrap::recordJoin(const EndpointDescriptor& _ep){
     154        boost::mutex::scoped_lock lock(lastJoinesMutex);
     155
     156        EventData data;
     157        data.spovnetid = spovnetid;
     158        data.nodeid = nodeid;
     159        data.endpoint = _ep;
     160
     161        lastJoines.push_front(JoinData(data));
     162}
     163
     164void OverlayBootstrap::checkOverlayStatus(){
     165
     166        // if we have no overlay neighbors, try to bootstrap using
     167        // bootstrap information that we already used
     168
     169        {       //limit history to 10 endpoints
     170                boost::mutex::scoped_lock lock(lastJoinesMutex);
     171                while(lastJoines.size() > 10)
     172                        lastJoines.pop_back();
     173        }
     174
     175        // we have overlay neighbors -> ok
     176        if(overlay->getOverlayNeighbors().size() > 0) return;
     177
     178        // no overlay neighbors -> try out already
     179        // successfully used bootstrap nodes
     180        JoinData data;
     181        {
     182                boost::mutex::scoped_lock lock(lastJoinesMutex);
     183                JoinStack::iterator i = lastJoines.begin();
     184                if(i == lastJoines.end()) return;
     185
     186                // use last used element and then put it into back
     187                JoinData data = *i;
     188                lastJoines.pop_front();
     189                lastJoines.push_back(data);
     190        }
     191
     192        logging_info("no overlay connections detected, " <<
     193                                        "trying to join using old bootstrap information");
     194
     195        // try to join using this node, if the join is successfull
     196        // the endpoint will again be inserted using recordJoin
     197        overlay->joinSpoVNet( spovnetid, data.data.endpoint );
     198}
     199
     200OverlayBootstrap::WatchdogTimer::WatchdogTimer(OverlayBootstrap* _obj) : obj(_obj) {
     201}
     202
     203void OverlayBootstrap::WatchdogTimer::startWatchdog(){
     204        Timer::setInterval(2000);
     205        Timer::start();
     206}
     207
     208void OverlayBootstrap::WatchdogTimer::stopWatchdog(){
     209        Timer::stop();
     210}
     211
     212void OverlayBootstrap::WatchdogTimer::eventFunction(){
     213        if(obj == NULL) return;
     214        obj->checkOverlayStatus();
     215}
     216
    146217}} // namespace ariba, overlay
  • source/ariba/overlay/OverlayBootstrap.h

    r4866 r5838  
    4242#include <string>
    4343#include <sstream>
     44#include <ctime>
     45#include <deque>
     46#include <boost/thread/mutex.hpp>
    4447#include "ariba/utility/logging/Logging.h"
    4548#include "ariba/utility/types.h"
     49#include "ariba/utility/system/Timer.h"
    4650#include "ariba/utility/bootstrap/BootstrapManager.h"
    4751#include "ariba/utility/bootstrap/BootstrapInformationCallback.h"
     
    5256#include "ariba/utility/system/SystemEventType.h"
    5357
     58using std::deque;
    5459using std::string;
    5560using std::ostringstream;
     
    6267using ariba::utility::SystemEvent;
    6368using ariba::utility::SystemQueue;
     69using ariba::utility::Timer;
    6470using ariba::utility::SystemEventListener;
    6571
     
    8187        void revoke();
    8288
     89        void recordJoin(const EndpointDescriptor& _ep);
     90
    8391protected:
    8492        virtual void handleSystemEvent(const SystemEvent& event);
     
    8694
    8795private:
    88         typedef struct _EventData {
     96        class EventData {
     97        public:
    8998                SpoVNetID spovnetid;
    9099                NodeID nodeid;
    91100                EndpointDescriptor endpoint;
    92         } EventData;
     101        };
    93102
    94103        BootstrapManager& manager;
     
    98107        string randname;
    99108
     109        class JoinData {
     110        public:
     111                time_t timestamp;
     112                EventData data;
     113
     114                JoinData(const EventData& _data){
     115                        timestamp = time(NULL);
     116                        data = _data;
     117                }
     118
     119                JoinData(){
     120                        timestamp = time(NULL);
     121                }
     122        };
     123
     124        class WatchdogTimer : public Timer {
     125        public:
     126                WatchdogTimer(OverlayBootstrap* _obj);
     127                void startWatchdog();
     128                void stopWatchdog();
     129        protected:
     130                virtual void eventFunction();
     131        private:
     132                OverlayBootstrap* obj;
     133        };
     134
     135        typedef deque<JoinData> JoinStack;
     136        JoinStack lastJoines;
     137        boost::mutex lastJoinesMutex;
     138        WatchdogTimer watchtimer;
     139        void checkOverlayStatus();
    100140};
    101141
  • source/ariba/utility/bootstrap/modules/periodicbroadcast/PeriodicBroadcast.cpp

    r5532 r5838  
    5858
    5959use_logging_cpp(PeriodicBroadcast);
    60 const long PeriodicBroadcast::timerinterval = 2;
    61 const long PeriodicBroadcast::servicetimeout = 5;
     60const long PeriodicBroadcast::timerinterval = 1;
     61const long PeriodicBroadcast::servicetimeout = 3;
    6262const unsigned int PeriodicBroadcast::serverport_v4 = 5634;
    6363const unsigned int PeriodicBroadcast::serverport_v6 = 5636;
Note: See TracChangeset for help on using the changeset viewer.