OverSim
Pastry.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 __PASTRY_H_
25 #define __PASTRY_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 Pastry : public BasePastry
54 {
55  public:
56  virtual ~Pastry();
57 
58  // see BaseOverlay.h
59  virtual void initializeOverlay(int stage);
60 
61  // see BaseOverlay.h
62  virtual void handleTimerEvent(cMessage* msg);
63 
64  // see BaseOverlay.h
65  virtual void handleUDPMessage(BaseOverlayMessage* msg);
66 
68 
70  cPolymorphic* context, int rpcId,
71  simtime_t rtt);
72 
73  protected:
74 
75  virtual void purgeVectors(void);
76 
77  bool handleRpcCall(BaseCallMessage* msg);
78 
80 
82 
84 
86  cPolymorphic* context, int rpcId,
87  simtime_t rtt);
88 
90 
92 
94 
96 
98 
100  const TransportAddress& dest,
101  cPolymorphic* context, int rpcId,
102  const OverlayKey& key);
103 
109  virtual void changeState(int toState);
110 
111 
112  virtual bool recursiveRoutingHook(const TransportAddress& dest,
113  BaseRouteMessage* msg);
114 
115  void iterativeJoinHook(BaseOverlayMessage* msg, bool incrHopCount);
119  std::vector<PastryStateMsgHandle> stReceived;
120  std::vector<PastryStateMsgHandle>::iterator stReceivedPos;
121 
125  std::vector<TransportAddress> notifyList;
126 
127  std::vector<PastrySendState*> sendStateWait;
128 
129  private:
130 
131  void clearVectors();
132 
137 
139  int depth;
140 
142 
149 
152 
153  cMessage* secondStageWait;
154  cMessage* ringCheck;
155  cMessage* discoveryTimeout;
156  cMessage* repairTaskTimeout;
157 
161  void doSecondStage(void);
162 
163 
170 
179  bool handleFailedNode(const TransportAddress& failed);
180 
185  void checkProxCache(void);
186 
187  void processState(void);
188 
189  bool mergeState(void);
190 
191  void endProcessingState(void);
192 
196  void doJoinUpdate(void);
197 
198  // see BaseOverlay.h
199 
200  virtual void joinOverlay();
201 
207  void sendStateDelayed(const TransportAddress& destination);
208 };
209 
210 
211 #endif