Changeset 3037 for source/ariba/Node.cpp
- Timestamp:
- Apr 22, 2009, 9:07:53 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.