SOLA
Loading...
Searching...
No Matches
logic_container.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_LOGIC_CONTAINER_H_
8#define MINHTON_CORE_LOGIC_CONTAINER_H_
9
10#include <future>
11#include <memory>
12
13#include "minhton/algorithms/algorithm_interface.h"
14#include "minhton/algorithms/esearch/interface_entity_search_algorithm.h"
15#include "minhton/algorithms/esearch/node_data.h"
16#include "minhton/algorithms/join/interface_join_algorithm.h"
17#include "minhton/algorithms/leave/interface_leave_algorithm.h"
18#include "minhton/algorithms/misc/interface_bootstrap_algorithm.h"
19#include "minhton/algorithms/misc/interface_response_algorithm.h"
20#include "minhton/algorithms/search_exact/interface_search_exact_algorithm.h"
21#include "minhton/core/access_container.h"
22#include "minhton/core/constants.h"
23#include "minhton/core/definitions.h"
24#include "minhton/message/message.h"
25#include "minhton/utils/algorithm_types_container.h"
26
27namespace minhton {
28
30public:
31 LogicContainer() = default;
32 explicit LogicContainer(std::shared_ptr<AccessContainer> access,
33 const AlgorithmTypesContainer &types_container);
34
35 void process(const MessageVariant &msg);
36 void processSignal(Signal &signal);
37 void processTimeout(const Timeout &timeout_event);
38
39 bool isBootstrapResponseValid() const;
40 bool canLeaveWithoutReplacement() const;
41
42 void performSearchExactTest(const minhton::NodeInfo &destination,
43 std::shared_ptr<minhton::MessageSEVariant> query);
44
45 std::future<FindResult> find(const FindQuery &query);
46
47 void localInsert(const std::vector<Entry> &entries);
48 void localUpdate(const std::vector<Entry> &entries);
49 void localRemove(const std::vector<std::string> &keys);
50
51private:
52 std::shared_ptr<JoinAlgorithmInterface> join_algo_;
53 std::shared_ptr<LeaveAlgorithmInterface> leave_algo_;
54 std::shared_ptr<SearchExactAlgorithmInterface> search_exact_algo_;
55 std::shared_ptr<ResponseAlgorithmInterface> response_algo_;
56 std::shared_ptr<BootstrapAlgorithmInterface> bootstrap_algo_;
57 std::shared_ptr<EntitySearchAlgorithmInterface> entity_search_algo_;
58
59 std::unordered_map<minhton::MessageType, std::shared_ptr<AlgorithmInterface>>
60 message_type_to_algorithm_map_;
61
62 void associateMessageTypesWithAlgorithm(std::vector<minhton::MessageType> types,
63 std::shared_ptr<AlgorithmInterface> algorithm);
64};
65
66} // namespace minhton
67
68#endif
Definition find_query.h:21
Definition logic_container.h:29
Definition node_info.h:24
Definition minhton_watchdog_ns3.cpp:24
Definition algorithm_types_container.h:14
Definition fsm.h:26
Definition fsm.h:49