mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 09:00:35 +00:00
Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
/*
|
|
*
|
|
*
|
|
*/
|
|
/*
|
|
* Copyright (C) 2019-present ScyllaDB
|
|
*
|
|
* Modified by ScyllaDB
|
|
*/
|
|
/*
|
|
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
|
|
*/
|
|
#pragma once
|
|
#include "utils/UUID_gen.hh"
|
|
#include "frozen_mutation.hh"
|
|
|
|
namespace service {
|
|
|
|
namespace paxos {
|
|
|
|
// Proposal represents replica's value associated with a given ballot. The origin uses the term
|
|
// "commit" for this object, however, Scylla follows the terminology as set by Paxos Made Simple
|
|
// paper.
|
|
// Each replica persists the proposals it receives in the system.paxos table. A proposal may be
|
|
// new, accepted by a replica, or accepted by a majority. When a proposal is accepted by majority it
|
|
// is considered "chosen" by Paxos, and we call such a proposal "decision". A decision is
|
|
// saved in the paxos table in an own column and applied to the base table during "learn" phase of
|
|
// the protocol. After a decision is applied it is considered "committed".
|
|
class proposal {
|
|
public:
|
|
// The ballot for the update.
|
|
utils::UUID ballot;
|
|
// The mutation representing the update that is being applied.
|
|
frozen_mutation update;
|
|
|
|
proposal(utils::UUID ballot_arg, frozen_mutation update_arg)
|
|
: ballot(ballot_arg)
|
|
, update(std::move(update_arg)) {}
|
|
};
|
|
|
|
// Proposals are ordered by their ballot's timestamp.
|
|
// A proposer uses it to find the newest proposal accepted
|
|
// by some replica among the responses to its own one.
|
|
inline bool operator<(const proposal& lhs, const proposal& rhs) {
|
|
return lhs.ballot.timestamp() < rhs.ballot.timestamp();
|
|
}
|
|
|
|
inline bool operator>(const proposal& lhs, const proposal& rhs) {
|
|
return lhs.ballot.timestamp() > rhs.ballot.timestamp();
|
|
}
|
|
|
|
// Used for logging and debugging.
|
|
std::ostream& operator<<(std::ostream& os, const proposal& proposal);
|
|
|
|
} // end of namespace "paxos"
|
|
} // end of namespace "service"
|