SOLA
Loading...
Searching...
No Matches
paxos_acceptor.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_ACCEPTOR_H_
18#define DAISI_PATH_PLANNING_CONSENSUS_PAXOS_ACCEPTOR_H_
19
20#include <memory>
21
22#include "path_planning/consensus/paxos/message/accept_message.h"
23#include "path_planning/consensus/paxos/message/ok_message.h"
24#include "path_planning/consensus/paxos/message/prepare_message.h"
25#include "path_planning/consensus/paxos/paxos_data.h"
26#include "path_planning/constants.h"
27
28namespace daisi::path_planning::consensus {
31public:
32 explicit PaxosAcceptor(std::shared_ptr<PaxosContainer> container);
33
34 void processPrepareMessage(const PrepareMessage &msg);
35 void processAcceptMessage(const AcceptMessage &msg);
36 void processOKMessage(const OKMessage &msg);
37
38private:
39 std::shared_ptr<PaxosContainer> container_;
40
42 uint32_t current_accepted_instance_ = UINT32_MAX;
43 uint32_t current_accepted_proposal_id_ = UINT32_MAX;
44 uint32_t current_accepted_station_ = UINT32_MAX;
45 uint32_t remaining_oks_ = 0;
46
48 struct AlreadyReceivedOKS {
49 uint32_t instance = 0;
50 uint32_t proposal_id = 0;
51 uint32_t station = 0;
52 uint32_t already_received = 0;
53 };
54 std::vector<AlreadyReceivedOKS>
55 already_received_;
56
57 void sendResponseMessage();
58};
59} // namespace daisi::path_planning::consensus
60
61#endif // DAISI_PATH_PLANNING_CONSENSUS_PAXOS_ACCEPTOR_H_
Implementation for an acceptor in the paxos consensus algorithm.
Definition paxos_acceptor.h:30
< OK message from all acceptors to all other participants to commit the requested occupancy
Definition ok_message.h:26