NodeHandle Class Reference

#include <NodeHandle.h>

Inheritance diagram for NodeHandle:

TransportAddress BootstrapNodeHandle BrooseHandle GiaNode KademliaBucketEntry

List of all members.


Detailed Description

This class implements a node handle.


It covers the complete node information, like IP-Address, port, NodeKey and some additional flags for Simulation behaviour. The information can be sparse, so parts can be omited by setting the property to an unspecified value.

Author:
Markus Mauch

Sebastian Mies

Definition at line 50 of file NodeHandle.h.


Public Types

typedef UNORDERED_SET
< NodeHandle, hashFcn > 
Set
 a hash_set of NodeHandles

Public Member Functions

 NodeHandle ()
 Constructs an unspecified NodeHandle.
virtual ~NodeHandle ()
 Standard destructor.
 NodeHandle (const NodeHandle &handle)
 Copy constructor.
 NodeHandle (const OverlayKey &key, const IPvXAddress &ip, int port)
 Complete constructor.
 NodeHandle (const TransportAddress &ta)
 Constructor to generate a NodeHandle from a TransportAddress.
bool operator== (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator!= (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator< (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator> (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator<= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator>= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
NodeHandle & operator= (const NodeHandle &rhs)
 assigns key, ip and port of rhs to this->key, this->ip and this->port
void setKey (const OverlayKey &key)
 saves given key to NodeHandle::key
const OverlayKey & getKey () const
 returns key of this NodeHandle
bool isUnspecified () const
 indicates if this NodeHandle is specified
virtual void netPack (cCommBuffer *b)
 serializes the object into a buffer
virtual void netUnpack (cCommBuffer *b)
 deserializes the object from a buffer
virtual TransportAddress * dup () const
 returns a copy of the NodeHandle

Public Attributes

OverlayKey key
 the OverlayKey of this NodeHandle

Static Public Attributes

static const NodeHandle UNSPECIFIED_NODE
 the unspecified NodeHandle

Private Member Functions

void assertUnspecified (const NodeHandle &handle) const
 throws an opp_error if this or handle is unspecified

Friends

std::ostream & operator<< (std::ostream &os, const NodeHandle &n)
 standard output stream for NodeHandle, gives out ip, port and key

Member Typedef Documentation

typedef UNORDERED_SET<NodeHandle, hashFcn> NodeHandle::Set

a hash_set of NodeHandles

Reimplemented from TransportAddress.

Definition at line 53 of file NodeHandle.h.


Constructor & Destructor Documentation

NodeHandle::NodeHandle (  ) 

Constructs an unspecified NodeHandle.

Definition at line 43 of file NodeHandle.cc.

Referenced by dup().

00044 {
00045     port = -1;
00046     key = OverlayKey(); // unspecified key, note: OverlayKey::UNSPECIFIED_KEY might not be initialized here
00047 }

virtual NodeHandle::~NodeHandle (  )  [inline, virtual]

Standard destructor.

Definition at line 68 of file NodeHandle.h.

00068 {};

NodeHandle::NodeHandle ( const NodeHandle &  handle  ) 

Copy constructor.

Parameters:
handle The NodeHandle to copy

Definition at line 50 of file NodeHandle.cc.

00051 {
00052     key = handle.key;
00053     port = handle.port;
00054     ip = handle.ip;
00055 }

NodeHandle::NodeHandle ( const OverlayKey &  key,
const IPvXAddress &  ip,
int  port 
)

Complete constructor.

Parameters:
key The OverlayKey
ip The IPvXAddress
port The UDP-Port

Definition at line 65 of file NodeHandle.cc.

00067 {
00068     this->ip = ip;
00069     this->port = port;
00070     this->key = key;
00071 }

NodeHandle::NodeHandle ( const TransportAddress &  ta  ) 

Constructor to generate a NodeHandle from a TransportAddress.

The key will be unspecified.

Parameters:
ta transport address

Definition at line 57 of file NodeHandle.cc.

00058 {
00059     this->ip = ta.ip;
00060     this->port = ta.port;
00061     this->key = OverlayKey::UNSPECIFIED_KEY;
00062 }


Member Function Documentation

bool NodeHandle::operator== ( const NodeHandle &  rhs  )  const

compares this NodeHandle to another given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if OverlayKey, IPvXAddress and port is equal, false otherwise

Definition at line 90 of file NodeHandle.cc.

00091 {
00092     assertUnspecified( rhs );
00093     return ( this->key == rhs.key &&
00094              this->ip == rhs.ip && this->port == rhs.port );
00095 }

bool NodeHandle::operator!= ( const NodeHandle &  rhs  )  const

compares this NodeHandle to another given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if OverlayKey, IPvXAddress and port is not equal, false otherwise

Definition at line 98 of file NodeHandle.cc.

00099 {
00100     assertUnspecified( rhs );
00101     return !( this->key == rhs.key &&
00102               this->ip == rhs.ip && this->port == rhs.port );
00103 }

bool NodeHandle::operator< ( const NodeHandle &  rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is smaller than rhs->key, false otherwise

Definition at line 106 of file NodeHandle.cc.

00107 {
00108     assertUnspecified(rhs);
00109     return this->key < rhs.key;
00110 }

bool NodeHandle::operator> ( const NodeHandle &  rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is greater than rhs->key, false otherwise

Definition at line 113 of file NodeHandle.cc.

00114 {
00115     assertUnspecified(rhs);
00116     return this->key > rhs.key;
00117 }

bool NodeHandle::operator<= ( const NodeHandle &  rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is smaller than or equal to rhs->key, false otherwise

Definition at line 120 of file NodeHandle.cc.

00121 {
00122     assertUnspecified(rhs);
00123     return this->key <= rhs.key;
00124 }

bool NodeHandle::operator>= ( const NodeHandle &  rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is greater than or equal to rhs->key, false otherwise

Definition at line 127 of file NodeHandle.cc.

00128 {
00129     assertUnspecified(rhs);
00130     return this->key >= rhs.key;
00131 }

NodeHandle & NodeHandle::operator= ( const NodeHandle &  rhs  ) 

assigns key, ip and port of rhs to this->key, this->ip and this->port

Parameters:
rhs the NodeHandle with the defined key, ip and port
Returns:
this NodeHandle object

Reimplemented in GiaNode.

Definition at line 80 of file NodeHandle.cc.

00081 {
00082     this->key = rhs.key;
00083     this->ip = rhs.ip;
00084     this->port = rhs.port;
00085 
00086     return *this;
00087 }

void NodeHandle::setKey ( const OverlayKey &  key  ) 

saves given key to NodeHandle::key

Parameters:
key the given key

Definition at line 134 of file NodeHandle.cc.

Referenced by PubSubMMOG::initializeOverlay(), and PubSubLobby::initializeOverlay().

00135 {
00136     this->key = key;
00137 }

const OverlayKey & NodeHandle::getKey (  )  const

returns key of this NodeHandle

Returns:
the key of this NodeHandle

Definition at line 140 of file NodeHandle.cc.

Referenced by Kademlia::handleBucketRefreshTimerExpired(), DHT::handlePutRequest(), Kademlia::isSiblingFor(), Kademlia::routingAdd(), Kademlia::routingBucketIndex(), and Kademlia::routingInit().

00141 {
00142     return key;
00143 }

bool NodeHandle::isUnspecified (  )  const

indicates if this NodeHandle is specified

Returns:
true, if NodeHandle has no ip or key specified, false otherwise

Reimplemented from TransportAddress.

Definition at line 74 of file NodeHandle.cc.

Referenced by Gia::acceptNode(), GiaNeighborCandidateList::add(), assertUnspecified(), BaseOverlay::callUpdate(), Gia::changeState(), oversim::Chord::changeState(), Scribe::checkGroupEmpty(), oversim::Chord::closestPreceedingNode(), PubSubLobby::failedNode(), PastryRoutingTable::findCloserNode(), PastryLeafSet::findCloserNode(), PastryRoutingTable::findCloserNodes(), oversim::Koorde::findDeBruijnHop(), oversim::Chord::findNode(), BasePastry::findNode(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), GiaNeighbors::get(), GlobalNodeList::getBootstrapNode(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimerExpired(), oversim::Chord::handleFailedNode(), PubSubMMOG::handleIntermediateResponse(), PubSubLobby::handleJoin(), PubSubMMOG::handleJoinResponse(), PubSubMMOG::handleMove(), PubSubMMOG::handlePingCallTimeout(), DHT::handlePutRequest(), PubSubLobby::handleRespCall(), oversim::Chord::handleRpcJoinResponse(), oversim::Koorde::handleRpcStabilizeResponse(), Scribe::handleTimerEvent(), Pastry::handleTimerEvent(), Gia::handleTimerEvent(), oversim::Chord::handleTimerEvent(), Pastry::handleUDPMessage(), PastryLeafSet::insertLeaf(), PastryStateObject::isCloser(), oversim::Chord::isSiblingFor(), Gia::joinOverlay(), BootstrapList::locateBootstrapNode(), PastryRoutingTable::lookupNextHop(), BrooseHandle::operator!=(), operator<<(), BrooseHandle::operator==(), BaseRpc::pingNode(), BasePastry::pingNodes(), BootstrapList::pingResponse(), BasePastry::pingResponse(), BaseRpc::pingRpcResponse(), oversim::Chord::pingTimeout(), BasePastry::prePing(), PastryRoutingTable::repair(), Kademlia::routingAdd(), oversim::Chord::rpcFixfingers(), oversim::Koorde::rpcJoin(), oversim::Chord::rpcJoin(), oversim::Koorde::rpcNotify(), oversim::Chord::rpcNotify(), oversim::Chord::rpcStabilize(), PubSubMMOG::sendMessageToChildren(), BaseOverlay::sendToKey(), and PubSubMMOG::unsubscribeChild().

00075 {
00076     return (ip.isUnspecified() || key.isUnspecified());
00077 }

void NodeHandle::assertUnspecified ( const NodeHandle &  handle  )  const [inline, private]

throws an opp_error if this or handle is unspecified

Parameters:
handle the NodeHandle to check

Definition at line 147 of file NodeHandle.cc.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

00148 {
00149     if ( this->isUnspecified() || handle.isUnspecified() )
00150         opp_error("NodeHandle: Trying to compare unspecified NodeHandle!");
00151 }

void NodeHandle::netPack ( cCommBuffer *  b  )  [virtual]

serializes the object into a buffer

Parameters:
b the buffer

Definition at line 154 of file NodeHandle.cc.

Referenced by doPacking().

00155 {
00156     //cMessage::netPack(b);
00157     doPacking(b,this->ip);
00158     doPacking(b,this->key);
00159     doPacking(b,this->port);
00160 }

void NodeHandle::netUnpack ( cCommBuffer *  b  )  [virtual]

deserializes the object from a buffer

Parameters:
b the buffer

Definition at line 162 of file NodeHandle.cc.

Referenced by doUnpacking().

00163 {
00164     //cMessage::netUnpack(b);
00165     doUnpacking(b,this->ip);
00166     doUnpacking(b,this->key);
00167     doUnpacking(b,this->port);
00168 }

TransportAddress * NodeHandle::dup (  )  const [virtual]

returns a copy of the NodeHandle

Returns:
a copy of the NodeHandle

Reimplemented from TransportAddress.

Definition at line 170 of file NodeHandle.cc.

00171 {
00172     return new NodeHandle(*this);
00173 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const NodeHandle &  n 
) [friend]

standard output stream for NodeHandle, gives out ip, port and key

Parameters:
os the ostream
n the NodeHandle
Returns:
the output stream

Definition at line 30 of file NodeHandle.cc.

00031 {
00032     if (n.isUnspecified()) {
00033         os << "<unspec>";
00034     } else {
00035         os << n.ip << ":" << n.port << " " << n.key;
00036     }
00037 
00038     return os;
00039 };


Member Data Documentation

the OverlayKey of this NodeHandle

Definition at line 56 of file NodeHandle.h.

Referenced by BrooseBucket::add(), GiaMessageBookkeeping::addMessage(), PastryRoutingTable::addRow(), IterativeLookup::addSibling(), QuonPR::addSite(), QuonP::addSite(), oversim::ChordSuccessorList::addSuccessor(), BasePastry::baseChangeState(), BasePastry::baseInit(), BaseOverlay::bindToPort(), BootstrapNodeHandle::BootstrapNodeHandle(), BrooseHandle::BrooseHandle(), BaseApp::callRoute(), BaseOverlay::callUpdate(), Vast::changeState(), QuonPR::changeState(), QuonP::changeState(), Pastry::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Bamboo::changeState(), Pastry::checkProxCache(), oversim::Chord::closestPreceedingNode(), GiaNeighborCandidateList::contains(), QuonPR::deleteSite(), QuonP::deleteSite(), KBRTestApp::deliver(), Broose::displayBucketState(), BasePastry::doRoutingTableMaintenance(), Pastry::doSecondStage(), ConnectivityProbe::extractTopology(), PastryRoutingTable::findCloserNode(), oversim::Koorde::findDeBruijnHop(), oversim::Koorde::findNode(), oversim::Chord::findNode(), Broose::findNode(), BaseOverlay::findNodeRpc(), BasePastry::finishOverlay(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), PastryLeafSet::getBiggestKey(), BrooseBucket::getClosestNode(), PastryLeafSet::getDestinationNode(), QuonPR::getKey(), QuonP::getKey(), getKey(), Gia::getRoute(), PastryLeafSet::getSmallestKey(), PubSubMMOG::handleAdoptChildCall(), PubSubMMOG::handleAdoptChildResponse(), Vast::handleAppMessage(), QuonPR::handleAppMessage(), QuonP::handleAppMessage(), BaseOverlay::handleBaseOverlayMessage(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimerExpired(), Pastry::handleFailedNode(), Kademlia::handleFailedNode(), oversim::Chord::handleFixFingersTimerExpired(), PubSubMMOG::handleHelpResponse(), PubSubMMOG::handleIntermediateResponse(), Scribe::handleJoinMessage(), Scribe::handleJoinResponse(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), KBRTestApp::handleLookupResponse(), DHT::handleLookupResponse(), BootstrapList::handleLookupResponse(), XmlRpcInterface::handleMessage(), BaseOverlay::handleMessage(), BaseApp::handleMessage(), PubSubMMOG::handleMoveMessage(), oversim::Chord::handleNewSuccessorHint(), Vast::handleNodeLeaveNotification(), QuonPR::handleNodeLeaveNotification(), PubSubMMOG::handlePingCall(), Scribe::handlePublishCall(), Scribe::handlePublishResponse(), BasePastry::handleRequestMessage(), IterativePathLookup::handleResponse(), oversim::Koorde::handleRpc(), oversim::Chord::handleRpc(), oversim::Koorde::handleRpcDeBruijnRequest(), oversim::Koorde::handleRpcNotifyResponse(), oversim::Chord::handleRpcNotifyResponse(), Scribe::handleRpcResponse(), PubSubMMOG::handleRpcResponse(), oversim::Koorde::handleRpcResponse(), KBRTestApp::handleRpcResponse(), oversim::Chord::handleRpcResponse(), Broose::handleRpcResponse(), BootstrapList::handleRpcResponse(), oversim::Koorde::handleRpcStabilizeResponse(), oversim::Chord::handleRpcStabilizeResponse(), PubSubMMOG::handleRpcTimeout(), PubSubLobby::handleRpcTimeout(), oversim::Koorde::handleRpcTimeout(), Kademlia::handleRpcTimeout(), oversim::Chord::handleRpcTimeout(), Broose::handleRpcTimeout(), oversim::Chord::handleStabilizeTimerExpired(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), Scribe::handleTimerEvent(), Pastry::handleTimerEvent(), KBRTestApp::handleTimerEvent(), DHT::handleTimerEvent(), Bamboo::handleTimerEvent(), Vast::handleUDPMessage(), QuonPR::handleUDPMessage(), QuonP::handleUDPMessage(), Pastry::handleUDPMessage(), Gia::handleUDPMessage(), Bamboo::handleUDPMessage(), Scribe::handleUpperMessage(), BaseOverlay::initialize(), SimpleGameClient::initializeApp(), BootstrapList::initializeApp(), BrooseBucket::initializeBucket(), oversim::Chord::initializeFriendModules(), Vast::initializeOverlay(), QuonPR::initializeOverlay(), QuonP::initializeOverlay(), BaseRpc::internalHandleRpcMessage(), PastryStateObject::isCloser(), PastryLeafSet::isClosestNode(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), BasePastry::isSiblingFor(), isUnspecified(), BaseOverlay::join(), oversim::Chord::joinForeignPartition(), Kademlia::joinOverlay(), KeyExtractor< NodeHandle >::key(), KeyExtractor< KademliaBucketEntry >::key(), KeyExtractor< LookupEntry >::key(), BrooseBucket::keyInRange(), XmlRpcInterface::localLookup(), BootstrapList::locateBootstrapNode(), BrooseBucket::longestPrefix(), IterativeLookup::lookup(), SendToKeyListener::lookupFinished(), PastryRoutingTable::lookupNextHop(), PastryRoutingTable::mergeNode(), PastryLeafSet::mergeNode(), Pastry::mergeState(), BaseOverlay::neighborSet(), netPack(), netUnpack(), BasePastry::newLeafs(), NodeHandle(), operator!=(), BrooseHandle::operator!=(), operator<(), operator<<(), operator<=(), operator=(), GiaNode::operator=(), BrooseHandle::operator=(), operator==(), BrooseHandle::operator==(), operator>(), operator>=(), BrooseBucket::output(), P2pns::p2pnsRegisterRpc(), oversim::Chord::pingResponse(), BootstrapList::pingResponse(), BasePastry::pingResponse(), oversim::Chord::pingTimeout(), BootstrapList::pingTimeout(), BasePastry::pingTimeout(), BasePastry::prePing(), Gia::processSearchMessage(), QuonPR::purgeSites(), QuonP::purgeSites(), BaseOverlay::route(), Kademlia::routingAdd(), Kademlia::routingTimeout(), oversim::Koorde::rpcNotify(), oversim::Chord::rpcNotify(), Vast::sendDiscardNode(), Vast::sendMessage(), QuonPR::sendMessage(), QuonP::sendMessage(), BaseOverlay::sendMessageToUDP(), BaseApp::sendMessageToUDP(), Gia::sendSearchResponseMessage(), BasePastry::sendStateTables(), Vast::sendToApp(), QuonPR::sendToApp(), QuonP::sendToApp(), BaseOverlay::sendToKey(), Kademlia::setBucketUsage(), BaseOverlay::setOwnNodeID(), PastryStateObject::specialCloserCondition(), IterativeLookup::start(), PubSubMMOG::startTimer(), Scribe::subscribeToGroup(), Scribe::update(), oversim::ChordSuccessorList::updateList(), QuonPR::updateThisSite(), QuonP::updateThisSite(), Broose::updateTooltip(), oversim::Koorde::walkDeBruijnList(), and oversim::Koorde::walkSuccessorList().

the unspecified NodeHandle

Reimplemented from TransportAddress.

Reimplemented in GiaNode.

Definition at line 98 of file NodeHandle.h.

Referenced by PastryLeafSet::balanceLeafSet(), oversim::Koorde::changeState(), oversim::Chord::changeState(), oversim::Chord::closestPreceedingNode(), PastryRoutingTable::failedNode(), PastryLeafSet::failedNode(), PastryRoutingTable::findCloserNode(), PastryNeighborhoodSet::findCloserNode(), PastryLeafSet::findCloserNode(), GiaNeighborCandidateList::get(), GlobalNodeList::getBootstrapNode(), BootstrapList::getBootstrapNode(), PastryStateObject::getDestinationNode(), PastryLeafSet::getDestinationNode(), GiaMessageBookkeeping::getNextHop(), GlobalNodeList::getRandomNode(), DHTDataStorage::getSourceNode(), oversim::ChordSuccessorList::getSuccessor(), PubSubMMOG::handleBackupCallTimeout(), BaseApp::handleCommonAPIMessage(), oversim::Koorde::handleDeBruijnTimeout(), oversim::ChordFingerTable::handleFailedNode(), oversim::Chord::handleFailedNode(), IterativePathLookup::handleFailedNodeResponse(), QuonPR::handleMove(), QuonP::handleMove(), PubSubMMOG::handlePingCallTimeout(), Scribe::handlePublishResponse(), oversim::Chord::handleStabilizeTimerExpired(), IterativePathLookup::handleTimeout(), PastryLeafSet::initializeSet(), NeighborCache::insertNodeContext(), BaseOverlay::internalSendRpcResponse(), BaseApp::internalSendRpcResponse(), PastryRoutingTable::lookupNextHop(), oversim::Chord::pingTimeout(), QuonPR::processBackupTimer(), QuonP::processBackupTimer(), PubSubSubspace::PubSubSubspace(), PubSubSubspaceResponsible::PubSubSubspaceResponsible(), QPRSite::QPRSite(), QPSite::QPSite(), oversim::ChordFingerTable::removeFinger(), ScribeGroup::ScribeGroup(), oversim::ChordFingerTable::setFinger(), NeighborCache::setNodeTimeout(), Site::Site(), oversim::ChordFingerTable::updateFinger(), and oversim::Koorde::walkDeBruijnList().


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

Generated on Wed Mar 25 16:32:53 2009 for OverSim by  doxygen 1.5.5