OverSim
BootstrapList.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
25 #ifndef __BOOTSTRAPLIST_H_
26 #define __BOOTSTRAPLIST_H_
27 
28 #include <omnetpp.h>
29 #include <BaseApp.h>
30 #include <BootstrapNodeHandle.h>
31 #include <NodeVector.h>
32 #include <oversim_mapset.h>
33 
34 class BaseOverlay;
36 
37 typedef std::pair<TransportAddress, BootstrapNodeHandle*> NodePair;
38 // hash_map for accommodating bootstrap nodes
41 
53 class BootstrapList : public BaseApp
54 {
55 
56 public:
57  BootstrapList();
59 
68  const TransportAddress getBootstrapNode(int32_t overlayId = 0);
69 
75  void locateBootstrapNode(const NodeHandle& node);
76 
84  bool insertBootstrapCandidate(const NodeHandle& node,
86 
88 
95 
96  void removeBootstrapNode(const NodeHandle& node, int32_t overlayId = 0);
97 
98  void registerBootstrapNode(const NodeHandle& node, int32_t overlayId = 0);
99 
100 protected:
101  // see BaseRpc.h
102  virtual void pingResponse(PingResponse* pingResponse,
103  cPolymorphic* context, int rpcId,
104  simtime_t rtt);
105 
106  // see BaseRpc.h
107  virtual void pingTimeout(PingCall* pingCall,
108  const TransportAddress& dest,
109  cPolymorphic* context,
110  int rpcId);
111 
112  // see BaseOverlay.h
114 
115 private:
116  BootstrapNodeSet bootstrapList;
117 
118  // see BaseApp.h
119  virtual void initializeApp(int stage);
120 
121  // see BaseApp.h
122  virtual void finishApp();
123 
124  // see BaseApp.h
125  void handleTimerEvent(cMessage *msg);
126 
131 
132  // see BaseRpc.h
134  cPolymorphic* context, int rpcId,
135  simtime_t rtt);
136 
144 
145  static const int timerInterval = 10;
147  cMessage* timerMsg;
151 };
152 
153 #endif