ariba::Node Class Reference

#include <source/ariba/Node.h>

Inherits ariba::Module.

Collaboration diagram for ariba::Node:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Node (AribaModule &ariba_mod, const Name &node_name=Name::UNSPECIFIED)
virtual ~Node ()
void join (const Name &name)
void initiate (const Name &name, const SpoVNetProperties &parm=SpoVNetProperties::DEFAULT)
void leave ()
bool bind (NodeListener *listener)
bool unbind (NodeListener *listener)
const SpoVNetPropertiesgetSpoVNetProperties () const
const SpoVNetIDgetSpoVNetId () const
bool isJoined () const
const NodeIDgetNodeId (const LinkID &lid=LinkID::UNSPECIFIED) const
NodeID generateNodeId (const Name &name) const
const Name getNodeName (const LinkID &lid=LinkID::UNSPECIFIED) const
vector< NodeIDgetNeighborNodes () const
LinkID establishLink (const NodeID &nid, const ServiceID &sid)
void dropLink (const LinkID &lnk)
seqnum_t sendMessage (const DataMessage &msg, const NodeID &nid, const ServiceID &sid, const LinkProperties &req=LinkProperties::DEFAULT)
seqnum_t sendMessage (const DataMessage &msg, const LinkID &lnk)
void sendBroadcastMessage (const DataMessage &msg, const ServiceID &sid)
bool bind (CommunicationListener *listener, const ServiceID &sid)
bool unbind (CommunicationListener *listener, const ServiceID &sid)
void put (const Data &key, const Data &value, uint16_t ttl, bool replace=false)
void get (const Data &key, const ServiceID &sid)
string getName () const

Protected Attributes

Name name
AribaModuleariba_mod
SpoVNetID spovnetId
NodeID nodeId
overlay::BaseOverlaybase_overlay

Friends

class AribaModule

Detailed Description

This class should implement all ariba node functionality.

Author:
Sebastian Mies <mies@tm.uka.de>
Christoph Mayer <mayer@tm.uka.de>

Definition at line 74 of file Node.h.


Constructor & Destructor Documentation

ariba::Node::Node ( AribaModule ariba_mod,
const Name node_name = Name::UNSPECIFIED 
)

Constructs a new node using a given ariba module

Parameters:
ariba_mod The ariba module
name The canonical node name of the new node. When NULL a randomly chosen name is created.
len The length of the canonical node name or -1, if the name is a zero-terminated char-string.

Definition at line 49 of file Node.cpp.

References base_overlay.

ariba::Node::~Node (  )  [virtual]

Destroys the node. Before destruction some pre-conditions must be met:

1. The node is not part of any SpoVNet
2. All listeners must be unbound from this node
3. The module has been stopped

Definition at line 54 of file Node.cpp.

References base_overlay.


Member Function Documentation

bool ariba::Node::bind ( CommunicationListener listener,
const ServiceID sid 
)

Binds a listener to a specifed service identifier. Whenever a link is established/dropped or messages are received the events inside the interface are called.

Parameters:
listener The listener to be registered
sid The service identifier
Returns:
boolean indicating success of failure

Definition at line 195 of file Node.cpp.

References ariba_mod, base_overlay, ariba::overlay::BaseOverlay::bind(), ariba::overlay::BaseOverlay::registerSidePort(), and ariba::AribaModule::sideport_sniffer.

bool ariba::Node::bind ( NodeListener listener  ) 

This method is used to bind a node listener to this node.

Parameters:
listener The node listener
Returns:
boolean indicating success of failure

Definition at line 187 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::bind().

Referenced by ariba::application::dhttest::DHTTest::startup(), and ariba::application::pingpong::PingPong::startup().

void ariba::Node::dropLink ( const LinkID lnk  ) 

This method drops an established link.

Parameters:
lnk The link identifier of an active link

Definition at line 170 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::dropLink().

LinkID ariba::Node::establishLink ( const NodeID nid,
const ServiceID sid 
)

Establishes a new link to another node and service with the given link properties. An optional message could be sent with the request.

Parameters:
nid The remote node identifier
sid The remote service identifier
req The required link properties
msg An optional message that is sent with the request
Returns:
A new link id

Definition at line 166 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::establishLink().

NodeID ariba::Node::generateNodeId ( const Name name  )  const

Returns the node id to a node name according to the currently joined spovnet (usually derives a node identifier by hashing the name).

Returns:
The node identifier to the given name

Definition at line 157 of file Node.cpp.

References ariba::Name::random(), ariba::Name::toNodeId(), and ariba::Name::UNSPECIFIED.

Referenced by initiate(), and join().

void ariba::Node::get ( const Data key,
const ServiceID sid 
)

Queries for values stored in the DHT. Fires an communication event when values arrive.

Parameters:
key The key data
sid The service that is requesting the values

Definition at line 217 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::dhtGet().

Referenced by ariba::application::dhttest::DHTTest::eventFunction().

string ariba::Node::getName (  )  const [virtual]
See also:
Module.h

Reimplemented from ariba::Module.

Definition at line 222 of file Node.cpp.

References name, and ariba::Name::toString().

vector< NodeID > ariba::Node::getNeighborNodes (  )  const

Get a list of neighboring nodes in the overlay structure. The number and identities of nodes depends highly on the used overlay structure.

Returns:
a list of NodeIDs that are neighbors in the overlay structure
See also:
sendBroadcastMessage

Definition at line 162 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::getOverlayNeighbors().

Referenced by ariba::application::pingpong::PingPong::eventFunction().

const NodeID & ariba::Node::getNodeId ( const LinkID lid = LinkID::UNSPECIFIED  )  const

Returns the node id of this node if the link id is unspecified or the node id of the remote node.

Returns:
The local or the remote node identifier

Definition at line 152 of file Node.cpp.

References base_overlay, ariba::overlay::BaseOverlay::getNodeID(), nodeId, and ariba::utility::LinkID::UNSPECIFIED.

Referenced by ariba::application::dhttest::DHTTest::startup(), and ariba::application::pingpong::PingPong::startup().

const Name ariba::Node::getNodeName ( const LinkID lid = LinkID::UNSPECIFIED  )  const

Returns the name of this node if the link id is unspecified or the node name of the remote node, if known -- otherwise it returns an unspecified name.

Returns:
A node's name or an unspecified name, if unknown
const SpoVNetID & ariba::Node::getSpoVNetId (  )  const

Returns the spovnet identifier

Returns:
The spovnet idenfifier

Definition at line 148 of file Node.cpp.

References spovnetId.

Referenced by ariba::application::dhttest::DHTTest::startup(), and ariba::application::pingpong::PingPong::startup().

const SpoVNetProperties & ariba::Node::getSpoVNetProperties (  )  const

Returns the properties of the spovnet the node has joined.

Returns:
The properties of the spovnet the node has joined

Definition at line 144 of file Node.cpp.

References ariba::SpoVNetProperties::DEFAULT.

void ariba::Node::initiate ( const Name name,
const SpoVNetProperties parm = SpoVNetProperties::DEFAULT 
)
bool ariba::Node::isJoined (  )  const

Returns true, if the node is part of a spovnet.

Returns:
True, if the node is part of a spovnet
void ariba::Node::join ( const Name name  ) 
void ariba::Node::leave (  ) 
void ariba::Node::put ( const Data key,
const Data value,
uint16_t  ttl,
bool  replace = false 
)

Adds a key value pair to the DHT

Parameters:
key The key data
value The value data
ttl The time to live in seconds

Definition at line 213 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::dhtPut().

Referenced by ariba::application::dhttest::DHTTest::eventFunction().

void ariba::Node::sendBroadcastMessage ( const DataMessage msg,
const ServiceID sid 
)

Sends a message to all known hosts in the overlay structure the nodes that are reached here depend on the overlay structure.

Parameters:
msg The message to be send
sid The id of the service that should receive the message
See also:
getNeighborNodes

Definition at line 183 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::broadcastMessage().

seqnum_t ariba::Node::sendMessage ( const DataMessage msg,
const LinkID lnk 
)

Sends a message via an established link. If reliable transport was selected, the method returns a sequence number and a communication event is triggered on message delivery or loss.

Parameters:
msg The message to be sent
lnk The link to be used for sending the message

Definition at line 179 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::sendMessage().

seqnum_t ariba::Node::sendMessage ( const DataMessage msg,
const NodeID nid,
const ServiceID sid,
const LinkProperties req = LinkProperties::DEFAULT 
)

Sends a one-shot message to a service. If link properties are specified, the node tries to fulfill those requirements. This may cause the node to first establish a temporary link, second sending the message and last dropping the link. This would result in a small amount of extra latency until the message is delivered. If reliable transport was selected, the method returns a sequence number and a communication event is triggered on message delivery or loss.

Parameters:
msg The message to be sent
nid The remote node identifier
sid The remote service identifier
req The requirements associated with the message
Returns:
A sequence number

Definition at line 174 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::sendMessage().

Referenced by ariba::application::pingpong::PingPong::eventFunction().

bool ariba::Node::unbind ( CommunicationListener listener,
const ServiceID sid 
)

Un-binds a listener from this node.

Parameters:
The listener to be unbound
Returns:
boolean indicating success of failure

Definition at line 207 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::unbind().

bool ariba::Node::unbind ( NodeListener listener  ) 

This method is used to unbind a node listener to this node.

Parameters:
listener The node listener
Returns:
boolean indicating success of failure

Definition at line 191 of file Node.cpp.

References base_overlay, and ariba::overlay::BaseOverlay::unbind().

Referenced by ariba::application::dhttest::DHTTest::shutdown(), and ariba::application::pingpong::PingPong::shutdown().


Friends And Related Function Documentation

friend class AribaModule [friend]

Definition at line 327 of file Node.h.


Member Data Documentation

Definition at line 331 of file Node.h.

Referenced by bind(), initiate(), join(), and leave().

Name ariba::Node::name [protected]

Definition at line 330 of file Node.h.

Referenced by getName(), initiate(), and join().

Definition at line 333 of file Node.h.

Referenced by getNodeId(), initiate(), and join().

Definition at line 332 of file Node.h.

Referenced by getSpoVNetId(), initiate(), and join().


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

Generated on Fri Dec 10 11:09:24 2010 for Ariba by  doxygen 1.6.1