SOLA
Loading...
Searching...
No Matches
node.h
1// Copyright The SOLA Contributors
2//
3// Licensed under the MIT License.
4// For details on the licensing terms, see the LICENSE file.
5// SPDX-License-Identifier: MIT
6
7#ifndef MINHTON_CORE_NODE_H_
8#define MINHTON_CORE_NODE_H_
9
10#include <chrono>
11#include <future>
12#include <memory>
13#include <thread>
14#include <vector>
15
16#include "minhton/algorithms/esearch/find_query.h"
17#include "minhton/core/connection_info.h"
18#include "minhton/core/definitions.h"
19#include "minhton/core/logic_container.h"
20#include "minhton/core/node_info.h"
21#include "minhton/core/routing_information.h"
22#include "minhton/core/watchdog.h"
23#include "minhton/logging/logging.h"
24#include "minhton/message/message.h"
25#include "minhton/message/types_all.h"
26#include "minhton/network/network_facade.h"
27#include "minhton/utils/config_node.h"
28#include "minhton/utils/fsm.h"
29#include "minhton/utils/procedure_info.h"
30
31namespace minhton {
32
33// Low level
35public:
37 explicit MinhtonNode(const ConfigNode &config_node,
38 NeighborCallbackFct fct = NeighborCallbackFct{}, bool auto_start = true);
39
57 void setConfig(const minhton::ConfigNode &config);
58
59 void stop();
60
62 virtual ~MinhtonNode() = default;
63
66
67 void processSignal(Signal signal);
68
69 void initFSM(minhton::FSMState &init_state);
70
71 FSMState getFsmState() const;
72
73 std::shared_ptr<minhton::RoutingInformation> getRoutingInformation();
74
75 void insert(const std::vector<Entry> &data);
76 void update(const std::vector<Entry> &data);
77 void remove(const std::vector<std::string> &keys);
78
79 std::future<FindResult> find(const std::string &query); // for high level api
80 std::future<FindResult> find(const FindQuery &query); // for testing
81
82 // if we expose this, we dont need to expose the logic container!
83 void performSearchExactTest(const minhton::NodeInfo &destination,
84 std::shared_ptr<minhton::MessageSEVariant> query);
85
86 // For debugging and testing purposes
87 std::shared_ptr<AccessContainer> getAccessContainer() const { return access_; };
88
89private:
101 void send(const MessageVariant &msg);
102
110 void prepareSending(const MessageVariant &msg_variant);
111
117 void triggerTimeout(const TimeoutType &timeout_type);
118
137 void recv(const MessageVariant &msg);
138
149 bool prepareReceiving(const MessageVariant &msg_variant);
150
168 void start(const JoinInfo &info, bool auto_connect = false);
169
171 std::shared_ptr<AccessContainer> access_;
172
174 NetworkFacade network_facade_;
175
177 std::shared_ptr<minhton::ProcedureInfo> procedure_info_;
178
180 bool verbose_ = true;
181
183 TimeoutLengthsContainer timeout_lengths_container_{};
184
186 uint16_t getTimeoutLength(const TimeoutType &timeout_type) const;
187
193 void setTimeout(TimeoutType timeout_type);
194
195 minhton::core::WatchDog watchdog_;
196
199 std::shared_ptr<minhton::RoutingInformation> routing_info_;
200
206
207 std::unique_ptr<LogicContainer> logic_;
208
209 NeighborCallbackFct neighbor_update_fct_;
210
211 NodeInfo replacing_node_;
212};
213} // namespace minhton
214
215#endif
Definition config_node.h:30
Definition find_query.h:21
Definition fsm.h:54
Definition node.h:34
virtual ~MinhtonNode()=default
Destructor.
void setConfig(const minhton::ConfigNode &config)
Definition node.cpp:42
minhton::NodeInfo getNodeInfo() const
Definition node.cpp:139
Definition network_facade.h:19
Definition node_info.h:24
Definition watchdog.h:20
Definition minhton_watchdog_ns3.cpp:24
Definition config_node.h:24
Definition fsm.h:26
Definition timeout_lengths_container.h:14