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 NodeHandlegetFinger (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< FingerEntryfingerTable
 the finger table vector
BaseOverlayoverlay
 pointer to the main chord module

Member Function Documentation

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

00056     {
00057         return MAX_STAGE_OVERLAY + 1;
00058     }

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

00031 {
00032     // because of IPAddressResolver, we need to wait until interfaces
00033     // are registered, address auto-assignment takes place etc.
00034     if(stage != MIN_STAGE_OVERLAY)
00035         return;
00036 
00037     WATCH_VECTOR(fingerTable);
00038 }

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

00041 {
00042     error("this module doesn't handle messages, it runs only in initialize()");
00043 }

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

Referenced by Chord::initializeFriendModules().

00047 {
00048     Successors temp;
00049     fingerTable.assign(size, FingerEntry(owner, temp));
00050     this->overlay = overlay;
00051 }

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

Referenced by Chord::handleFixFingersTimerExpired(), Chord::handleRpcFixfingersResponse(), and Chord::pingTimeout().

00059 {
00060     if (pos < fingerTable.size()) {
00061         Successors temp;
00062         fingerTable[pos] = FingerEntry(node, temp);
00063     } else {
00064         error("Index out of bound (ChordFingerTable, setFinger())");
00065     }
00066 }

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

00069 {
00070     if (pos < fingerTable.size()) {
00071         fingerTable[pos] = FingerEntry(nodes.begin()->second, nodes);
00072     } else {
00073         error("Index out of bound (ChordFingerTable, setFinger())");
00074     }
00075 }

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

Referenced by Chord::pingResponse().

00078 {
00079     if(rtt < 0)
00080         return false;
00081 
00082     Successors::iterator it;
00083     for(it = fingerTable[pos].second.begin(); it != fingerTable[pos].second.end(); it++)
00084         if(it->second == node)
00085             break;
00086     if(it == fingerTable[pos].second.end())
00087         return false;
00088 
00089     fingerTable[pos].second.erase(it);
00090     fingerTable[pos].second.insert(std::make_pair(rtt, node));
00091 
00092     return true;
00093 }

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)

Referenced by Chord::closestPreceedingNode(), Chord::handleStabilizeTimerExpired(), and Chord::pingTimeout().

00096 {
00097     if (pos >= fingerTable.size())
00098         error("Index out of bound (ChordFingerTable, getFinger())");
00099 
00100     return fingerTable[pos].first;
00101 }

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

00104 {
00105     if (pos >= fingerTable.size())
00106         error("Index out of bound (ChordFingerTable, getFinger())");
00107 
00108     NodeVector* nextHop = new NodeVector();
00109 
00110     for(Successors::const_iterator it = fingerTable[pos].second.begin();
00111     it != fingerTable[pos].second.end(); it++) {
00112         if(!key.isBetweenLR(fingerTable[pos].first.key, it->second.key)) {
00113             nextHop->push_back(it->second);
00114         }
00115     }
00116     if(nextHop->size() == 0)
00117         nextHop->push_back(fingerTable[pos].first);
00118     return nextHop;
00119 }

uint ChordFingerTable::getSize (  )  [virtual]

Returns the size of the finger table.

Returns:
number of fingers

Referenced by Chord::closestPreceedingNode().

00054 {
00055     return fingerTable.size();
00056 }


Member Data Documentation

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

the finger table vector

Referenced by getFinger(), getSize(), initialize(), initializeTable(), setFinger(), and updateFinger().

pointer to the main chord module


The documentation for this class was generated from the following files:

Generated on Fri Sep 19 13:05:06 2008 for ITM OverSim by  doxygen 1.5.5