source: source/ariba/Node.cpp@ 3055

Last change on this file since 3055 was 3055, checked in by Christoph Mayer, 15 years ago

-temporärer commit, sorry kompiliert nicht :( muss aber die änderungen auf die andere maschine kriegen, ist in ca1h gefixt.

File size: 5.4 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#include "Node.h"
40
41#include "ariba/overlay/BaseOverlay.h"
42#include "ariba/utility/types/OverlayParameterSet.h"
43#include "ariba/communication/EndpointDescriptor.h"
44
45using ariba::communication::EndpointDescriptor;
46
47namespace ariba {
48
49Node::Node(AribaModule& ariba_mod, const Name& node_name) :
50 ariba_mod(ariba_mod), name(node_name) {
51 base_overlay = new BaseOverlay();
52}
53
54Node::~Node() {
55 delete base_overlay;
56 base_overlay = NULL;
57}
58
59//TODO: Implement error handling: no bootstrap node available
60void Node::join(const Name& vnetname) {
61 spovnetId = vnetname.toSpoVNetId();
62 nodeId = generateNodeId(name);
63
64 const communication::EndpointDescriptor* ep =
65 ariba_mod.getBootstrapNode(vnetname);
66 if( ep == NULL ) return;
67
68 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
69 base_overlay->start( *ariba_mod.base_comm, nodeId );
70 base_overlay->joinSpoVNet( spovnetId, *ep);
71}
72
73void Node::initiate(const Name& vnetname, const SpoVNetProperties& parm) {
74 utility::OverlayParameterSet ovrpset =
75 (utility::OverlayParameterSet::_OverlayStructure)
76 parm.getBaseOverlayType();
77
78 spovnetId = vnetname.toSpoVNetId();
79 nodeId = generateNodeId(name);
80
81 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
82
83 base_overlay->start( *ariba_mod.base_comm, nodeId );
84 base_overlay->createSpoVNet( spovnetId );
85
86 ariba_mod.addBootstrapNode(vnetname,
87 new EndpointDescriptor(ariba_mod.base_comm->getEndpointDescriptor()));
88}
89
90void Node::leave() {
91 base_overlay->leaveSpoVNet();
92 ariba_mod.base_comm->stop();
93 base_overlay->stop();
94}
95
96const SpoVNetProperties& Node::getSpoVNetProperties() const {
97 return SpoVNetProperties::DEFAULT;
98}
99
100const SpoVNetID& Node::getSpoVNetId() const {
101 return spovnetId;
102}
103
104const NodeID& Node::getNodeId(const LinkID& lid) const {
105 if( lid == LinkID::UNSPECIFIED ) return nodeId;
106 else return base_overlay->getNodeID( lid );
107}
108
109NodeID Node::generateNodeId(const Name& name) const {
110 if (name == Name::UNSPECIFIED) return Name::random().toNodeId();
111 else return name.toNodeId();
112}
113
114vector<NodeID> Node::getNeighborNodes() const {
115 return base_overlay->getOverlayNeighbors();
116}
117
118LinkID Node::establishLink(const NodeID& nid, const ServiceID& sid,
119 const LinkProperties& req, const DataMessage& msg) {
120 return base_overlay->establishLink(nid, sid);
121}
122
123void Node::dropLink(const LinkID& lnk) {
124 base_overlay->dropLink(lnk);
125}
126
127seqnum_t Node::sendMessage(const DataMessage& msg, const NodeID& nid,
128 const ServiceID& sid, const LinkProperties& req) {
129 return base_overlay->sendMessage((Message*) msg, nid, sid);
130}
131
132seqnum_t Node::sendMessage(const DataMessage& msg, const LinkID& lnk) {
133 return base_overlay->sendMessage((Message*) msg, lnk);
134}
135
136void Node::sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid) {
137 return base_overlay->broadcastMessage((Message*)msg, sid);
138}
139
140void Node::bind(NodeListener* listener) {
141 base_overlay->bind(listener);
142}
143
144void Node::unbind(NodeListener* listener) {
145 base_overlay->unbind(listener);
146}
147
148void Node::bind(CommunicationListener* listener, const ServiceID& sid) {
149 base_overlay->bind(listener, sid);
150}
151
152void Node::unbind(CommunicationListener* listener, const ServiceID& sid) {
153 base_overlay->unbind(listener, sid);
154}
155
156// service directory
157/*
158 void Node::put(const Identifier<>& key, Message* value) {
159 }
160
161 void Node::get(const Identifier<>& key) {
162
163 }
164 */
165
166// @see Module.h
167void Node::initialize() {
168
169}
170
171// @see Module.h
172void Node::start() {
173
174}
175
176// @see Module.h
177void Node::stop() {
178
179}
180
181// @see Module.h
182string Node::getName() const {
183
184}
185
186// @see Module.h
187void Node::setProperty(string key, string value) {
188
189}
190
191// @see Module.h
192const string Node::getProperty(string key) const {
193
194}
195
196// @see Module.h
197const vector<string> Node::getProperties() const {
198
199}
200
201} // namespace ariba
Note: See TracBrowser for help on using the repository browser.