#include <view_manager.hpp>
Public Member Functions | |
ViewManager (const SubgroupInfo &subgroup_info, const std::vector< std::type_index > &subgroup_type_order, const bool any_persistent_objects, const std::shared_ptr< tcp::tcp_connections > &group_tcp_sockets, ReplicatedObjectReferenceMap &object_reference_map, const persistence_manager_callbacks_t &_persistence_manager_callbacks, std::vector< view_upcall_t > _view_upcalls={}) | |
Constructor for a new group where this node is the GMS leader. More... | |
ViewManager (tcp::socket &leader_connection, const SubgroupInfo &subgroup_info, const std::vector< std::type_index > &subgroup_type_order, const bool any_persistent_objects, const std::shared_ptr< tcp::tcp_connections > &group_tcp_sockets, ReplicatedObjectReferenceMap &object_reference_map, const persistence_manager_callbacks_t &_persistence_manager_callbacks, std::vector< view_upcall_t > _view_upcalls={}) | |
Constructor for joining an existing group, assuming the caller has already opened a socket to the group's leader. More... | |
~ViewManager () | |
void | await_rejoining_nodes (const node_id_t my_id) |
Setup method for the leader when it is restarting from complete failure: waits for a restart quorum of nodes from the last known view to join. More... | |
bool | check_view_committed (tcp::socket &leader_connection) |
Setup method for non-leader nodes: checks whether the initial View received in the constructor gets committed by the leader, and if not, waits for another initial View to be sent. More... | |
bool | leader_prepare_initial_view (bool &leader_has_quorum) |
Setup method for the leader node in total restart mode: sends a Prepare message to all non-leader nodes indicating that state transfer has finished. More... | |
void | leader_commit_initial_view () |
Setup method for the leader node: sends a commit message to all non-leader nodes indicating that it is safe to use the initial View. More... | |
void | truncate_logs () |
An extra setup step only needed during total restart; truncates the persistent logs of this node to conform to the ragged trim decided on by the restart leader. More... | |
void | send_logs () |
An extra setup method only needed during total restart. More... | |
void | initialize_multicast_groups (CallbackSet callbacks) |
Sets up RDMA sessions for the multicast groups within this group. More... | |
void | finish_setup () |
Completes first-time setup of the ViewManager, including synchronizing the initial SST and delivering the first new-view upcalls. More... | |
void | start () |
Starts predicate evaluation in the current view's SST. More... | |
const vector_int64_2d & | get_old_shard_leaders () const |
void | leave () |
Causes this node to cleanly leave the group by setting itself to "failed.". More... | |
std::vector< node_id_t > | get_members () |
Returns a vector listing the nodes that are currently members of the group. More... | |
int32_t | get_my_rank () |
Returns the order of this node in the sequence of members of the group. More... | |
std::vector< std::vector< node_id_t > > | get_subgroup_members (subgroup_type_id_t subgroup_type, uint32_t subgroup_index) |
Returns a vector of vectors listing the members of a single subgroup (identified by type and index), organized by shard number. More... | |
std::size_t | get_number_of_shards_in_subgroup (subgroup_type_id_t subgroup_type, uint32_t subgroup_index) |
int32_t | get_my_shard (subgroup_type_id_t subgroup_type, uint32_t subgroup_index) |
If this node is a member of the given subgroup (identified by its type and index), returns the number of the shard this node belongs to. More... | |
void | send (subgroup_id_t subgroup_num, long long unsigned int payload_size, const std::function< void(char *buf)> &msg_generator, bool cooked_send=false) |
Instructs the managed DerechoGroup's to send the next message. More... | |
const uint64_t | compute_global_stability_frontier (subgroup_id_t subgroup_num) |
SharedLockedReference< View > | get_current_view () |
SharedLockedReference< const View > | get_current_view_const () |
This function is a dirty workaround for the fact that Group might need read-only access to curr_view during a total restart when curr_view is owned by restart_leader_state, but it's only available by const reference and SharedLockedReference<View> wants a mutable reference. More... | |
void | add_view_upcall (const view_upcall_t &upcall) |
Adds another function to the set of "view upcalls," which are called when the view changes to notify another component of the new view. More... | |
void | report_failure (const node_id_t who) |
Reports to the GMS that the given node has failed. More... | |
void | barrier_sync () |
Waits until all members of the group have called this function. More... | |
void | register_initialize_objects_upcall (initialize_rpc_objects_t upcall) |
Registers a function that will initialize all the RPC objects at this node, given a new view and a list of the shard leaders in the previous view (needed to download object state). More... | |
void | silence () |
stop complaining about node failures. More... | |
void | debug_print_status () const |
std::map< subgroup_id_t, uint64_t > | get_max_payload_sizes () |
Public Attributes | |
std::map< subgroup_id_t, uint64_t > | max_payload_sizes |
uint64_t | view_max_rpc_reply_payload_size = 0 |
uint32_t | view_max_rpc_window_size = 0 |
Private Types | |
using | pred_handle = sst::Predicates< DerechoSST >::pred_handle |
using | initialize_rpc_objects_t = std::function< void(node_id_t, const View &, const std::vector< std::vector< int64_t > > &)> |
using | ReplicatedObjectReferenceMap = std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject > > |
Private Member Functions | |
bool | has_pending_join () |
void | new_suspicion (DerechoSST &gmsSST) |
Called when there is a new failure suspicion. More... | |
void | leader_start_join (DerechoSST &gmsSST) |
Runs only on the group leader; proposes new views to include new members. More... | |
void | redirect_join_attempt (DerechoSST &gmsSST) |
Runs on non-leaders to redirect confused new members to the current leader. More... | |
void | new_leader_takeover (DerechoSST &gmsSST) |
Runs once on a node that becomes a leader due to a failure. More... | |
void | leader_commit_change (DerechoSST &gmsSST) |
Runs only on the group leader and updates num_committed when all non-failed members have acked a proposed view change. More... | |
void | acknowledge_proposed_change (DerechoSST &gmsSST) |
Updates num_acked to acknowledge a proposed change when the leader increments num_changes. More... | |
void | start_meta_wedge (DerechoSST &gmsSST) |
Runs when at least one membership change has been committed by the leader, and wedges the current view in preparation for a new view. More... | |
void | terminate_epoch (DerechoSST &gmsSST) |
Runs when all live nodes have reported they have wedged the current view (meta-wedged), and starts ragged edge cleanup to finalize the terminated epoch. More... | |
void | echo_ragged_trim (std::shared_ptr< std::map< subgroup_id_t, uint32_t >> follower_subgroups_and_shards, DerechoSST &gmsSST) |
Runs when the leader nodes of each subgroup have finished ragged edge cleanup. More... | |
void | deliver_ragged_trim (DerechoSST &gmsSST) |
Delivers messages that were marked deliverable by the ragged trim and proceeds to finish_view_change() when this is done. More... | |
void | finish_view_change (DerechoSST &gmsSST) |
Finishes installing the new view, assuming it is adequately provisioned. More... | |
bool | receive_join (DerechoSST &gmsSST, tcp::socket &client_socket) |
Assuming this node is the leader, handles a join request from a client. More... | |
void | update_tcp_connections (const View &new_view) |
Updates the TCP connections pool to reflect the joined and departed members in a new view. More... | |
void | send_objects_to_new_members (const View &new_view, const vector_int64_2d &old_shard_leaders) |
Helper method for completing view changes; determines whether this node needs to send Replicated Object state to each node that just joined, and then sends the state if necessary. More... | |
void | send_subgroup_object (subgroup_id_t subgroup_id, node_id_t new_node_id) |
Sends a single subgroup's replicated object to a new member after a view change. More... | |
void | send_view (const View &new_view, tcp::socket &client_socket) |
Sends a joining node the new view that has been constructed to include it. More... | |
void | log_ragged_trim (const int shard_leader_rank, const subgroup_id_t subgroup_num, const uint32_t num_received_offset, const uint num_shard_senders) |
Reads the global_min values for the specified subgroup (and the shard that this node belongs to) from the SST, creates a ragged trim vector with these values, and persists the ragged trim to disk. More... | |
void | deliver_in_order (const int shard_leader_rank, const subgroup_id_t subgroup_num, const uint32_t num_received_offset, const std::vector< node_id_t > &shard_members, uint num_shard_senders) |
Reads the global_min for the specified subgroup from the SST (assuming it has been computed already) and tells the current View's MulticastGroup to deliver messages up to the global_min (i.e. More... | |
void | leader_ragged_edge_cleanup (const subgroup_id_t subgroup_num, const uint32_t num_received_offset, const std::vector< node_id_t > &shard_members, uint num_shard_senders) |
Implements the Ragged Edge Cleanup algorithm for a subgroup/shard leader, operating on the shard that this node is a member of. More... | |
void | follower_ragged_edge_cleanup (const subgroup_id_t subgroup_num, uint shard_leader_rank, const uint32_t num_received_offset, uint num_shard_senders) |
Implements the Ragged Edge Cleanup algorithm for a non-leader node in a subgroup. More... | |
void | create_threads () |
Constructor helper method to encapsulate spawning the background threads. More... | |
void | register_predicates () |
Constructor helper method to encapsulate creating all the predicates. More... | |
void | load_ragged_trim () |
Constructor helper that reads logged ragged trim information from disk, called only if there is also a logged view on disk from a previous failed group. More... | |
void | await_first_view (const node_id_t my_id) |
Constructor helper for the leader when it first starts; waits for enough new nodes to join to make the first view adequately provisioned. More... | |
void | receive_view_and_leaders (const node_id_t my_id, tcp::socket &leader_connection) |
Constructor helper for non-leader nodes; encapsulates receiving and deserializing a View, DerechoParams, and state-transfer leaders (old shard leaders) from the leader. More... | |
void | truncate_persistent_logs (const ragged_trim_map_t &logged_ragged_trim) |
Helper function for total restart mode: Uses the RaggedTrim values in logged_ragged_trim to truncate any persistent logs that have a persisted version later than the last committed version in the RaggedTrim. More... | |
void | initialize_rdmc_sst () |
Performs one-time global initialization of RDMC and SST, using the current view's membership. More... | |
void | receive_initial_view (node_id_t my_id, tcp::socket &leader_connection) |
Helper for joining an existing group; receives the View and parameters from the leader. More... | |
void | setup_initial_tcp_connections (const View &initial_view, node_id_t my_id) |
Constructor helper that initializes TCP connections (for state transfer) to the members of initial_view in ascending rank order. More... | |
void | reinit_tcp_connections (const View &initial_view, node_id_t my_id) |
Another setup helper for joining nodes; re-initializes the TCP connections list to reflect the current list of members in initial_view, assuming that the first view was aborted and a new one has been sent. More... | |
void | construct_multicast_group (CallbackSet callbacks, const std::map< subgroup_id_t, SubgroupSettings > &subgroup_settings, const uint32_t num_received_size, const uint32_t slot_size) |
Creates the SST and MulticastGroup for the first time, using the current view's member list. More... | |
void | transition_multicast_group (const std::map< subgroup_id_t, SubgroupSettings > &new_subgroup_settings, const uint32_t new_num_received_size, const uint32_t new_slot_size) |
Sets up the SST and MulticastGroup for a new view, based on the settings in the current view, and copies over the SST data from the current view. More... | |
std::pair< uint32_t, uint32_t > | derive_subgroup_settings (View &curr_view, std::map< subgroup_id_t, SubgroupSettings > &subgroup_settings) |
Creates the subgroup-settings map that MulticastGroup's constructor needs (and the num_received_size for the SST) based on the subgroup information already in curr_view. More... | |
Static Private Member Functions | |
static bool | suspected_not_equal (const DerechoSST &gmsSST, const std::vector< bool > &old) |
static void | copy_suspected (const DerechoSST &gmsSST, std::vector< bool > &old) |
static bool | changes_contains (const DerechoSST &gmsSST, const node_id_t q) |
static int | min_acked (const DerechoSST &gmsSST, const std::vector< char > &failed) |
static bool | previous_leaders_suspected (const DerechoSST &gmsSST, const View &curr_view) |
static bool | copy_prior_leader_proposals (DerechoSST &gmsSST) |
Searches backwards from this node's row in the SST to lower-ranked rows, looking for proposed changes not in this node's changes list, assuming this node is the current leader and the lower-ranked rows are failed prior leaders. More... | |
static std::unique_ptr< View > | make_next_view (const std::unique_ptr< View > &curr_view, const DerechoSST &gmsSST) |
Constructs the next view from the current view and the set of committed changes in the SST. More... | |
static void | make_subgroup_maps (const SubgroupInfo &subgroup_info, const std::unique_ptr< View > &prev_view, View &curr_view) |
Initializes curr_view with subgroup information based on the membership functions in subgroup_info. More... | |
static uint32_t | compute_num_received_size (const View &view) |
Recomputes num_received_size (the length of the num_received column in the SST) for an existing provisioned View, without re-running the subgroup membership functions. More... | |
template<PORT_TYPE port_index> | |
static std::map< node_id_t, std::pair< ip_addr_t, uint16_t > > | make_member_ips_and_ports_map (const View &view) |
Constructs a map from node ID -> IP address from the parallel vectors in the given View. More... | |
static vector_int64_2d | old_shard_leaders_by_new_ids (const View &curr_view, const View &next_view) |
Constructs a vector mapping subgroup ID in the new view -> shard number -> node ID of that shard's leader in the old view. More... | |
template<typename ValueType > | |
static std::unique_ptr< std::vector< std::vector< ValueType > > > | receive_vector2d (tcp::socket &socket) |
A little convenience method that receives a 2-dimensional vector using our standard network protocol, which first sends the buffer size and then a serialized buffer. More... | |
Private Attributes | |
std::shared_timed_mutex | view_mutex |
Controls access to curr_view. More... | |
std::condition_variable_any | view_change_cv |
Notified when curr_view changes (i.e. More... | |
std::unique_ptr< View > | curr_view |
The current View, containing the state of the managed group. More... | |
std::unique_ptr< View > | next_view |
May hold a pointer to the partially-constructed next view, if we are in the process of transitioning to a new view. More... | |
LockedQueue< tcp::socket > | pending_join_sockets |
On the leader node, contains client sockets for pending joins that have not yet been handled. More... | |
std::queue< std::unique_ptr< View > > | old_views |
Contains old Views that need to be cleaned up. More... | |
std::mutex | old_views_mutex |
std::condition_variable | old_views_cv |
std::list< tcp::socket > | proposed_join_sockets |
The sockets connected to clients that will join in the next view, if any. More... | |
std::vector< bool > | last_suspected |
A cached copy of the last known value of this node's suspected[] array. More... | |
tcp::connection_listener | server_socket |
The TCP socket the leader uses to listen for joining clients. More... | |
std::atomic< bool > | thread_shutdown |
A flag to signal background threads to shut down; set to true when the group is destroyed. More... | |
std::thread | client_listener_thread |
The background thread that listens for clients connecting on our server socket. More... | |
std::thread | old_view_cleanup_thread |
const bool | disable_partitioning_safety |
A user-configurable option that disables the checks for partitioning events. More... | |
pred_handle | suspected_changed_handle |
pred_handle | start_join_handle |
pred_handle | reject_join_handle |
pred_handle | change_commit_ready_handle |
pred_handle | leader_proposed_handle |
pred_handle | leader_committed_handle |
std::vector< view_upcall_t > | view_upcalls |
Functions to be called whenever the view changes, to report the new view to some other component. More... | |
const SubgroupInfo | subgroup_info |
The subgroup membership function, which will be called whenever the view changes. More... | |
std::vector< std::type_index > | subgroup_type_order |
Indicates the order that the subgroups should be provisioned; set by Group to be the same order as its template parameters. More... | |
std::shared_ptr< tcp::tcp_connections > | tcp_sockets |
The same set of TCP sockets used by Group and RPCManager. More... | |
ReplicatedObjectReferenceMap & | subgroup_objects |
A type-erased list of references to the Replicated<T> objects in this group, indexed by their subgroup ID. More... | |
initialize_rpc_objects_t | initialize_subgroup_objects |
A function that will be called to initialize replicated objects after transitioning to a new view. More... | |
const bool | any_persistent_objects |
True if any of the Replicated<T> objects in this group have a Persistent<T> field, false if none of them do. More... | |
bool | in_total_restart |
Set to true in the constructor if this node must do a total restart before completing group setup; false otherwise. More... | |
std::unique_ptr< RestartLeaderState > | restart_leader_state_machine |
If this node is the restart leader and currently doing a total restart, this object contains state related to the restart, including curr_view. More... | |
std::unique_ptr< RestartState > | restart_state |
If this node is currently doing a total restart, this object contains state related to restarting, such as the current logged ragged trim. More... | |
bool | active_leader |
True if this node is the current leader and is fully active (i.e. More... | |
persistence_manager_callbacks_t | persistence_manager_callbacks |
The persistence request func is from persistence manager. More... | |
std::vector< std::vector< int64_t > > | prior_view_shard_leaders |
A 2-dimensional vector, indexed by (subgroup ID -> shard number), containing the ID of the node in each shard that was its leader in the prior view, or -1 if that shard had no state in the prior view. More... | |
std::atomic< bool > | bSilent = false |
On a graceful exit, nodes will be agree to leave at some point, where the view manager should stop throw exception on "failure". More... | |
Friends | |
class | rpc::RPCManager |
template<typename T > | |
class | Replicated |
template<typename T > | |
class | ExternalCaller |
class | PersistenceManager |
class | RestartLeaderState |
Definition at line 93 of file view_manager.hpp.
|
private |
Definition at line 97 of file view_manager.hpp.
|
private |
Definition at line 95 of file view_manager.hpp.
|
private |
Definition at line 172 of file view_manager.hpp.
derecho::ViewManager::ViewManager | ( | const SubgroupInfo & | subgroup_info, |
const std::vector< std::type_index > & | subgroup_type_order, | ||
const bool | any_persistent_objects, | ||
const std::shared_ptr< tcp::tcp_connections > & | group_tcp_sockets, | ||
ReplicatedObjectReferenceMap & | object_reference_map, | ||
const persistence_manager_callbacks_t & | _persistence_manager_callbacks, | ||
std::vector< view_upcall_t > | _view_upcalls = {} |
||
) |
Constructor for a new group where this node is the GMS leader.
my_ip | The IP address of the node executing this code |
subgroup_info | The set of functions defining subgroup membership for this group. |
group_tcp_sockets | The pool of TCP connections to each group member that is shared with Group. |
object_reference_map | A mutable reference to the list of ReplicatedObject references in Group, so that ViewManager can access it while Group manages the list |
_persistence_manager_callbacks | The persistence manager callbacks. |
_view_upcalls | Any extra View Upcalls to be called when a view changes. |
Definition at line 29 of file view_manager.cpp.
derecho::ViewManager::ViewManager | ( | tcp::socket & | leader_connection, |
const SubgroupInfo & | subgroup_info, | ||
const std::vector< std::type_index > & | subgroup_type_order, | ||
const bool | any_persistent_objects, | ||
const std::shared_ptr< tcp::tcp_connections > & | group_tcp_sockets, | ||
ReplicatedObjectReferenceMap & | object_reference_map, | ||
const persistence_manager_callbacks_t & | _persistence_manager_callbacks, | ||
std::vector< view_upcall_t > | _view_upcalls = {} |
||
) |
Constructor for joining an existing group, assuming the caller has already opened a socket to the group's leader.
my_id | The node ID of this node |
leader_connection | A Socket connected to the leader on its group-management service port. |
subgroup_info | The set of functions defining subgroup membership in this group. Must be the same as the SubgroupInfo used to set up the leader. |
group_tcp_sockets | The pool of TCP connections to each group member that is shared with Group. |
object_reference_map | A mutable reference to the list of ReplicatedObject references in Group, so that ViewManager can access it while Group manages the list |
_persistence_manager_callbacks | The persistence manager callbacks |
_view_upcalls | Any extra View Upcalls to be called when a view changes. |
Definition at line 88 of file view_manager.cpp.
derecho::ViewManager::~ViewManager | ( | ) |
Definition at line 117 of file view_manager.cpp.
|
private |
Updates num_acked to acknowledge a proposed change when the leader increments num_changes.
Mostly intended for non-leaders, but also runs on the leader.
Definition at line 887 of file view_manager.cpp.
void derecho::ViewManager::add_view_upcall | ( | const view_upcall_t & | upcall | ) |
Adds another function to the set of "view upcalls," which are called when the view changes to notify another component of the new view.
Definition at line 2046 of file view_manager.cpp.
|
private |
Constructor helper for the leader when it first starts; waits for enough new nodes to join to make the first view adequately provisioned.
Definition at line 420 of file view_manager.cpp.
void derecho::ViewManager::await_rejoining_nodes | ( | const node_id_t | my_id | ) |
Setup method for the leader when it is restarting from complete failure: waits for a restart quorum of nodes from the last known view to join.
Definition at line 539 of file view_manager.cpp.
void derecho::ViewManager::barrier_sync | ( | ) |
Waits until all members of the group have called this function.
Definition at line 2087 of file view_manager.cpp.
|
staticprivate |
Definition at line 1778 of file view_manager.cpp.
bool derecho::ViewManager::check_view_committed | ( | tcp::socket & | leader_connection | ) |
Setup method for non-leader nodes: checks whether the initial View received in the constructor gets committed by the leader, and if not, waits for another initial View to be sent.
leader_connection |
Definition at line 245 of file view_manager.cpp.
const uint64_t derecho::ViewManager::compute_global_stability_frontier | ( | subgroup_id_t | subgroup_num | ) |
Definition at line 2041 of file view_manager.cpp.
|
staticprivate |
Recomputes num_received_size (the length of the num_received column in the SST) for an existing provisioned View, without re-running the subgroup membership functions.
Used in total restart to set up an SST when all you have is a logged View.
view | The View to compute num_received_size for, based on its SubViews |
Definition at line 1515 of file view_manager.cpp.
|
private |
Creates the SST and MulticastGroup for the first time, using the current view's member list.
callbacks | The custom callbacks to supply to the MulticastGroup |
subgroup_settings | The subgroup settings map to supply to the MulticastGroup |
num_received_size | The size of the num_received field in the SST (derived from subgroup_settings) |
Definition at line 1338 of file view_manager.cpp.
|
staticprivate |
Searches backwards from this node's row in the SST to lower-ranked rows, looking for proposed changes not in this node's changes list, assuming this node is the current leader and the lower-ranked rows are failed prior leaders.
If a lower-ranked row has more changes, or different changes, copies that node's changes array to the local row.
gmsSST |
Definition at line 1822 of file view_manager.cpp.
|
staticprivate |
Definition at line 1772 of file view_manager.cpp.
|
private |
Constructor helper method to encapsulate spawning the background threads.
Definition at line 615 of file view_manager.cpp.
void derecho::ViewManager::debug_print_status | ( | ) | const |
Definition at line 2105 of file view_manager.cpp.
|
private |
Reads the global_min for the specified subgroup from the SST (assuming it has been computed already) and tells the current View's MulticastGroup to deliver messages up to the global_min (i.e.
the computed ragged trim).
shard_leader_rank | The rank of the leader node in this node's shard of the specified subgroup |
subgroup_num | The subgroup ID to deliver messages in |
num_received_offset | The offset into the SST's num_received field that corresponds to the specified subgroup's entries in it |
shard_members | The IDs of the members of this node's shard in the specified subgroup |
num_shard_senders | The number of nodes in that shard that are active senders in the current epoch |
Definition at line 1938 of file view_manager.cpp.
|
private |
Delivers messages that were marked deliverable by the ragged trim and proceeds to finish_view_change() when this is done.
Runs after every non-leader node has echoed the subgroup leaders' ragged trims.
Definition at line 1135 of file view_manager.cpp.
|
private |
Creates the subgroup-settings map that MulticastGroup's constructor needs (and the num_received_size for the SST) based on the subgroup information already in curr_view.
Also reinitializes curr_view's my_subgroups to indicate which subgroups this node belongs to.
curr_view | A mutable reference to the current View, which will have its my_subgroups corrected |
subgroup_settings | A mutable reference to the subgroup settings map, which will be filled in by this function |
Definition at line 1589 of file view_manager.cpp.
|
private |
Runs when the leader nodes of each subgroup have finished ragged edge cleanup.
Echoes the global_min they have posted in the SST to acknowledge it.
follower_subgroups_and_shards | A list of subgroups this node is a non-leader in, and the corresponding shard number for this node |
Definition at line 1087 of file view_manager.cpp.
void derecho::ViewManager::finish_setup | ( | ) |
Completes first-time setup of the ViewManager, including synchronizing the initial SST and delivering the first new-view upcalls.
This assumes the initial view has been committed and initialize_multicast_groups has finished.
Definition at line 313 of file view_manager.cpp.
|
private |
Finishes installing the new view, assuming it is adequately provisioned.
Sends the new view and necessary Replicated Object state to new members, sets up the new SST and MulticastGroup instances, and calls the new-view upcalls.
Definition at line 1190 of file view_manager.cpp.
|
private |
Implements the Ragged Edge Cleanup algorithm for a non-leader node in a subgroup.
This simply waits for the leader to write a value to global_min and then copies and uses it.
subgroup_num | The subgroup ID of the subgroup to do cleanup on |
shard_leader_rank | The rank of the leader node in this node's shard of the specified subgroup |
num_received_offset | The offset into the SST's num_received field that corresponds to the specified subgroup's entries in it |
num_shard_senders | The number of nodes in that shard that are active senders in the current epoch |
Definition at line 1914 of file view_manager.cpp.
SharedLockedReference< View > derecho::ViewManager::get_current_view | ( | ) |
Definition at line 2092 of file view_manager.cpp.
SharedLockedReference< const View > derecho::ViewManager::get_current_view_const | ( | ) |
This function is a dirty workaround for the fact that Group might need read-only access to curr_view during a total restart when curr_view is owned by restart_leader_state, but it's only available by const reference and SharedLockedReference<View> wants a mutable reference.
Definition at line 2097 of file view_manager.cpp.
std::map< subgroup_id_t, uint64_t > derecho::ViewManager::get_max_payload_sizes | ( | ) |
Definition at line 1641 of file view_manager.cpp.
std::vector< node_id_t > derecho::ViewManager::get_members | ( | ) |
Returns a vector listing the nodes that are currently members of the group.
Definition at line 2050 of file view_manager.cpp.
int32_t derecho::ViewManager::get_my_rank | ( | ) |
Returns the order of this node in the sequence of members of the group.
Definition at line 2055 of file view_manager.cpp.
int32_t derecho::ViewManager::get_my_shard | ( | subgroup_type_id_t | subgroup_type, |
uint32_t | subgroup_index | ||
) |
If this node is a member of the given subgroup (identified by its type and index), returns the number of the shard this node belongs to.
Otherwise, returns -1.
Definition at line 2076 of file view_manager.cpp.
std::size_t derecho::ViewManager::get_number_of_shards_in_subgroup | ( | subgroup_type_id_t | subgroup_type, |
uint32_t | subgroup_index | ||
) |
Definition at line 2070 of file view_manager.cpp.
|
inline |
Definition at line 707 of file view_manager.hpp.
std::vector< std::vector< node_id_t > > derecho::ViewManager::get_subgroup_members | ( | subgroup_type_id_t | subgroup_type, |
uint32_t | subgroup_index | ||
) |
Returns a vector of vectors listing the members of a single subgroup (identified by type and index), organized by shard number.
Definition at line 2060 of file view_manager.cpp.
|
inlineprivate |
Definition at line 233 of file view_manager.hpp.
void derecho::ViewManager::initialize_multicast_groups | ( | CallbackSet | callbacks | ) |
Sets up RDMA sessions for the multicast groups within this group.
This should only be called once the initial view is committed by the leader.
callbacks | The set of callback functions for message delivery events in this group. |
Definition at line 296 of file view_manager.cpp.
|
private |
Performs one-time global initialization of RDMC and SST, using the current view's membership.
Definition at line 595 of file view_manager.cpp.
|
private |
Runs only on the group leader and updates num_committed when all non-failed members have acked a proposed view change.
Definition at line 880 of file view_manager.cpp.
void derecho::ViewManager::leader_commit_initial_view | ( | ) |
Setup method for the leader node: sends a commit message to all non-leader nodes indicating that it is safe to use the initial View.
Definition at line 584 of file view_manager.cpp.
bool derecho::ViewManager::leader_prepare_initial_view | ( | bool & | leader_has_quorum | ) |
Setup method for the leader node in total restart mode: sends a Prepare message to all non-leader nodes indicating that state transfer has finished.
Also checks to see whether any non-leader nodes have failed in the meantime. This function simply does nothing if this node is not in total restart mode.
leader_has_quorum | A mutable reference to a bool that will be set to False if the leader realizes it no longer has a restart quorum due to failures. |
Definition at line 569 of file view_manager.cpp.
|
private |
Implements the Ragged Edge Cleanup algorithm for a subgroup/shard leader, operating on the shard that this node is a member of.
This computes the last safely-deliverable message from each sender in the shard and places it in this node's SST row in the global_min field.
subgroup_num | The subgroup ID of the subgroup to do cleanup on |
num_received_offset | The offset into the SST's num_received field that corresponds to the specified subgroup's entries in it |
shard_members | The IDs of the members of this node's shard in the specified subgroup |
num_shard_senders | The number of nodes in that shard that are active senders in the current epoch |
Definition at line 1864 of file view_manager.cpp.
|
private |
Runs only on the group leader; proposes new views to include new members.
Definition at line 804 of file view_manager.cpp.
void derecho::ViewManager::leave | ( | ) |
Causes this node to cleanly leave the group by setting itself to "failed.".
Definition at line 2019 of file view_manager.cpp.
|
private |
Constructor helper that reads logged ragged trim information from disk, called only if there is also a logged view on disk from a previous failed group.
|
private |
Reads the global_min values for the specified subgroup (and the shard that this node belongs to) from the SST, creates a ragged trim vector with these values, and persists the ragged trim to disk.
shard_leader_rank | The rank of the leader node in this node's shard of the specified subgroup |
subgroup_num | The subgroup ID to compute the ragged trim for |
num_received_offset | The offset into the SST's num_received field that corresponds to the specified subgroup's entries in it |
num_shard_senders | The number of nodes in that shard that are active senders in the current epoch |
Definition at line 1965 of file view_manager.cpp.
|
inlinestaticprivate |
Constructs a map from node ID -> IP address from the parallel vectors in the given View.
Definition at line 536 of file view_manager.hpp.
|
staticprivate |
Constructs the next view from the current view and the set of committed changes in the SST.
curr_view | The current view, which the proposed changes are relative to |
gmsSST | The SST containing the proposed/committed changes |
logger | A logger for printing out debug information |
Definition at line 1645 of file view_manager.cpp.
|
staticprivate |
Initializes curr_view with subgroup information based on the membership functions in subgroup_info.
If curr_view would be inadequate based on the subgroup allocation functions, it will be marked as inadequate.
subgroup_info | The SubgroupInfo (containing subgroup membership functions) to use to provision subgroups |
prev_view | The previous View, which may be null if the current view is the first one |
curr_view | A mutable reference to the current View, which will have its SubViews initialized |
Definition at line 1531 of file view_manager.cpp.
|
staticprivate |
Definition at line 1791 of file view_manager.cpp.
|
private |
Runs once on a node that becomes a leader due to a failure.
Searches for and re-proposes changes proposed by prior leaders, as well as suspicions noticed by this node before it became the leader.
Definition at line 847 of file view_manager.cpp.
|
private |
Called when there is a new failure suspicion.
Updates the suspected[] array and, for the leader, proposes new views to exclude failed members.
Definition at line 710 of file view_manager.cpp.
|
staticprivate |
Constructs a vector mapping subgroup ID in the new view -> shard number -> node ID of that shard's leader in the old view.
If a shard had no leader in the old view, or is a RawObject shard (which does not do state transfer), the "node ID" for that shard will be -1.
Definition at line 1732 of file view_manager.cpp.
|
staticprivate |
Definition at line 1805 of file view_manager.cpp.
|
private |
Helper for joining an existing group; receives the View and parameters from the leader.
Definition at line 131 of file view_manager.cpp.
|
private |
Assuming this node is the leader, handles a join request from a client.
Definition at line 1393 of file view_manager.cpp.
|
inlinestaticprivate |
A little convenience method that receives a 2-dimensional vector using our standard network protocol, which first sends the buffer size and then a serialized buffer.
socket | The socket to read from |
ValueType | The type of values in the vector; this assumes ValueType can be serialized by mutils |
Definition at line 566 of file view_manager.hpp.
|
private |
Constructor helper for non-leader nodes; encapsulates receiving and deserializing a View, DerechoParams, and state-transfer leaders (old shard leaders) from the leader.
Definition at line 207 of file view_manager.cpp.
|
private |
Runs on non-leaders to redirect confused new members to the current leader.
Definition at line 823 of file view_manager.cpp.
|
inline |
Registers a function that will initialize all the RPC objects at this node, given a new view and a list of the shard leaders in the previous view (needed to download object state).
ViewManger will call it after it has installed a new view.
Definition at line 764 of file view_manager.hpp.
|
private |
Constructor helper method to encapsulate creating all the predicates.
Definition at line 640 of file view_manager.cpp.
|
private |
Another setup helper for joining nodes; re-initializes the TCP connections list to reflect the current list of members in initial_view, assuming that the first view was aborted and a new one has been sent.
initial_view | The View whose membership the TCP connections should be updated to reflect |
Definition at line 379 of file view_manager.cpp.
void derecho::ViewManager::report_failure | ( | const node_id_t | who | ) |
Reports to the GMS that the given node has failed.
Definition at line 1985 of file view_manager.cpp.
void derecho::ViewManager::send | ( | subgroup_id_t | subgroup_num, |
long long unsigned int | payload_size, | ||
const std::function< void(char *buf)> & | msg_generator, | ||
bool | cooked_send = false |
||
) |
Instructs the managed DerechoGroup's to send the next message.
This returns immediately in sending through RDMC; the send is scheduled to happen some time in the future. if sending through SST, the RDMA write is issued in this call
Definition at line 2032 of file view_manager.cpp.
void derecho::ViewManager::send_logs | ( | ) |
An extra setup method only needed during total restart.
Sends Replicated Object data (most importantly, the persistent logs) to all members of a shard if this node is listed as that shard's leader. This function does nothing if this node is not in total restart mode.
Definition at line 343 of file view_manager.cpp.
|
private |
Helper method for completing view changes; determines whether this node needs to send Replicated Object state to each node that just joined, and then sends the state if necessary.
Definition at line 1465 of file view_manager.cpp.
|
private |
Sends a single subgroup's replicated object to a new member after a view change.
Definition at line 1488 of file view_manager.cpp.
|
private |
Sends a joining node the new view that has been constructed to include it.
Definition at line 1455 of file view_manager.cpp.
|
private |
Constructor helper that initializes TCP connections (for state transfer) to the members of initial_view in ascending rank order.
Assumes that no TCP connections have been set up yet.
initial_view | The View to use for membership |
Definition at line 367 of file view_manager.cpp.
void derecho::ViewManager::silence | ( | ) |
stop complaining about node failures.
Definition at line 2015 of file view_manager.cpp.
void derecho::ViewManager::start | ( | ) |
Starts predicate evaluation in the current view's SST.
Call this only when all other setup has been done for the Derecho group.
Definition at line 394 of file view_manager.cpp.
|
private |
Runs when at least one membership change has been committed by the leader, and wedges the current view in preparation for a new view.
Ends by awaiting the "meta-wedged" state and registers terminate_epoch() to trigger when meta-wedged is true.
Definition at line 930 of file view_manager.cpp.
|
staticprivate |
Definition at line 1761 of file view_manager.cpp.
|
private |
Runs when all live nodes have reported they have wedged the current view (meta-wedged), and starts ragged edge cleanup to finalize the terminated epoch.
Determines if the next view will be adequate, and only proceeds to start a view change if it will be.
Definition at line 961 of file view_manager.cpp.
|
private |
Sets up the SST and MulticastGroup for a new view, based on the settings in the current view, and copies over the SST data from the current view.
new_subgroup_settings | The subgroup settings map to supply to the MulticastGroup; this needs to change to account for the new subgroup/shard membership in the new view |
new_num_received_size | The size of the num_recieved field in the new SST |
Definition at line 1362 of file view_manager.cpp.
void derecho::ViewManager::truncate_logs | ( | ) |
An extra setup step only needed during total restart; truncates the persistent logs of this node to conform to the ragged trim decided on by the restart leader.
This function does nothing if this node is not in total restart mode.
Definition at line 282 of file view_manager.cpp.
|
private |
Helper function for total restart mode: Uses the RaggedTrim values in logged_ragged_trim to truncate any persistent logs that have a persisted version later than the last committed version in the RaggedTrim.
Definition at line 399 of file view_manager.cpp.
|
private |
Updates the TCP connections pool to reflect the joined and departed members in a new view.
Removes connections to departed members, and initializes new connections to joined members.
new_view | The new view that is about to be installed. |
Definition at line 1502 of file view_manager.cpp.
|
friend |
Definition at line 104 of file view_manager.hpp.
|
friend |
Definition at line 106 of file view_manager.hpp.
|
friend |
Definition at line 102 of file view_manager.hpp.
|
friend |
Definition at line 108 of file view_manager.hpp.
|
friend |
Definition at line 100 of file view_manager.hpp.
|
private |
True if this node is the current leader and is fully active (i.e.
has finished "waking up"), false otherwise.
Definition at line 211 of file view_manager.hpp.
|
private |
True if any of the Replicated<T> objects in this group have a Persistent<T> field, false if none of them do.
Definition at line 191 of file view_manager.hpp.
|
private |
On a graceful exit, nodes will be agree to leave at some point, where the view manager should stop throw exception on "failure".
Set 'bSilence' to keep the view manager calm on detecting intended node "failure."
Definition at line 231 of file view_manager.hpp.
|
private |
Definition at line 156 of file view_manager.hpp.
|
private |
The background thread that listens for clients connecting on our server socket.
Definition at line 142 of file view_manager.hpp.
|
private |
The current View, containing the state of the managed group.
Must be a pointer so we can re-assign it, but will never be null.
Definition at line 118 of file view_manager.hpp.
|
private |
A user-configurable option that disables the checks for partitioning events.
It defaults to false, because disabling them is unsafe, but some users might want to do this for testing purposes.
Definition at line 150 of file view_manager.hpp.
|
private |
Set to true in the constructor if this node must do a total restart before completing group setup; false otherwise.
Definition at line 195 of file view_manager.hpp.
|
private |
A function that will be called to initialize replicated objects after transitioning to a new view.
This transfers control back to Group because the objects' constructors are only known by Group.
Definition at line 186 of file view_manager.hpp.
|
private |
A cached copy of the last known value of this node's suspected[] array.
Helps the SST predicate detect when there's been a change to suspected[].
Definition at line 135 of file view_manager.hpp.
|
private |
Definition at line 158 of file view_manager.hpp.
|
private |
Definition at line 157 of file view_manager.hpp.
std::map<subgroup_id_t, uint64_t> derecho::ViewManager::max_payload_sizes |
Definition at line 776 of file view_manager.hpp.
|
private |
May hold a pointer to the partially-constructed next view, if we are in the process of transitioning to a new view.
Definition at line 121 of file view_manager.hpp.
|
private |
Definition at line 143 of file view_manager.hpp.
|
private |
Contains old Views that need to be cleaned up.
Definition at line 127 of file view_manager.hpp.
|
private |
Definition at line 129 of file view_manager.hpp.
|
private |
Definition at line 128 of file view_manager.hpp.
|
private |
On the leader node, contains client sockets for pending joins that have not yet been handled.
Definition at line 124 of file view_manager.hpp.
|
private |
The persistence request func is from persistence manager.
Definition at line 214 of file view_manager.hpp.
|
private |
A 2-dimensional vector, indexed by (subgroup ID -> shard number), containing the ID of the node in each shard that was its leader in the prior view, or -1 if that shard had no state in the prior view.
Only used for state transfer during initial startup and total restart, may be empty otherwise.
Definition at line 223 of file view_manager.hpp.
|
private |
The sockets connected to clients that will join in the next view, if any.
Definition at line 132 of file view_manager.hpp.
|
private |
Definition at line 155 of file view_manager.hpp.
|
private |
If this node is the restart leader and currently doing a total restart, this object contains state related to the restart, including curr_view.
Otherwise this will be a null pointer.
Definition at line 200 of file view_manager.hpp.
|
private |
If this node is currently doing a total restart, this object contains state related to restarting, such as the current logged ragged trim.
Otherwise this will be a null pointer.
Definition at line 205 of file view_manager.hpp.
|
private |
The TCP socket the leader uses to listen for joining clients.
Definition at line 138 of file view_manager.hpp.
|
private |
Definition at line 154 of file view_manager.hpp.
|
private |
The subgroup membership function, which will be called whenever the view changes.
Definition at line 164 of file view_manager.hpp.
|
private |
A type-erased list of references to the Replicated<T> objects in this group, indexed by their subgroup ID.
The actual objects live in the Group<ReplicatedTypes...> that owns this ViewManager, and the abstract ReplicatedObject interface only provides functions for the object state management tasks that ViewManager needs to do. This list also lives in the Group, where it is updated as replicated objects are added and destroyed, so ViewManager has only a reference to it.
Definition at line 182 of file view_manager.hpp.
|
private |
Indicates the order that the subgroups should be provisioned; set by Group to be the same order as its template parameters.
Definition at line 167 of file view_manager.hpp.
|
private |
Definition at line 153 of file view_manager.hpp.
|
private |
The same set of TCP sockets used by Group and RPCManager.
Definition at line 170 of file view_manager.hpp.
|
private |
A flag to signal background threads to shut down; set to true when the group is destroyed.
Definition at line 140 of file view_manager.hpp.
|
private |
Notified when curr_view changes (i.e.
we are finished with a pending view change).
Definition at line 114 of file view_manager.hpp.
uint64_t derecho::ViewManager::view_max_rpc_reply_payload_size = 0 |
Definition at line 779 of file view_manager.hpp.
uint32_t derecho::ViewManager::view_max_rpc_window_size = 0 |
Definition at line 780 of file view_manager.hpp.
|
private |
Controls access to curr_view.
Read-only accesses should acquire a shared_lock, while view changes acquire a unique_lock.
Definition at line 112 of file view_manager.hpp.
|
private |
Functions to be called whenever the view changes, to report the new view to some other component.
Definition at line 162 of file view_manager.hpp.