ChordFingerTable.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 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 
00024 #ifndef __CHORDFINGERTABLE_H_
00025 #define __CHORDFINGERTABLE_H_
00026 
00027 #include <deque>
00028 #include <map>
00029 
00030 #include <omnetpp.h>
00031 
00032 #include <NodeVector.h>
00033 #include <InitStages.h>
00034 
00035 class BaseOverlay;
00036 
00037 namespace oversim {
00038 
00039 typedef std::multimap<simtime_t, NodeHandle> Successors;
00040 typedef std::pair<NodeHandle, Successors> FingerEntry;
00041 
00042 class Chord;
00043 
00052 class ChordFingerTable : public cSimpleModule
00053 {
00054   public:
00055 
00056     virtual int numInitStages() const
00057     {
00058         return MAX_STAGE_OVERLAY + 1;
00059     }
00060 
00061     virtual void initialize(int stage);
00062     virtual void handleMessage(cMessage* msg);
00063 
00075     virtual void initializeTable(uint32_t size, const NodeHandle& owner,
00076                                  Chord* overlay);
00077 
00086     virtual void setFinger(uint32_t pos, const NodeHandle& node,
00087                            Successors const* sucNodes = NULL);
00088     virtual void setFinger(uint32_t pos, const Successors& nodes);
00089 
00090     virtual bool updateFinger(uint32_t pos, const NodeHandle& node, simtime_t rtt);
00091 
00098     virtual const NodeHandle& getFinger(uint32_t pos);
00099 
00100     virtual NodeVector* getFinger(uint32_t pos, const OverlayKey& key);
00101 
00102     bool handleFailedNode(const TransportAddress& failed);
00103 
00109     void removeFinger(uint32_t pos);
00110 
00116     virtual uint32_t getSize();
00117 
00118 private:
00119 
00120     uint32_t maxSize; 
00121     std::deque<FingerEntry> fingerTable; 
00122     Chord* overlay; 
00123 };
00124 
00125 }; //namespace
00126 
00127 std::ostream& operator<<(std::ostream& os, const oversim::Successors& suc);
00128 std::ostream& operator<<(std::ostream& os, const oversim::FingerEntry& entry);
00129 
00130 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3