ChordFingerTable Class Reference

#include <ChordFingerTable.h>

List of all members.


Detailed Description

Chord's finger table module.

This modul contains the finger table of the Chord implementation.

Author:
Markus Mauch, Ingmar Baumgart
See also:
Chord

Public Member Functions

virtual int numInitStages () const
virtual void initialize (int stage)
virtual void handleMessage (cMessage *msg)
virtual void initializeTable (uint size, const NodeHandle &owner, BaseOverlay *overlay)
 Sets up the finger table.
virtual void setFinger (uint pos, const NodeHandle &node)
 Sets a particular finger to point to node.
virtual void setFinger (uint pos, const Successors &nodes)
virtual bool updateFinger (uint pos, const NodeHandle &node, double rtt)
virtual const
NodeHandle
getFinger (uint pos)
 Returns the NodeVector of a particular finger.
virtual NodeVectorgetFinger (uint pos, const OverlayKey &key)
virtual uint getSize ()
 Returns the size of the finger table.

Protected Attributes

std::vector
< FingerEntry
fingerTable
 the finger table vector
BaseOverlayoverlay
 pointer to the main chord module

Member Function Documentation

virtual int ChordFingerTable::numInitStages (  )  const [inline, virtual]

00055     {
00056         return MAX_STAGE_OVERLAY + 1;
00057     }

void ChordFingerTable::initialize ( int  stage  )  [virtual]

00038 {
00039     // because of IPAddressResolver, we need to wait until interfaces
00040     // are registered, address auto-assignment takes place etc.
00041     if(stage != MIN_STAGE_OVERLAY)
00042         return;
00043 
00044     WATCH_VECTOR(fingerTable);
00045 }

void ChordFingerTable::handleMessage ( cMessage *  msg  )  [virtual]

00048 {
00049     error("this module doesn't handle messages, it runs only in initialize()");
00050 }

void ChordFingerTable::initializeTable ( uint  size,
const NodeHandle owner,
BaseOverlay overlay 
) [virtual]

Sets up the finger table.

Sets up the finger table and makes all fingers pointing to the node itself. Should be called on startup to initialize the finger table.

Parameters:
size number of fingers
owner set all fingers to the key of node handle owner
overlay pointer to the main chord module
00054 {
00055     Successors temp;
00056     //temp.insert(std::make_pair(-1, owner));
00057     //fingerTable.assign(size, temp);
00058     fingerTable.assign(size, FingerEntry(owner, temp));
00059     //std::cout << fingerTable[0].second.size() << std::endl;
00060     this->overlay = overlay;
00061 }

void ChordFingerTable::setFinger ( uint  pos,
const NodeHandle node 
) [virtual]

Sets a particular finger to point to node.

Parameters:
pos number of the finger to set
node set finger to this node
00069 {
00070     if (pos < fingerTable.size()) {
00071         Successors temp;
00072         fingerTable[pos] = FingerEntry(node, temp);
00073     } else {
00074         error("Index out of bound (ChordFingerTable, setFinger())");
00075     }
00076 }

void ChordFingerTable::setFinger ( uint  pos,
const Successors nodes 
) [virtual]

00079 {
00080     if (pos < fingerTable.size()) {
00081         fingerTable[pos] = FingerEntry(nodes.begin()->second, nodes);
00082     } else {
00083         error("Index out of bound (ChordFingerTable, setFinger())");
00084     }
00085 }

bool ChordFingerTable::updateFinger ( uint  pos,
const NodeHandle node,
double  rtt 
) [virtual]

00088 {
00089     if(rtt < 0)
00090         return false;
00091 
00092     Successors::iterator it;
00093     for(it = fingerTable[pos].second.begin(); it != fingerTable[pos].second.end(); it++)
00094         if(it->second == node)
00095             break;
00096     if(it == fingerTable[pos].second.end())
00097         return false;
00098 
00099     fingerTable[pos].second.erase(it);
00100     fingerTable[pos].second.insert(std::make_pair(rtt, node));
00101 
00102     return true;
00103 }

const NodeHandle & ChordFingerTable::getFinger ( uint  pos  )  [virtual]

Returns the NodeVector of a particular finger.

Parameters:
pos number of the finger to get
Returns:
NodeVector of the particular finger(s)
00106 {
00107     if (pos >= fingerTable.size())
00108         error("Index out of bound (ChordFingerTable, getFinger())");
00109 
00110     return fingerTable[pos].first;
00111 }

NodeVector * ChordFingerTable::getFinger ( uint  pos,
const OverlayKey key 
) [virtual]

00114 {
00115     if (pos >= fingerTable.size())
00116         error("Index out of bound (ChordFingerTable, getFinger())");
00117 
00118     NodeVector* nextHop = new NodeVector();
00119 
00120     for(Successors::const_iterator it = fingerTable[pos].second.begin();
00121         it != fingerTable[pos].second.end(); it++) {
00122         if(!key.isBetweenLR(fingerTable[pos].first.key, it->second.key)) {
00123             nextHop->push_back(it->second);
00124         }
00125     }
00126     if(nextHop->size() == 0)
00127         nextHop->push_back(fingerTable[pos].first);
00128     return nextHop;
00129 }

uint ChordFingerTable::getSize (  )  [virtual]

Returns the size of the finger table.

Returns:
number of fingers
00064 {
00065     return fingerTable.size();
00066 }


Member Data Documentation

std::vector<FingerEntry> ChordFingerTable::fingerTable [protected]

the finger table vector

BaseOverlay* ChordFingerTable::overlay [protected]

pointer to the main chord module


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:28 2008 for ITM OverSim by  doxygen 1.5.3