OverSim
Bamboo.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2012 Institute of Telematics, Karlsruhe Institute of Technology (KIT)
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 
24 #ifndef __BAMBOO_H_
25 #define __BAMBOO_H_
26 
27 #include <vector>
28 #include <map>
29 #include <queue>
30 #include <algorithm>
31 
32 #include <omnetpp.h>
33 #include <IPvXAddress.h>
34 
35 #include <OverlayKey.h>
36 #include <NodeHandle.h>
37 #include <BaseOverlay.h>
38 #include <BasePastry.h>
39 
40 #include "PastryTypes.h"
41 #include "PastryMessage_m.h"
42 #include "PastryRoutingTable.h"
43 #include "PastryLeafSet.h"
44 #include "PastryNeighborhoodSet.h"
45 
46 
53 class Bamboo : public BasePastry, public LookupListener
54 {
55  friend class BambooLookupListener;
56 
57  public:
58 
59  virtual ~Bamboo();
60 
61  // see BaseOverlay.h
62  virtual void initializeOverlay(int stage);
63 
64  // see BaseOverlay.h
65  virtual void handleTimerEvent(cMessage* msg);
66 
67  // see BaseOverlay.h
68  //virtual void handleUDPMessage(BaseOverlayMessage* msg);
69 
71  cPolymorphic* context, int rpcId,
72  simtime_t rtt);
73 
75 
77 
78  protected:
79 
80  void lookupFinished(AbstractLookup *lookup);
86  virtual void changeState(int toState);
87 
88  private:
89 
90  uint16_t rowToAsk;
91 
92  // local state tables
96 
98  cMessage* globalTuningTimer;
99  cMessage* localTuningTimer;
100 
105  void doLeafsetMaintenance(void);
106 
107  int getNextRowToMaintain();
108 
109  void doLocalTuning();
110 
114  void doGlobalTuning(void);
115 
124  bool handleFailedNode(const TransportAddress& failed);
125 
130  void checkProxCache(void);
131 
132  // see BaseOverlay.h
133  virtual void joinOverlay();
134 
135 };
136 
138 {
139  private:
141 
142  public:
144  {
145  this->overlay = overlay;
146  }
147 
148  virtual void lookupFinished(AbstractLookup *lookup)
149  {
150  overlay->lookupFinished(lookup);
151  delete this;
152  }
153 };
154 
155 
156 #endif