An Overlay-based
Virtual Network Substrate
SpoVNet

source: source/ariba/overlay/OverlayBootstrap.h @ 8606

Last change on this file since 8606 was 7532, checked in by Christoph Mayer, 14 years ago

-von außen konfigurierbare bootstrap module, -periodicbroadcast crash fix

File size: 4.5 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef __OVERLAY_BOOTSTRAP_H
40#define __OVERLAY_BOOTSTRAP_H
41
42#include <string>
43#include <sstream>
44#include <ctime>
45#include <deque>
46#include <vector>
47#include <algorithm>
48#include <boost/thread/mutex.hpp>
49#include <boost/foreach.hpp>
50#include "ariba/utility/logging/Logging.h"
51#include "ariba/utility/types.h"
52#include "ariba/utility/system/Timer.h"
53#include "ariba/utility/bootstrap/BootstrapManager.h"
54#include "ariba/utility/bootstrap/BootstrapInformationCallback.h"
55#include "ariba/communication/EndpointDescriptor.h"
56#include "ariba/utility/system/SystemEventListener.h"
57#include "ariba/utility/system/SystemQueue.h"
58#include "ariba/utility/system/SystemEvent.h"
59#include "ariba/utility/system/SystemEventType.h"
60
61using std::swap;
62using std::deque;
63using std::string;
64using std::vector;
65using std::pair;
66using std::ostringstream;
67using ariba::utility::SpoVNetID;
68using ariba::utility::NodeID;
69using ariba::utility::BootstrapManager;
70using ariba::utility::BootstrapInformationCallback;
71using ariba::communication::EndpointDescriptor;
72using ariba::utility::SystemEventType;
73using ariba::utility::SystemEvent;
74using ariba::utility::SystemQueue;
75using ariba::utility::Timer;
76using ariba::utility::SystemEventListener;
77
78namespace ariba {
79namespace overlay {
80
81class BaseOverlay;
82
83class OverlayBootstrap : public BootstrapInformationCallback, public SystemEventListener {
84        use_logging_h(OverlayBootstrap);
85public:
86        OverlayBootstrap();
87        virtual ~OverlayBootstrap();
88
89        void start(
90                        BaseOverlay* _overlay,
91                        const SpoVNetID& _spovnetid,
92                        const NodeID& _nodeid,
93                        vector<pair<BootstrapManager::BootstrapType,string> > modules
94                        );
95        void stop();
96
97        void publish( const EndpointDescriptor& _ep );
98        void revoke();
99
100        void recordJoin(const EndpointDescriptor& _ep);
101        bool haveOverlayConnections();
102
103protected:
104        virtual void handleSystemEvent(const SystemEvent& event);
105        virtual void onBootstrapServiceFound(string name, string info1, string info2, string info);
106
107private:
108        class JoinData {
109        public:
110                JoinData() : spovnetid(), nodeid(), endpoint() {
111                }
112
113                JoinData& operator=( const JoinData& rhs) {
114                        spovnetid = rhs.spovnetid;
115                        nodeid = rhs.nodeid;
116                        endpoint = rhs.endpoint;
117                        return *this;
118                }
119
120                SpoVNetID spovnetid;
121                NodeID nodeid;
122                EndpointDescriptor endpoint;
123        };
124
125        BootstrapManager& manager;
126        SpoVNetID spovnetid;
127        NodeID nodeid;
128        BaseOverlay* overlay;
129        string randname;
130
131        class WatchdogTimer : public Timer {
132        public:
133                WatchdogTimer(OverlayBootstrap* _obj);
134                void startWatchdog();
135                void stopWatchdog();
136        protected:
137                virtual void eventFunction();
138        private:
139                OverlayBootstrap* obj;
140        };
141
142        typedef deque<JoinData> JoinStack;
143        JoinStack lastJoines;
144        boost::mutex lastJoinesMutex;
145        WatchdogTimer watchtimer;
146        void checkOverlayStatus();
147
148
149        bool haveOverlayConnection;
150        boost::mutex haveOverlayConnectionMutex;
151};
152
153}} // namespace ariba, overlay
154
155#endif // __OVERLAY_BOOTSTRAP_H
Note: See TracBrowser for help on using the repository browser.