SOLA
Loading...
Searching...
No Matches
minhton_entity_search_algorithm.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_ESEARCH_MINHTON_ENTITIY_SEARCH_ALGORITHM_H_
8#define MINHTON_ALGORITHMS_ESEARCH_MINHTON_ENTITIY_SEARCH_ALGORITHM_H_
9
10#include <memory>
11
12#include "minhton/algorithms/esearch/dsn_handler.h"
13#include "minhton/algorithms/esearch/interface_entity_search_algorithm.h"
14#include "minhton/algorithms/esearch/local_data.h"
15#include "minhton/core/definitions.h"
16#include "minhton/message/attribute_inquiry_answer.h"
17#include "minhton/message/attribute_inquiry_request.h"
18#include "minhton/message/find_query_answer.h"
19#include "minhton/message/find_query_request.h"
20#include "minhton/message/message.h"
21#include "minhton/message/search_exact_failure.h"
22#include "minhton/message/subscription_order.h"
23#include "minhton/message/subscription_update.h"
24
25namespace minhton {
26
28public:
29 explicit MinhtonEntitySearchAlgorithm(std::shared_ptr<AccessContainer> access);
30
31 void process(const MessageVariant &msg) override;
32 void processTimeout(const TimeoutType &type) override;
33
34 std::future<FindResult> find(FindQuery query) override;
35
36 void localInsert(std::vector<Entry> entries) override;
37 void localUpdate(std::vector<Entry> entries) override;
38 void localRemove(std::vector<std::string> keys) override;
39
40private:
41 void processFindQueryRequest(const MessageFindQueryRequest &msg);
42 void processFindQueryAnswer(const MessageFindQueryAnswer &msg);
43 void processAttributeInquiryAnswer(const MessageAttributeInquiryAnswer &msg);
44 void processAttributeInquiryRequest(const MessageAttributeInquiryRequest &msg);
45 void processSubscriptionUpdate(const MessageSubscriptionUpdate &msg);
46 void processSubscriptionOrder(const MessageSubscriptionOrder &msg);
47 void processSearchExactFailure(const MessageSearchExactFailure &msg);
48
49 void performFindQueryForwarding(const MessageFindQueryRequest &msg);
50 void performSendInquiryAggregations(uint64_t ref_event_id, FindQuery &query);
51 void savePreliminaryResultsFromInquiryAggregation(uint64_t ref_event_id,
52 NodeData::NodesWithAttributes results);
53
54 void processDSNAggregationTimeout();
55 void processInquiryAggregationTimeout();
56
57 void notifyAboutFindQueryResults(uint64_t ref_event_id, const FindQuery &query,
58 NodeData::NodesWithAttributes results);
59
60 void concludeAggregationOfInquiries(uint64_t ref_event_id);
61 void concludeAggregationOfDSNs(uint64_t ref_event_id);
62
63 void requestAttributeInformation(const NodeInfo &node);
64
65 void optimizeSubscriptions();
66 void updateSubscribers(NodeData::Key key);
67
68 std::vector<NodeInfo> calcDSNsToSendInitialCDSForwardingTo() const;
69
70 static NodeData::NodesWithAttributes filterAggregationResultsAfterInquiries(
71 const NodeData::NodesWithAttributes &full_results, const FindQuery::FindQueryScope &scope);
72
73 static NodeData::NodesWithAttributes filterAggregationResultsAfterDSNs(
74 const NodeData::NodesWithAttributes &full_results, const FindQuery::FindQueryScope &scope);
75
76 static NodeData::NodesWithAttributes filterDuplicateAttributes(
77 NodeData::NodesWithAttributes full_results);
78
79 NodeData::NodesWithAttributes getRelevantAttributesAndValues(
80 const std::vector<NodeInfo> &true_nodes, const FindQuery &query);
81
82 void logKeyValueContentUpdateInsert(NodeData::Key key, NodeData::Value value,
83 NodeData::ValueType type);
84 void logKeyValueContentRemove(NodeData::Key key);
85
86 LocalData local_data_;
87 DSNHandler dsn_handler_;
88
89 static const uint8_t kFindQuerySomeScopeThreshold = 2;
90
91 const uint16_t default_num_of_forwarding_hops_per_dsn_ = 5;
92
93 uint64_t value_time_validity_threshold_at_find_query_request_;
94 uint64_t value_time_validity_threshold_after_inquiry_aggregation_;
95
96 bool publish_attributes_after_insert_and_removal_ = true;
97};
98
99} // namespace minhton
100
101#endif
Definition dsn_handler.h:21
Definition interface_entity_search_algorithm.h:21
Definition find_query.h:21
Definition local_data.h:14
Usage: The message that the node which received a MessageAttributeInquiryRequest sends back.
Definition attribute_inquiry_answer.h:20
Usage: A node that is not a DSN may receive a MessageAttributeInquiryRequest during an ongoing Entity...
Definition attribute_inquiry_request.h:20
Usage: A DSN sends a MessageFindQueryAnswer back to the requesting node (that sent this DSN a Message...
Definition find_query_answer.h:22
Usage: A node that wants to find data in the network can call the Entity Search Algorithm,...
Definition find_query_request.h:20
Usage: If a node cannot further forward a MessageSearchExact, but is also not the target node,...
Definition search_exact_failure.h:18
Usage: A node can send a MessageSubscriptionOrder to subscribe or unsubscribe itself from the data an...
Definition subscription_order.h:18
Usage: If a node's local data is modified (inserted, updated or removed), it will send a subscription...
Definition subscription_update.h:18
Definition minhton_entity_search_algorithm.h:27
Definition node_info.h:24
Definition minhton_watchdog_ns3.cpp:24