SOLA
Loading...
Searching...
No Matches
distributed_data.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 ALGORITHMS_ESEARCH_DISTRIBUTED_DATA_H_
8#define ALGORITHMS_ESEARCH_DISTRIBUTED_DATA_H_
9
10#include <cstdint>
11#include <queue>
12#include <unordered_map>
13#include <vector>
14
15#include "minhton/algorithms/esearch/node_data.h"
16#include "minhton/core/physical_node_info.h"
17
18namespace minhton {
19
20class DistributedData : public NodeData {
21public:
22 DistributedData() = default;
23 explicit DistributedData(const PhysicalNodeInfo &p_node_info);
24
25 virtual ~DistributedData() = default;
26
27 void setPhysicalNodeInfo(const PhysicalNodeInfo &p_node_info);
28 PhysicalNodeInfo getPhysicalNodeInfo() const;
29
30 bool insert(Key key, NodeData::ValueTimestampAndType value_timestamp_and_type) override;
31 bool update(Key key, NodeData::ValueTimestampAndType value_timestamp_and_type) override;
32 void remove(Key key) override;
33
34 void addSubscriptionOrderKey(NodeData::Key key);
35 void removeSubscriptionOrderKey(NodeData::Key key);
36 std::vector<NodeData::Key> getSubscriptionOrderKeys() const;
37
38 std::queue<uint64_t> getUpdateTimestamps(const NodeData::Key &key);
39
40 bool isKeySubscribed(NodeData::Key key);
41
42 bool isValueUpToDate(const NodeData::Key &key, uint64_t validity_threshold_timestamp) override;
43
44 uint8_t getTimestampStorageLimit() const;
45
46 bool isLocal() const override;
47
48private:
49 PhysicalNodeInfo p_node_info_;
50
51 // for which keys we have sent a subscription order
52 std::vector<NodeData::Key> subscription_ordered_keys_;
53
54 // to see how often we get updates
55 std::unordered_map<NodeData::Key, std::queue<uint64_t>> update_timestamps_;
56
57 // how many items we store in update timestamps
58 uint8_t timestamp_storage_limit_ = 5;
59};
60
61} // namespace minhton
62
63#endif
Definition distributed_data.h:20
Definition node_data.h:20
Definition physical_node_info.h:23
Definition minhton_watchdog_ns3.cpp:24