SOLA
Loading...
Searching...
No Matches
paxos_consensus.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_CONSENSUS_H_
18#define DAISI_PATH_PLANNING_CONSENSUS_PAXOS_CONSENSUS_H_
19
20#include <memory>
21
22#include "path_planning/consensus/consensus_base.h"
23#include "paxos_acceptor.h"
24#include "paxos_data.h"
25#include "paxos_proposer.h"
26#include "sola-ns3/sola_ns3_wrapper.h"
27
28namespace daisi::path_planning::consensus {
29class PaxosConsensus final : public ConsensusBase<PaxosConsensus, PaxosContainer> {
30public:
31 PaxosConsensus(std::shared_ptr<sola_ns3::SOLAWrapperNs3> sola, uint32_t node_id,
32 PaxosSettings settings, std::shared_ptr<PathPlanningLoggerNs3> logger);
33
34private:
35 friend ConsensusBase;
36
37 // CRTP implementation
38 void findConsensusImpl(const PointTimePairs &points, double seconds_earliest_start,
39 std::function<void(uint32_t, double)> success_cb,
40 std::function<void(uint32_t)> fail_cb);
41 void recvTopicMessageImpl(const std::string &topic, const std::string &msg);
42
43 void processPaxosMessage(const std::string &topic, const std::string &msg_content);
44
45 // Every paxos participant in this use case is proposer and acceptor at the same time
46 PaxosProposer proposer_;
47 PaxosAcceptor acceptor_;
48};
49
50} // namespace daisi::path_planning::consensus
51
52#endif // DAISI_PATH_PLANNING_CONSENSUS_PAXOS_CONSENSUS_H_
CRTP base class for a consensus algorithm.
Definition consensus_base.h:29
Implementation for an acceptor in the paxos consensus algorithm.
Definition paxos_acceptor.h:30
Implementation for an proposer in the paxos consensus algorithm.
Definition paxos_proposer.h:32