SOLA
Loading...
Searching...
No Matches
paxos_replication_manager.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_PATH_PLANNING_CONSENSUS_PAXOS_REPLICATION_MANAGER_H_
18#define DAISI_PATH_PLANNING_CONSENSUS_PAXOS_REPLICATION_MANAGER_H_
19
20#include <memory>
21
22#include "path_planning/consensus/paxos/message/replication_message.h"
23#include "path_planning/path_planning_logger_ns_3.h"
24#include "paxos_settings.h"
25
26namespace daisi::path_planning::consensus {
30public:
31 PaxosReplicationManager(std::string station_id, std::shared_ptr<PathPlanningLoggerNs3> logger,
32 const PaxosSettings &settings);
33
34 void processReplicationMessage(const ReplicationMessage &msg);
35
36private:
37 const std::string station_id_;
38 std::shared_ptr<PathPlanningLoggerNs3> logger_;
39 const PaxosSettings settings_;
40
41 struct Data {
42 uint32_t proposal_id;
43 uint32_t station_id;
44 // TO BE EXTENDED
45 };
46
48 struct UnfinishedData {
49 Data data;
50 uint32_t remaining_replications;
51 };
52
53 using InstanceID = uint32_t;
54 using InstanceProposalStationTuple = std::tuple<InstanceID, uint32_t, uint32_t>;
55
56 struct TupleHash {
57 std::size_t operator()(const InstanceProposalStationTuple &tuple) const {
58 return std::hash<uint32_t>()(std::get<0>(tuple)) ^ std::hash<uint32_t>()(std::get<1>(tuple)) ^
59 std::hash<uint32_t>()(std::get<2>(tuple));
60 }
61 };
62
63 std::unordered_map<InstanceID, Data> log_;
64 std::unordered_map<InstanceProposalStationTuple, UnfinishedData, TupleHash> outstanding_data_;
65};
66} // namespace daisi::path_planning::consensus
67
68#endif // DAISI_PATH_PLANNING_CONSENSUS_PAXOS_REPLICATION_MANAGER_H_
Definition paxos_replication_manager.h:29
Definition replication_message.h:28