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

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

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

File size: 4.5 KB
RevLine 
[4836]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>
[5838]44#include <ctime>
45#include <deque>
[7532]46#include <vector>
[5860]47#include <algorithm>
[5838]48#include <boost/thread/mutex.hpp>
[7532]49#include <boost/foreach.hpp>
[4836]50#include "ariba/utility/logging/Logging.h"
51#include "ariba/utility/types.h"
[5838]52#include "ariba/utility/system/Timer.h"
[4836]53#include "ariba/utility/bootstrap/BootstrapManager.h"
54#include "ariba/utility/bootstrap/BootstrapInformationCallback.h"
55#include "ariba/communication/EndpointDescriptor.h"
[4866]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"
[4836]60
[5860]61using std::swap;
[5838]62using std::deque;
[4836]63using std::string;
[7532]64using std::vector;
65using std::pair;
[4836]66using std::ostringstream;
67using ariba::utility::SpoVNetID;
68using ariba::utility::NodeID;
69using ariba::utility::BootstrapManager;
70using ariba::utility::BootstrapInformationCallback;
71using ariba::communication::EndpointDescriptor;
[4866]72using ariba::utility::SystemEventType;
73using ariba::utility::SystemEvent;
74using ariba::utility::SystemQueue;
[5838]75using ariba::utility::Timer;
[4866]76using ariba::utility::SystemEventListener;
[4836]77
78namespace ariba {
79namespace overlay {
80
81class BaseOverlay;
82
[4866]83class OverlayBootstrap : public BootstrapInformationCallback, public SystemEventListener {
[4836]84 use_logging_h(OverlayBootstrap);
85public:
86 OverlayBootstrap();
87 virtual ~OverlayBootstrap();
88
[7532]89 void start(
90 BaseOverlay* _overlay,
91 const SpoVNetID& _spovnetid,
92 const NodeID& _nodeid,
93 vector<pair<BootstrapManager::BootstrapType,string> > modules
94 );
[4836]95 void stop();
96
97 void publish( const EndpointDescriptor& _ep );
98 void revoke();
99
[5838]100 void recordJoin(const EndpointDescriptor& _ep);
[5967]101 bool haveOverlayConnections();
[5838]102
[4836]103protected:
[4866]104 virtual void handleSystemEvent(const SystemEvent& event);
[4836]105 virtual void onBootstrapServiceFound(string name, string info1, string info2, string info);
106
107private:
[5860]108 class JoinData {
[5838]109 public:
[5860]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;
[6919]117 return *this;
[5860]118 }
119
[4866]120 SpoVNetID spovnetid;
121 NodeID nodeid;
122 EndpointDescriptor endpoint;
[5838]123 };
[4866]124
[4836]125 BootstrapManager& manager;
126 SpoVNetID spovnetid;
127 NodeID nodeid;
128 BaseOverlay* overlay;
129 string randname;
130
[5838]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();
[5967]147
148
149 bool haveOverlayConnection;
150 boost::mutex haveOverlayConnectionMutex;
[4836]151};
152
153}} // namespace ariba, overlay
154
155#endif // __OVERLAY_BOOTSTRAP_H
Note: See TracBrowser for help on using the repository browser.