SOLA
Loading...
Searching...
No Matches
leave_algorithm_general.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_ALGORITHMS_LEAVE_ALGORITHM_GENERAL_H_
8#define MINHTON_ALGORITHMS_LEAVE_ALGORITHM_GENERAL_H_
9
10#include <memory>
11#include <optional>
12
13#include "minhton/algorithms/leave/interface_leave_algorithm.h"
14#include "minhton/message/find_replacement.h"
15#include "minhton/message/lock_neighbor_request.h"
16#include "minhton/message/lock_neighbor_response.h"
17#include "minhton/message/message.h"
18#include "minhton/message/remove_neighbor.h"
19#include "minhton/message/remove_neighbor_ack.h"
20#include "minhton/message/replacement_ack.h"
21#include "minhton/message/replacement_nack.h"
22#include "minhton/message/replacement_offer.h"
23#include "minhton/message/replacement_update.h"
24#include "minhton/message/signoff_parent_answer.h"
25#include "minhton/message/signoff_parent_request.h"
26#include "minhton/message/unlock_neighbor.h"
27#include "minhton/message/update_neighbors.h"
28
29namespace minhton {
30
32public:
33 explicit LeaveAlgorithmGeneral(std::shared_ptr<AccessContainer> access)
34 : LeaveAlgorithmInterface(access){};
35
36 ~LeaveAlgorithmGeneral() override = default;
37
38 void process(const MessageVariant &msg) override;
39
50 void initiateSelfDeparture() override = 0;
51
52protected:
62
76
92
108
121
135
151
157
173
182
197 std::vector<minhton::NodeInfo> neighbors_of_leaving_node,
198 bool leaving_node_was_locked, bool leaving_node_locked_right,
199 bool leaving_node_locked_left);
200
205 void prepareLeavingAsSuccessor(const minhton::NodeInfo &node_to_replace);
206
210 void signOffFromParent();
211
222
230
237
242 void sendNackToReplacement(uint64_t ref_event_id);
243
256 void replaceMyself(const minhton::NodeInfo &node_to_replace,
257 std::vector<minhton::NodeInfo> neighbors_of_node_to_replace) override;
258
267
274
288
289 // TODO Temporary
290 minhton::NodeInfo replacing_node_;
291 uint64_t leaving_event_id_ = 0;
292 bool in_leave_progress_ = false;
293 bool locked_right_neighbor_ = false;
294 bool locked_left_neighbor_ = false;
295 uint32_t remaining_lock_neighbor_response_ = 0;
296 std::shared_ptr<minhton::MessageSignoffParentRequest> current_signoff_request_ = nullptr;
297
298 std::shared_ptr<minhton::MessageReplacementUpdate> last_replacement_update_ = nullptr;
299 NodeInfo old_parent_;
300
317 std::vector<minhton::NodeInfo> neighbors);
318
335 std::vector<minhton::NodeInfo> neighbors);
336};
337
338} // namespace minhton
339
340#endif
Definition leave_algorithm_general.h:31
void sendNackToReplacement(uint64_t ref_event_id)
Definition leave_algorithm_general.cpp:602
void processReceiveSignoffNeighborAdjacentsAck()
Definition leave_algorithm_general.cpp:565
void prepareLeavingAsSuccessor(const minhton::NodeInfo &node_to_replace)
Definition leave_algorithm_general.cpp:360
void processLockNeighborRequest(const minhton::MessageLockNeighborRequest &message)
Definition leave_algorithm_general.cpp:442
void replaceMyself(const minhton::NodeInfo &node_to_replace, std::vector< minhton::NodeInfo > neighbors_of_node_to_replace) override
Definition leave_algorithm_general.cpp:618
void processUpdateForwardAck()
Definition leave_algorithm_general.cpp:530
void processLockNeighborResponse(const minhton::MessageLockNeighborResponse &message)
Definition leave_algorithm_general.cpp:458
void sendReplacementOffer()
Definition leave_algorithm_general.cpp:608
void initiateSelfDeparture() override=0
void processUnlockNeighbor(const MessageUnlockNeighbor &msg)
Definition leave_algorithm_general.cpp:47
uint32_t signOffFromNeighborsAndAdjacents()
Definition leave_algorithm_general.cpp:273
void processReplacementAck(const minhton::MessageReplacementAck &message)
Definition leave_algorithm_general.cpp:173
static minhton::NodeInfo getAdjacentLeftFromVector(const minhton::NodeInfo &considered_node, std::vector< minhton::NodeInfo > neighbors)
Definition leave_algorithm_general_helper.cpp:12
void processSignOffParentAnswer(const minhton::MessageSignoffParentAnswer &message)
Definition leave_algorithm_general.cpp:547
void processReplacementUpdate(const minhton::MessageReplacementUpdate &message)
Definition leave_algorithm_general.cpp:129
virtual void processFindReplacement(const minhton::MessageFindReplacement &message)=0
static minhton::NodeInfo getAdjacentRightFromVector(const minhton::NodeInfo &considered_node, std::vector< minhton::NodeInfo > neighbors)
Definition leave_algorithm_general_helper.cpp:33
void performLeaveWithoutReplacement()
Definition leave_algorithm_general.cpp:182
void processReceiveReplacementUpdateAck()
Definition leave_algorithm_general.cpp:588
void processRemoveNeighborAck()
Definition leave_algorithm_general.cpp:539
void performLeaveWithReplacement(minhton::NodeInfo leaving_node, std::vector< minhton::NodeInfo > neighbors_of_leaving_node, bool leaving_node_was_locked, bool leaving_node_locked_right, bool leaving_node_locked_left)
Definition leave_algorithm_general.cpp:195
void processSignOffParentRequest(const minhton::MessageSignoffParentRequest &message)
Definition leave_algorithm_general.cpp:393
void signOffFromParent()
Definition leave_algorithm_general.cpp:381
void processReplacementOffer(const minhton::MessageReplacementOffer &message)
Definition leave_algorithm_general.cpp:99
Definition interface_leave_algorithm.h:18
Usage: A node wants to leave the network, but cannot leave the position directly because it would vio...
Definition find_replacement.h:21
Usage: The parent of a successor node sends a Lock Neighbor Request to its right and left neighbor....
Definition lock_neighbor_request.h:18
Usage: The answer to a MessageLockNeighborRequest, received by the parent of a successor node.
Definition lock_neighbor_response.h:17
Usage: The node that wants to leave the network receives a MessageReplacementOffer from a node that i...
Definition replacement_ack.h:19
Usage: A MessageFindReplacement reached a node that can replace the leaving node. The node sends a Me...
Definition replacement_offer.h:18
Usage: During the replacement process, the neighbor nodes of the leaving node / the replaced position...
Definition replacement_update.h:20
Usage: The successor node waits for the MessageSignoffParentAnswer from its parent after sending a Me...
Definition signoff_parent_answer.h:17
Usage: The last node of the network, the chosen successor, sends a MessageSignoffParentRequest to its...
Definition signoff_parent_request.h:18
Usage: Used for unlocking nodes after they were locked during a concurrent operation like leave.
Definition unlock_neighbor.h:17
Definition node_info.h:24
Definition minhton_watchdog_ns3.cpp:24