10 #include "../subgroup_info.hpp" 11 #include "../view.hpp" 15 #include <spdlog/spdlog.h> 30 int32_t leader_id, std::vector<int32_t> max_received_by_sender)
31 : subgroup_id(subgroup_id), shard_num(shard_num), vid(vid), leader_id(leader_id), max_received_by_sender(max_received_by_sender) {}
49 std::ostringstream string_builder;
50 string_builder <<
"RaggedTrim_" << subgroup_num <<
"_" <<
shard_num;
51 return string_builder.str();
55 using ragged_trim_map_t = std::map<subgroup_id_t, std::map<uint32_t, std::unique_ptr<RaggedTrim>>>;
66 void load_ragged_trim(
const View& curr_view);
117 bool compute_restart_view();
124 std::unique_ptr<View> update_curr_and_next_restart_view();
127 static const int RESTART_LEADER_TIMEOUT = 2000;
146 bool has_restart_quorum();
154 bool resend_view_until_quorum_lost();
163 int64_t send_restart_view();
177 int64_t send_prepare();
192 void print_longest_logs()
const;
207 static std::unique_ptr<View> make_next_view(
const std::unique_ptr<View>& curr_view,
208 const std::vector<node_id_t>& joiner_ids,
209 const std::vector<std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t>>& joiner_ips_and_ports);
214 static bool contains_at_least_one_member_per_subgroup(std::set<node_id_t> rejoined_node_ids,
215 const View& last_view);
uint32_t subgroup_id_t
Type alias for the internal Subgroup IDs generated by ViewManager.
std::vector< std::vector< int64_t > > restart_shard_leaders
Map from (subgroup ID, shard num) to ID of the "restart leader" for that shard, which is the node wit...
CommitMessage
A type-safe set of messages that can be sent during two-phase commit.
DEFAULT_SERIALIZATION_SUPPORT(RaggedTrim, subgroup_id, shard_num, vid, leader_id, max_received_by_sender)
const SubgroupInfo & subgroup_info
subgroup_id_t subgroup_id
RestartState & restart_state
Mutable reference to RestartState, since this class needs to update the restart state stored in ViewM...
std::vector< int32_t > max_received_by_sender
std::unique_ptr< View > restart_view
RaggedTrim(subgroup_id_t subgroup_id, uint32_t shard_num, int vid, int32_t leader_id, std::vector< int32_t > max_received_by_sender)
A non-POD type which wishes to mark itself byte representable should extend this class.
const View & get_curr_view() const
Read the curr_view (last known view) managed by RestartLeaderState.
std::set< node_id_t > rejoined_node_ids
std::map< subgroup_id_t, std::map< uint32_t, std::unique_ptr< RaggedTrim > >> ragged_trim_map_t
List of logged ragged trim states, indexed by (subgroup ID, shard num), stored by pointer...
std::set< node_id_t > last_known_view_members
std::unique_ptr< View > curr_view
Takes ownership of ViewManager's curr_view pointer, because await_quroum() might replace curr_view wi...
uint32_t node_id_t
Type alias for Node IDs in a Derecho group.
ragged_trim_map_t logged_ragged_trim
List of logged ragged trim states recovered from the last known View, either read locally from this n...
std::set< node_id_t > members_sent_restart_view
std::vector< std::vector< int64_t > > nodes_with_longest_log
Container for whatever information is needed to describe a Group's subgroups and shards.
std::vector< std::vector< persistent::version_t > > longest_log_versions
std::map< node_id_t, std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t > > rejoined_node_ips_and_ports
Represents the data needed to log a "ragged trim" decision to disk.
std::map< node_id_t, tcp::socket > waiting_join_sockets
std::unique_ptr< View > take_restart_view()
Remove and return the restart view managed by RestartLeaderState; this will take ownership back to th...
const View & get_restart_view() const
Read the current restart view managed by RestartLeaderState.
std::string ragged_trim_filename(subgroup_id_t subgroup_num, uint32_t shard_num)
Builds a filename to use for a RaggedTrim logged to disk using its subgroup and shard IDs...