BootstrapList.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00025 #ifndef __BOOTSTRAPLIST_H_
00026 #define __BOOTSTRAPLIST_H_
00027 
00028 #include <omnetpp.h>
00029 #include <BaseApp.h>
00030 #include <BootstrapNodeHandle.h>
00031 #include <NodeVector.h>
00032 #include <oversim_mapset.h>
00033 
00034 class BaseOverlay;
00035 class ZeroconfConnector;
00036 
00037 typedef std::pair<TransportAddress, BootstrapNodeHandle*> NodePair;
00038 // hash_map for accommodating bootstrap nodes
00039 typedef UNORDERED_MAP<TransportAddress, BootstrapNodeHandle*,
00040                       TransportAddress::hashFcn> BootstrapNodeSet;
00041 
00053 class BootstrapList : public BaseApp
00054 {
00055 
00056 public:
00057     BootstrapList();
00058     ~BootstrapList();
00059 
00065     const TransportAddress getBootstrapNode();
00066 
00072    void locateBootstrapNode(const NodeHandle& node);
00073 
00081     bool insertBootstrapCandidate(const NodeHandle& node,
00082                                   BootstrapNodePrioType prio = DNSSD);
00083 
00084     bool insertBootstrapCandidate(BootstrapNodeHandle& node);
00085 
00091     void removeBootstrapCandidate(const TransportAddress &addr);
00092 
00093     void removeBootstrapNode(const NodeHandle& node);
00094 
00095     void registerBootstrapNode(const NodeHandle& node);
00096 
00097 protected:
00098     // see BaseRpc.h
00099     virtual void pingResponse(PingResponse* pingResponse,
00100                               cPolymorphic* context, int rpcId,
00101                               simtime_t rtt);
00102 
00103     // see BaseRpc.h
00104     virtual void pingTimeout(PingCall* pingCall,
00105                              const TransportAddress& dest,
00106                              cPolymorphic* context,
00107                              int rpcId);
00108 
00109     // see BaseOverlay.h
00110     virtual CompType getThisCompType() { return BOOTSTRAPLIST_COMP; };
00111 
00112 private:
00113     BootstrapNodeSet bootstrapList;
00114 
00115     // see BaseApp.h
00116     virtual void initializeApp(int stage);
00117 
00118     // see BaseApp.h
00119     virtual void finishApp();
00120 
00121     // see BaseApp.h
00122     void handleTimerEvent(cMessage *msg);
00123 
00127     void handleBootstrapListTimerExpired();
00128 
00129     // see BaseRpc.h
00130     void handleRpcResponse(BaseResponseMessage* msg,
00131                            cPolymorphic* context, int rpcId,
00132                            simtime_t rtt);
00133 
00140     void handleLookupResponse(LookupResponse* msg);
00141 
00142     static const int timerInterval = 10; 
00144     cMessage* timerMsg; 
00145     ZeroconfConnector* zeroconfConnector; 
00146     bool mergeOverlayPartitions; 
00147     bool maintainList; 
00148 };
00149 
00150 #endif
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3