Changeset 3037
- Timestamp:
- Apr 22, 2009, 9:07:53 PM (16 years ago)
- Files:
-
- 4 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/pingpong/PingPong.cpp
r2483 r3037 12 12 use_logging_cpp( PingPong ); 13 13 14 // the service id of the ping pong service14 // the service that the pingpong wants to use 15 15 ServiceID PingPong::PINGPONG_ID = ServiceID( 111 ); 16 16 … … 40 40 41 41 // get initiator flag 42 this->isInitiator = Configuration::instance().read<bool> 42 this->isInitiator = Configuration::instance().read<bool>("node.initiator"); 43 43 44 44 // get node name 45 45 Name nodeName = Name::UNSPECIFIED; 46 if (config.exists("node.name")) nodeName 47 = config.read<string> ("node.name"); 46 if (config.exists("node.name")) nodeName = config.read<string> ("node.name"); 48 47 49 48 // configure ariba module 50 49 if (config.exists("ariba.ip.addr")) ariba->setProperty("ip.addr", 51 config.read<string> 50 config.read<string>("ariba.ip.addr")); 52 51 if (config.exists("ariba.tcp.port")) ariba->setProperty("tcp.port", 53 config.read<string> 52 config.read<string>("ariba.tcp.port")); 54 53 if (config.exists("ariba.udp.port")) ariba->setProperty("udp.port", 55 config.read<string> 54 config.read<string>("ariba.udp.port")); 56 55 if (config.exists("ariba.bootstrap.hints")) ariba->setProperty("bootstrap.hints", 57 config.read<string> 56 config.read<string>("ariba.bootstrap.hints")); 58 57 59 58 // start ariba module … … 71 70 72 71 // bind communication and node listener 73 node->bind( this ); 74 node->bind( this, PingPong::PINGPONG_ID); 75 72 node->bind( this ); /*NodeListener*/ 73 node->bind( this, PingPong::PINGPONG_ID); /*CommunicationListener*/ 74 76 75 // start the ping timer. if we are not 77 76 // the initiator this will happen in onJoinCompleted … … 79 78 80 79 // ping pong started up... 81 logging_info( "pingpong started up "); 80 logging_info( "pingpong starting up with" 81 << " [spovnetid " << node->getSpoVNetId().toString() << "]" 82 << " and [nodeid " << node->getNodeId().toString() << "]" ); 82 83 } 83 84 … … 91 92 92 93 // unbind communication and node listener 93 node->unbind( this ); 94 node->unbind( this, PingPong::PINGPONG_ID ); 94 node->unbind( this ); /*NodeListener*/ 95 node->unbind( this, PingPong::PINGPONG_ID ); /*CommunicationListener*/ 95 96 96 97 // leave spovnet … … 110 111 // node listener interface 111 112 void PingPong::onJoinCompleted( const SpoVNetID& vid ) { 112 logging_ info( "pingpong node join completed, spovnetid=" << vid.toString() );113 logging_error( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX pingpong node join completed, spovnetid=" << vid.toString() ); 113 114 114 115 // start the timer to ping every second … … 117 118 118 119 void PingPong::onJoinFailed( const SpoVNetID& vid ) { 119 logging_error(" pingpong node join failed, spovnetid=" << vid.toString() ); 120 logging_error("pingpong node join failed, spovnetid=" << vid.toString() ); 121 } 122 123 void PingPong::onLeaveCompleted( const SpoVNetID& vid ){ 124 logging_info("pingpong node leave completed, spovnetid=" << vid.toString() ); 125 } 126 127 void PingPong::onLeaveFailed( const SpoVNetID& vid ){ 128 logging_error("pingpong node leave failed, spovnetid=" << vid.toString() ); 129 } 130 131 // timer event 132 void PingPong::eventFunction() { 133 134 // we ping all nodes that are known in the overlay structure 135 // this can be all nodes (OneHop) overlay or just some neighbors 136 // in case of a Chord or Kademlia structure 137 138 logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 139 140 PingPongMessage pingmsg( pingId ); 141 142 //----------------------------------------------------------------------- 143 // Option 1: get all neighboring nodes and send the message to each 144 //----------------------------------------------------------------------- 145 vector<NodeID> nodes = node->getNeighborNodes(); 146 BOOST_FOREACH( NodeID nid, nodes ){ 147 node->sendMessage( pingmsg, nid, PingPong::PINGPONG_ID ); 148 } 149 150 //----------------------------------------------------------------------- 151 // Option 2: send a "broadcast message" that actually does the same thing 152 // internally, gets all neighboring nodes and sends the message 153 //----------------------------------------------------------------------- 154 // node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID ); 120 155 } 121 156 … … 127 162 void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) { 128 163 129 PingPongMessage* pingmsg = msg.getMessage()-> decapsulate<PingPongMessage> ();164 PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> (); 130 165 131 166 logging_info( "received ping message on link " << lnk.toString() … … 134 169 } 135 170 136 // timer event 137 void PingPong::eventFunction() { 138 139 // we ping all nodes that are known in the overlay structure 140 // this can be all nodes (OneHop) overlay or just some neighbors 141 // in case of a Chord or Kademlia structure 142 143 logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 144 145 PingPongMessage pingmsg( pingId ); 146 node->sendBroadcastMessage( pingmsg, PingPong::PINGPONG_ID ); 171 void PingPong::onLinkUp(const LinkID& lnk, const NodeID& remote){ 172 logging_info( "received link-up event for link " << lnk.toString() 173 << " and node " << remote.toString() ); 174 } 175 176 void PingPong::onLinkDown(const LinkID& lnk, const NodeID& remote){ 177 logging_info( "received link-down event for link " << lnk.toString() 178 << " and node " << remote.toString() ); 179 } 180 181 void PingPong::onLinkChanged(const LinkID& lnk, const NodeID& remote){ 182 logging_info( "received link-changed event for link " << lnk.toString() 183 << " and node " << remote.toString() ); 184 } 185 186 void PingPong::onLinkFail(const LinkID& lnk, const NodeID& remote){ 187 logging_info( "received link-failed event for link " << lnk.toString() 188 << " and node " << remote.toString() ); 189 } 190 191 void PingPong::onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop){ 192 logging_info( "received link-qos-changed event for link " << lnk.toString() 193 << " and node " << remote.toString() 194 << " with link properties " << prop.toString() ); 195 } 196 197 void PingPong::onMessageSent(seqnum_t seq_num, bool failed, const DataMessage& msg ){ 198 logging_info( "received message sent event for seqnum " << seq_num 199 << " with result " << failed ); 147 200 } 148 201 -
sample/pingpong/PingPong.h
r2483 r3037 37 37 virtual bool onLinkRequest(const NodeID& remote, const DataMessage& msg); 38 38 virtual void onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk= LinkID::UNSPECIFIED); 39 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote); 40 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote); 41 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote); 42 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote); 43 virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop); 44 virtual void onMessageSent(seqnum_t seq_num, bool failed, const DataMessage& msg = DataMessage::UNSPECIFIED); 39 45 40 46 // node listener interface 41 47 virtual void onJoinCompleted( const SpoVNetID& vid ); 42 48 virtual void onJoinFailed( const SpoVNetID& vid ); 49 virtual void onLeaveCompleted( const SpoVNetID& vid ); 50 virtual void onLeaveFailed( const SpoVNetID& vid ); 43 51 44 52 // startup wrapper interface … … 54 62 Node* node; 55 63 56 // flag, whet er this node initiates or just joins the spovnet64 // flag, whether this node initiates or just joins the spovnet 57 65 bool isInitiator; 58 66 -
source/ariba/AribaModule.cpp
r2467 r3037 46 46 #include "ariba/utility/misc/Helper.h" 47 47 #include "ariba/utility/misc/StringFormat.h" 48 49 // hack includes 50 #include "ariba/interface/UnderlayAbstraction.h" 48 #include "ariba/communication/BaseCommunication.h" 51 49 #include "ariba/communication/EndpointDescriptor.h" 52 50 #include "ariba/communication/modules/network/NetworkLocator.h" 53 51 54 52 using namespace ariba::utility::Helper; 55 using ariba:: interface::UnderlayAbstraction;53 using ariba::communication::BaseCommunication; 56 54 using ariba::communication::EndpointDescriptor; 57 55 … … 61 59 62 60 // init with default values 63 this-> underlay_abs= NULL;61 this->base_comm = NULL; 64 62 this->ip_addr = NULL; 65 63 this->tcp_port = 41402; … … 132 130 } 133 131 134 // std::cout << "added bootstrap info: " << getBootstrapHints() << std::endl;132 //logging_debug( "added bootstrap info: " << getBootstrapHints() ); 135 133 } 136 134 … … 154 152 155 153 // init variables 156 underlay_abs= NULL;154 base_comm = NULL; 157 155 } 158 156 … … 161 159 162 160 // preconditions 163 assert( underlay_abs== NULL);161 assert(base_comm == NULL); 164 162 assert(!started); 165 163 166 164 // create the base communication component 167 165 started = true; 168 underlay_abs = new interface::UnderlayAbstraction();166 base_comm = new BaseCommunication(); 169 167 } 170 168 … … 173 171 174 172 // preconditions 175 assert( underlay_abs!= NULL);173 assert(base_comm != NULL); 176 174 assert(started); 177 175 178 176 // delete base communication component 179 177 started = false; 180 delete underlay_abs;178 delete base_comm; 181 179 } 182 180 -
source/ariba/AribaModule.h
r2454 r3037 64 64 class NetworkLocator; 65 65 } 66 namespace interface{67 class UnderlayAbstraction;66 namespace communication { 67 class BaseCommunication; 68 68 } 69 69 … … 185 185 const Name& spovnet) const; 186 186 187 // TODO: merge with old interface 188 interface::UnderlayAbstraction* underlay_abs; 187 communication::BaseCommunication* base_comm; 189 188 190 189 // TODO: use "abstract" representations here! -
source/ariba/LinkProperties.cpp
r2409 r3037 52 52 } 53 53 54 string LinkProperties::toString() const { 55 std::ostringstream buf; 56 buf << "[reliable=" << (reliable ? "yes" : "no") << "]"; 57 return buf.str(); 58 } 59 54 60 } // namespace ariba -
source/ariba/LinkProperties.h
r2436 r3037 40 40 #define LINKPROPERTIES_H_ 41 41 42 #include <string> 43 #include <iostream> 44 #include <sstream> 45 46 using std::string; 47 42 48 namespace ariba { 43 49 // forward declaration … … 52 58 ~LinkProperties(); 53 59 60 string toString() const; 54 61 static const LinkProperties DEFAULT; 55 62 -
source/ariba/Makefile.am
r2467 r3037 256 256 257 257 libariba_la_SOURCES += \ 258 interface/UnderlayAbstraction.cpp \259 interface/AribaContext.cpp \260 258 interface/ServiceInterface.cpp 261 259 -
source/ariba/Node.cpp
r2482 r3037 41 41 #include "ariba/overlay/BaseOverlay.h" 42 42 #include "ariba/utility/types/OverlayParameterSet.h" 43 #include "ariba/interface/AribaContext.h"44 43 #include "ariba/interface/ServiceInterface.h" 45 #include "ariba/interface/UnderlayAbstraction.h"46 44 #include "ariba/communication/EndpointDescriptor.h" 47 45 48 46 using ariba::communication::EndpointDescriptor; 49 using ariba::interface::UnderlayAbstraction;50 47 51 48 namespace ariba { … … 64 61 nodeListener(NULL), commListener(listener) { 65 62 } 66 63 67 64 ~ServiceInterfaceWrapper() { 68 65 } 69 66 70 67 protected: 71 void onOverlayCreate(const SpoVNetID& id) {72 73 }74 75 void onOverlayDestroy(const SpoVNetID& id) {76 77 }78 68 79 69 bool isJoinAllowed(const NodeID& nodeid, const SpoVNetID& spovnetid) { … … 95 85 void onJoinFail(const SpoVNetID& spovnetid) { 96 86 if (nodeListener != NULL) nodeListener->onJoinFailed(spovnetid); 87 } 88 89 void onLeaveSuccess( const SpoVNetID& spovnetid ){ 90 if (nodeListener != NULL) nodeListener->onLeaveCompleted(spovnetid); 91 } 92 93 void onLeaveFail( const SpoVNetID& spovnetid ){ 94 if (nodeListener != NULL) nodeListener->onLeaveFailed(spovnetid); 97 95 } 98 96 … … 131 129 132 130 Node::Node(AribaModule& ariba_mod, const Name& node_name) : 133 ariba_mod(ariba_mod), name(node_name), context(NULL) {131 ariba_mod(ariba_mod), name(node_name), base_overlay(NULL) { 134 132 } 135 133 … … 137 135 } 138 136 137 //TODO: Implement error handling: no bootstrap node available 139 138 void Node::join(const Name& vnetname) { 140 139 spovnetId = vnetname.toSpoVNetId(); 141 140 nodeId = generateNodeId(name); 142 this->context = ariba_mod.underlay_abs->joinSpoVNet(spovnetId, 143 *ariba_mod.getBootstrapNode(vnetname), nodeId, 144 ariba_mod.ip_addr, ariba_mod.tcp_port); 145 } 146 147 //TODO: Implement error handling: no bootstrap node available 141 142 //logging("joining spovnet on" 143 // << " [spovnetid=]" << spovnetId.toString() 144 // << " [nodeid=]" << nodeId.toString() ); 145 146 //logging_info("starting base communication..."); 147 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port); 148 149 //logging_info("starting base overlay..."); 150 base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId ); 151 152 const communication::EndpointDescriptor* ep = 153 ariba_mod.getBootstrapNode(vnetname); 154 if( ep == NULL ) return; 155 156 base_overlay->joinSpoVNet( spovnetId, *ep); 157 } 158 148 159 void Node::initiate(const Name& vnetname, const SpoVNetProperties& parm) { 149 160 utility::OverlayParameterSet ovrpset = 150 (utility::OverlayParameterSet::_OverlayStructure) 161 (utility::OverlayParameterSet::_OverlayStructure) 151 162 parm.getBaseOverlayType(); 152 163 … … 154 165 nodeId = generateNodeId(name); 155 166 156 this->context = ariba_mod.underlay_abs->createSpoVNet( 157 spovnetId, nodeId, ariba_mod.ip_addr, 158 ariba_mod.tcp_port); 167 //logging("joining spovnet on" 168 // << " [spovnetid=]" << spovnetId.toString() 169 // << " [nodeid=]" << nodeId.toString() ); 170 171 //logging_info("starting base communication..."); 172 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port); 173 174 //logging_info("starting base overlay..."); 175 base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId ); 176 base_overlay->createSpoVNet( spovnetId ); 159 177 160 178 ariba_mod.addBootstrapNode(vnetname, 161 new EndpointDescriptor(this->context-> 162 getBaseCommunication().getEndpointDescriptor())); 179 new EndpointDescriptor(ariba_mod.base_comm->getEndpointDescriptor())); 163 180 } 164 181 165 182 void Node::leave() { 166 ariba_mod.underlay_abs->leaveSpoVNet( context ); 167 context = NULL; 183 base_overlay->leaveSpoVNet(); 184 ariba_mod.base_comm->stop(); 185 186 delete base_overlay; 187 base_overlay = NULL; 168 188 } 169 189 … … 177 197 178 198 const NodeID& Node::getNodeId(const LinkID& lid) const { 179 return nodeId; 199 if( lid == LinkID::UNSPECIFIED ) return nodeId; 200 else return base_overlay->getNodeID( lid ); 180 201 } 181 202 … … 185 206 } 186 207 208 vector<NodeID> Node::getNeighborNodes() const { 209 return base_overlay->getOverlayNeighbors(); 210 } 211 187 212 LinkID Node::establishLink(const NodeID& nid, const ServiceID& sid, 188 213 const LinkProperties& req, const DataMessage& msg) { 189 return context->getOverlay().establishLink(nid, sid);214 return base_overlay->establishLink(nid, sid); 190 215 } 191 216 192 217 void Node::dropLink(const LinkID& lnk) { 193 context->getOverlay().dropLink(lnk);218 base_overlay->dropLink(lnk); 194 219 } 195 220 196 221 seqnum_t Node::sendMessage(const DataMessage& msg, const NodeID& nid, 197 222 const ServiceID& sid, const LinkProperties& req) { 198 return context->getOverlay().sendMessage((Message*) msg, nid, sid);223 return base_overlay->sendMessage((Message*) msg, nid, sid); 199 224 } 200 225 201 226 seqnum_t Node::sendMessage(const DataMessage& msg, const LinkID& lnk) { 202 return context->getOverlay().sendMessage((Message*) msg, lnk);227 return base_overlay->sendMessage((Message*) msg, lnk); 203 228 } 204 229 205 230 void Node::sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid) { 206 return context->getOverlay().broadcastMessage((Message*)msg, sid);231 return base_overlay->broadcastMessage((Message*)msg, sid); 207 232 } 208 233 209 234 void Node::bind(NodeListener* listener) { 210 context->getOverlay().bind(new ServiceInterfaceWrapper(listener),235 base_overlay->bind(new ServiceInterfaceWrapper(listener), 211 236 Node::anonymousService); 212 237 } 213 238 214 239 void Node::unbind(NodeListener* listener) { 215 delete context->getOverlay().unbind(Node::anonymousService);240 delete base_overlay->unbind(Node::anonymousService); 216 241 } 217 242 218 243 void Node::bind(CommunicationListener* listener, const ServiceID& sid) { 219 context->getOverlay().bind(new ServiceInterfaceWrapper(listener), sid);244 base_overlay->bind(new ServiceInterfaceWrapper(listener), sid); 220 245 } 221 246 222 247 void Node::unbind(CommunicationListener* listener, const ServiceID& sid) { 223 delete context->getOverlay().unbind(sid);248 delete base_overlay->unbind(sid); 224 249 } 225 250 -
source/ariba/Node.h
r2473 r3037 45 45 } 46 46 47 #include <vector> 47 48 #include "Module.h" 48 49 #include "Identifiers.h" … … 54 55 #include "DataMessage.h" 55 56 57 using std::vector; 58 56 59 namespace ariba { 57 60 58 61 // forward declaration 59 62 namespace interface { 60 class AribaContext;61 63 class ServiceInterface; 64 } 65 66 namespace overlay { 67 class BaseOverlay; 62 68 } 63 69 … … 66 72 * 67 73 * @author Sebastian Mies <mies@tm.uka.de> 74 * @author Christoph Mayer <mayer@tm.uka.de> 68 75 */ 69 76 class Node: public Module { … … 181 188 */ 182 189 const Name getNodeName(const LinkID& lid = LinkID::UNSPECIFIED) const; 190 191 /** 192 * Get a list of neighboring nodes in the overlay structure. 193 * The number and identities of nodes depends highly on the 194 * used overlay structure. 195 * 196 * @return a list of NodeIDs that are neighbors in the overlay structure 197 * @see sendBroadcastMessage 198 */ 199 vector<NodeID> getNeighborNodes() const; 183 200 184 201 //--- communication --- … … 241 258 * @param msg The message to be send 242 259 * @param sid The id of the service that should receive the message 260 * @see getNeighborNodes 243 261 */ 244 262 void sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid); … … 317 335 318 336 // member variables 319 Name name; //< node name 320 AribaModule& ariba_mod; //< ariba module 321 SpoVNetID spovnetId; //< current spovnet id 322 NodeID nodeId; //< current node id 337 Name name; //< node name 338 AribaModule& ariba_mod; //< ariba module 339 SpoVNetID spovnetId; //< current spovnet id 340 NodeID nodeId; //< current node id 341 overlay::BaseOverlay* base_overlay; //< the base overlay 323 342 324 343 // delegates 325 interface::AribaContext* context;326 344 static ServiceID anonymousService; 327 345 }; -
source/ariba/NodeListener.cpp
r2409 r3037 42 42 namespace ariba { 43 43 44 // dummy45 44 NodeListener::NodeListener() { 46 45 } 47 46 48 // dummy49 47 NodeListener::~NodeListener() { 50 48 } 51 49 52 // dummy53 50 void NodeListener::onJoinCompleted(const SpoVNetID& vid ) { 54 51 } 55 52 56 // dummy57 53 void NodeListener::onJoinFailed(const SpoVNetID& vid ) { 58 54 } 59 55 60 // dummy61 56 void NodeListener::onLeaveCompleted(const SpoVNetID& vid ) { 62 57 } 63 58 64 // dummy65 59 void NodeListener::onLeaveFailed(const SpoVNetID& vid ) { 66 60 } -
source/ariba/communication/BaseCommunication.cpp
r2802 r3037 55 55 const BaseCommunication::LinkDescriptor BaseCommunication::LinkDescriptor::UNSPECIFIED; 56 56 57 BaseCommunication::BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport) 58 : messageReceiver( NULL ), currentSeqnum( 0 ), listenport( _listenport ) { 57 BaseCommunication::BaseCommunication() 58 : messageReceiver(NULL), network(NULL), transport(NULL){ 59 } 60 61 BaseCommunication::~BaseCommunication(){ 62 } 63 64 void BaseCommunication::start(const NetworkLocator* _locallocator, const uint16_t _listenport){ 65 66 currentSeqnum = 0; 67 listenport = _listenport; 59 68 60 69 logging_info( "starting up base communication and creating transports ..." ); … … 139 148 } 140 149 141 BaseCommunication::~BaseCommunication() {150 void BaseCommunication::stop() { 142 151 143 152 logging_info( "stopping base communication and transport ..." ); … … 210 219 // warn if this link has some queued messages attached 211 220 if( descriptor.waitingmsg.size() > 0 ){ 212 logging_warn( "dropping link " << link.toString() << 221 logging_warn( "dropping link " << link.toString() << 213 222 " that has " << descriptor.waitingmsg.size() << " waiting messages" ); 214 223 } … … 368 377 const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress()); 369 378 370 logging_debug( "localLocator=" << localLocator->toString() 379 logging_debug( "localLocator=" << localLocator->toString() 371 380 << " remoteLocator=" << remoteLocator->toString()); 372 381 … … 419 428 // the link is now open 420 429 // 421 430 422 431 BOOST_FOREACH( CommunicationEvents* i, eventListener ){ 423 432 i->onLinkUp( localLink, localLocator, remoteLocator ); … … 444 453 445 454 linkDesc.remoteLink = spovmsg->getLocalLink(); 446 linkDesc.linkup = true; 447 455 linkDesc.linkup = true; 456 448 457 logging_debug( "the link is now up with local link id " << spovmsg->getRemoteLink().toString() ); 449 458 … … 452 461 } 453 462 454 if( linkDesc.waitingmsg.size() > 0 ){ 463 if( linkDesc.waitingmsg.size() > 0 ){ 455 464 logging_info( "sending out queued messages on link " << linkDesc.localLink.toString() ); 456 465 … … 564 573 for( ; i != iend; i++){ 565 574 if( (*i).localLink != localLink) continue; 566 575 567 576 BOOST_FOREACH( Message* msg, i->waitingmsg ){ 568 577 delete msg; -
source/ariba/communication/BaseCommunication.h
r2483 r3037 122 122 */ 123 123 class BaseCommunication : public MessageReceiver, NetworkChangeInterface { 124 125 124 use_logging_h(BaseCommunication); 126 127 125 public: 128 /** 129 * Constructs a Base Communication instance. 130 * Listens default on port number 41402 131 */ 132 BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport); 133 134 /** 135 * Destructs a Base Communication instance 126 127 /** 128 * Default ctor that just creates an empty 129 * non functional base communication 130 */ 131 BaseCommunication(); 132 133 /** 134 * Default dtor that does nothing 136 135 */ 137 136 virtual ~BaseCommunication(); 137 138 /** 139 * Startup the base communication, start modules etc. 140 */ 141 void start(const NetworkLocator* _locallocator, const uint16_t _listenport); 142 143 /** 144 * stop the base communication, stop modules etc. 145 */ 146 void stop(); 138 147 139 148 /** -
source/ariba/communication/EndpointDescriptor.cpp
r2457 r3037 57 57 58 58 EndpointDescriptor::EndpointDescriptor(const Locator* _locator){ 59 if( _locator == NULL ) return; 60 59 61 locator = new IPv4Locator(*dynamic_cast<IPv4Locator*>((Locator*)_locator)); 60 62 isUnspec = false; -
source/ariba/communication/EndpointDescriptor.h
r3036 r3037 51 51 using ariba::communication::IPv4Locator; 52 52 53 // needed for friend decleration54 // in different namespace55 namespace ariba {56 namespace interface {57 class UnderlayAbstraction;58 }}59 60 53 namespace ariba { 61 54 namespace communication { … … 67 60 68 61 friend class BaseCommunication; 69 friend class ariba::interface::UnderlayAbstraction;70 62 71 63 public: -
source/ariba/interface/ServiceInterface.cpp
r2473 r3037 48 48 } 49 49 50 void ServiceInterface::onOverlayCreate( const SpoVNetID& id ){51 }52 53 void ServiceInterface::onOverlayDestroy( const SpoVNetID& id ){54 }55 56 50 bool ServiceInterface::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){ 57 51 // default: allow all nodes to join … … 71 65 } 72 66 67 void ServiceInterface::onLeaveSuccess( const SpoVNetID& spovnetid ){ 68 } 69 70 void ServiceInterface::onLeaveFail( const SpoVNetID& spovnetid ){ 71 } 72 73 73 void ServiceInterface::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){ 74 74 } -
source/ariba/interface/ServiceInterface.h
r2473 r3037 74 74 75 75 protected: 76 virtual void onOverlayCreate( const SpoVNetID& id );77 virtual void onOverlayDestroy( const SpoVNetID& id );78 79 76 virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ); 80 77 virtual void onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid ); … … 83 80 virtual void onJoinSuccess( const SpoVNetID& spovnetid ); 84 81 virtual void onJoinFail( const SpoVNetID& spovnetid ); 82 virtual void onLeaveSuccess( const SpoVNetID& spovnetid ); 83 virtual void onLeaveFail( const SpoVNetID& spovnetid ); 85 84 86 85 virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ); -
source/ariba/overlay/BaseOverlay.cpp
r2803 r3037 107 107 108 108 logging_info( "leaving spovnet " << spovnetId ); 109 bool ret = ( state != this->BaseOverlayStateInvalid ); 109 110 110 111 logging_debug( "dropping all auto-links ..." ); 111 112 112 113 BOOST_FOREACH( LinkPair item, linkMapping ){ 113 if( item.second.autolink ) 114 if( item.second.autolink ) 114 115 dropLink( item.first ); 115 116 } … … 135 136 // inform all registered services of the event 136 137 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){ 137 i->onOverlayDestroy( spovnetId ); 138 if( ret ) i->onLeaveSuccess( spovnetId ); 139 else i->onLeaveFail( spovnetId ); 138 140 } 139 141 } … … 159 161 160 162 // 161 // create the overlay162 //163 164 overlayInterface->createOverlay();165 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){166 i->onOverlayCreate( spovnetId );167 }168 169 //170 163 // bootstrap against ourselfs 171 164 // … … 286 279 node.toString() << " for service " << service.toString() << 287 280 ". creating auto link ..."); 288 281 289 282 const LinkID link = establishLink( node, service ); 290 283 LinkMapping::iterator i = linkMapping.find( link ); … … 328 321 ServiceInterface* iface = listenerMux.get( sid ); 329 322 listenerMux.unregisterItem( sid ); 330 323 331 324 return NULL; //iface; 332 325 } … … 385 378 " on link " << id.toString() ); 386 379 387 OverlayMsg overMsg( 388 OverlayMsg::OverlayMessageTypeUpdate, 389 i->second.service, 390 nodeId 380 OverlayMsg overMsg( 381 OverlayMsg::OverlayMessageTypeUpdate, 382 i->second.service, 383 nodeId 391 384 ); 392 385 … … 655 648 656 649 overlayInterface->createOverlay(); 657 658 // inform all registered services of the event659 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){660 i->onOverlayCreate( spovnetId );661 }662 663 650 overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() ); 664 651 … … 765 752 // inform all registered services of the event 766 753 BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){ 767 i->on OverlayDestroy( spovnetId );754 i->onLeaveFail( spovnetId ); 768 755 } 769 756 … … 815 802 sendMessage( message, *i, service ); // TODO: sollte auto links aufbauen fÃŒr sowas 816 803 } 804 } 805 806 vector<NodeID> BaseOverlay::getOverlayNeighbors() const { 807 // the known nodes _can_ also include our 808 // node, so we remove ourselfs 809 810 vector<NodeID> nodes = overlayInterface->getKnownNodes(); 811 vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId ); 812 if( i != nodes.end() ) nodes.erase( i ); 813 814 return nodes; 817 815 } 818 816 -
source/ariba/overlay/BaseOverlay.h
r2803 r3037 44 44 #include <algorithm> 45 45 #include <ctime> 46 #include <list> 47 #include <vector> 46 48 #include <boost/foreach.hpp> 47 49 … … 66 68 #include "ariba/overlay/messages/JoinReply.h" 67 69 70 using std::vector; 71 using std::list; 68 72 using std::cout; 69 73 using std::map; 70 74 using std::make_pair; 71 75 using std::pair; 76 using std::find; 72 77 73 78 using ariba::communication::EndpointDescriptor; … … 103 108 // in different namespace 104 109 namespace ariba { 105 namespace interface { 106 class UnderlayAbstraction; 107 }} 110 class Node; 111 } 108 112 109 113 namespace ariba { … … 117 121 118 122 use_logging_h( BaseOverlay ); 119 friend class ariba:: interface::UnderlayAbstraction;123 friend class ariba::Node; 120 124 121 125 public: … … 166 170 const ServiceID& service 167 171 ); 172 173 /** 174 * Get a list of overlay neighboring nodes. 175 */ 176 vector<NodeID> getOverlayNeighbors() const; 168 177 169 178 /** … … 324 333 static const LinkItem UNSPECIFIED; 325 334 326 LinkItem( const LinkID& _link, const NodeID& _node, 335 LinkItem( const LinkID& _link, const NodeID& _node, 327 336 const ServiceID& _service, ServiceInterface* _interface ) 328 : link( _link ), node( _node ), service( _service ), interface( _interface ), 337 : link( _link ), node( _node ), service( _service ), interface( _interface ), 329 338 autolink( false ), lastuse( time(NULL) ) { 330 339 } … … 350 359 typedef pair<const LinkID,LinkItem> LinkPair; 351 360 LinkMapping linkMapping; 352 361 353 362 // nodes with pending joines. TODO: should be cleaned every some seconds 354 363 // add timestamps to each, and check on occasion -
source/ariba/overlay/OverlayEvents.cpp
r3036 r3037 48 48 } 49 49 50 void OverlayEvents::onOverlayCreate( const SpoVNetID& id ){51 }52 53 void OverlayEvents::onOverlayDestroy( const SpoVNetID& id ){54 }55 56 50 bool OverlayEvents::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){ 57 51 // default: allow all nodes to join … … 71 65 } 72 66 67 void OverlayEvents::onLeaveSuccess( const SpoVNetID& spovnetid ){ 68 } 69 70 void OverlayEvents::onLeaveFail( const SpoVNetID& spovnetid ){ 71 } 72 73 73 void OverlayEvents::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){ 74 74 } -
source/ariba/overlay/OverlayEvents.h
r3036 r3037 58 58 59 59 protected: 60 61 virtual void onOverlayCreate( const SpoVNetID& id );62 virtual void onOverlayDestroy( const SpoVNetID& id );63 64 60 /// for initiator about remote nodes 65 61 virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ); … … 70 66 virtual void onJoinSuccess( const SpoVNetID& spovnetid ); 71 67 virtual void onJoinFail( const SpoVNetID& spovnetid ); 68 virtual void onLeaveSuccess( const SpoVNetID& spovnetid ); 69 virtual void onLeaveFail( const SpoVNetID& spovnetid ); 72 70 73 71 virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ); -
source/ariba/utility/messages/Message.h
r3036 r3037 235 235 } 236 236 return NULL; 237 } 238 239 /** 240 * The same as decapsulate, but this function 241 * is used in the samples to make the semantics easier 242 * to understand. The semantics is shown to be: you get 243 * a message and convert it to your type. Not as: you 244 * get a message and have to extract your message from it. 245 */ 246 template<class T> 247 inline T* convert() { 248 return decapsulate<T>(); 237 249 } 238 250 -
source/ariba/utility/misc/Helper.cpp
r3036 r3037 49 49 _ultoa_s (val, buf, 16, 10); 50 50 #else 51 sprintf (buf, "% u", val);51 sprintf (buf, "%lu", val); 52 52 #endif 53 53 … … 62 62 _ltoa_s (val, buf, 16, 10); 63 63 #else 64 sprintf (buf, "% i", val);64 sprintf (buf, "%li", val); 65 65 #endif 66 66 … … 75 75 _ultoa_s (val, buf, 16, 16); 76 76 #else 77 sprintf (buf, "% x", val);77 sprintf (buf, "%lx", val); 78 78 #endif 79 79 … … 93 93 _ltoa_s (val, buf, 16, 16); 94 94 #else 95 sprintf (buf, "% x", val);95 sprintf (buf, "%lx", val); 96 96 #endif 97 97 -
source/ariba/utility/system/StartupInterface.h
r3036 r3037 45 45 46 46 namespace ariba { 47 namespace interface {48 class UnderlayAbstraction;49 }}50 51 using ariba::interface::UnderlayAbstraction;52 53 namespace ariba {54 47 namespace utility { 55 48
Note:
See TracChangeset
for help on using the changeset viewer.