Implements the low-level mechanics of tracking multicasts in a Derecho group, using RDMC to deliver messages and SST to track their arrival and stability. More...
#include <multicast_group.hpp>

Public Member Functions | |
| MulticastGroup (std::vector< node_id_t > members, node_id_t my_node_id, std::shared_ptr< DerechoSST > sst, CallbackSet callbacks, uint32_t total_num_subgroups, const std::map< subgroup_id_t, SubgroupSettings > &subgroup_settings_by_id, unsigned int sender_timeout, const subgroup_post_next_version_func_t &post_next_version_callback, const persistence_manager_callbacks_t &persistence_manager_callbacks, std::vector< char > already_failed={}) | |
| Standard constructor for setting up a MulticastGroup for the first time. More... | |
| MulticastGroup (std::vector< node_id_t > members, node_id_t my_node_id, std::shared_ptr< DerechoSST > sst, MulticastGroup &&old_group, uint32_t total_num_subgroups, const std::map< subgroup_id_t, SubgroupSettings > &subgroup_settings_by_id, const subgroup_post_next_version_func_t &post_next_version_callback, const persistence_manager_callbacks_t &persistence_manager_callbacks, std::vector< char > already_failed={}) | |
| Constructor to initialize a new MulticastGroup from an old one, preserving the same settings but providing a new list of members. More... | |
| ~MulticastGroup () | |
| void | register_rpc_callback (rpc_handler_t handler) |
| Registers a function to be called upon receipt of a multicast RPC message. More... | |
| void | deliver_messages_upto (const std::vector< int32_t > &max_indices_for_senders, subgroup_id_t subgroup_num, uint32_t num_shard_senders) |
| bool | send (subgroup_id_t subgroup_num, long long unsigned int payload_size, const std::function< void(char *buf)> &msg_generator, bool cooked_send) |
| Send now internally calls get_sendbuffer_ptr. More... | |
| bool | check_pending_sst_sends (subgroup_id_t subgroup_num) |
| const uint64_t | compute_global_stability_frontier (subgroup_id_t subgroup_num) |
| void | wedge () |
| Stops all sending and receiving in this group, in preparation for shutting it down. More... | |
| void | debug_print () |
| Debugging function; prints the current state of the SST to stdout. More... | |
| const std::map< subgroup_id_t, SubgroupSettings > & | get_subgroup_settings () |
| std::vector< uint32_t > | get_shard_sst_indices (subgroup_id_t subgroup_num) |
Private Types | |
| using | pred_handle = typename sst::Predicates< DerechoSST >::pred_handle |
Private Member Functions | |
| void | send_loop () |
| Continuously waits for a new pending send, then sends it. More... | |
| uint64_t | get_time () |
| void | check_failures_loop () |
| Checks for failures when a sender reaches its timeout. More... | |
| bool | create_rdmc_sst_groups () |
| void | initialize_sst_row () |
| void | register_predicates () |
| void | deliver_message (RDMCMessage &msg, const subgroup_id_t &subgroup_num, const persistent::version_t &version, const uint64_t &msg_timestamp) |
| Delivers a single message to the application layer, either by invoking an RPC function or by calling a global stability callback. More... | |
| void | deliver_message (SSTMessage &msg, const subgroup_id_t &subgroup_num, const persistent::version_t &version, const uint64_t &msg_timestamp) |
| Same as the other deliver_message, but for the SSTMessage type. More... | |
| bool | version_message (RDMCMessage &msg, const subgroup_id_t &subgroup_num, const persistent::version_t &version, const uint64_t &msg_timestamp) |
| Enqueues a single message for persistence with the persistence manager. More... | |
| bool | version_message (SSTMessage &msg, const subgroup_id_t &subgroup_num, const persistent::version_t &version, const uint64_t &msg_timestamp) |
| Same as the other version_message, but for the SSTMessage type. More... | |
| uint32_t | get_num_senders (const std::vector< int > &shard_senders) |
| int32_t | resolve_num_received (int32_t index, uint32_t num_received_entry) |
| void | delivery_trigger (subgroup_id_t subgroup_num, const SubgroupSettings &subgroup_settings, const uint32_t num_shard_members, DerechoSST &sst) |
| void | sst_receive_handler (subgroup_id_t subgroup_num, const SubgroupSettings &subgroup_settings, const std::map< uint32_t, uint32_t > &shard_ranks_by_sender_rank, uint32_t num_shard_senders, uint32_t sender_rank, volatile char *data, uint64_t size) |
| bool | receiver_predicate (const SubgroupSettings &subgroup_settings, const std::map< uint32_t, uint32_t > &shard_ranks_by_sender_rank, uint32_t num_shard_senders, const DerechoSST &sst) |
| void | receiver_function (subgroup_id_t subgroup_num, const SubgroupSettings &subgroup_settings, const std::map< uint32_t, uint32_t > &shard_ranks_by_sender_rank, uint32_t num_shard_senders, DerechoSST &sst, unsigned int batch_size, const std::function< void(uint32_t, volatile char *, uint32_t)> &sst_receive_handler_lambda) |
| void | get_buffer_and_send_auto_null (subgroup_id_t subgroup_num) |
| char * | get_sendbuffer_ptr (subgroup_id_t subgroup_num, long long unsigned int payload_size, bool cooked_send) |
Private Attributes | |
| std::vector< node_id_t > | members |
| vector of member id's More... | |
| std::map< node_id_t, uint32_t > | node_id_to_sst_index |
| inverse map of node_ids to sst_row More... | |
| const unsigned int | num_members |
| number of members More... | |
| const int | member_index |
| index of the local node in the members vector, which should also be its row index in the SST More... | |
| const CallbackSet | callbacks |
| Message-delivery event callbacks, supplied by the client, for "raw" sends. More... | |
| uint32_t | total_num_subgroups |
| const std::map< subgroup_id_t, SubgroupSettings > | subgroup_settings_map |
| Maps subgroup IDs (for subgroups this node is a member of) to an immutable set of configuration options for that subgroup. More... | |
| std::vector< std::list< int32_t > > | received_intervals |
| Used for synchronizing receives by RDMC and SST. More... | |
| std::map< subgroup_id_t, uint32_t > | subgroup_to_rdmc_group |
| Maps subgroup IDs for which this node is a sender to the RDMC group it should use to send. More... | |
| rpc_handler_t | rpc_callback |
| These two callbacks are internal, not exposed to clients, so they're not in CallbackSet. More... | |
| uint16_t | rdmc_group_num_offset |
| Offset to add to member ranks to form RDMC group numbers. More... | |
| bool | rdmc_sst_groups_created = false |
| false if RDMC groups haven't been created successfully More... | |
| std::map< uint32_t, std::vector< MessageBuffer > > | free_message_buffers |
| Stores message buffers not currently in use. More... | |
| std::vector< message_id_t > | future_message_indices |
| Index to be used the next time get_sendbuffer_ptr is called. More... | |
| std::vector< std::optional< RDMCMessage > > | next_sends |
| next_message is the message that will be sent when send is called the next time. More... | |
| std::map< uint32_t, bool > | pending_sst_sends |
| std::vector< std::queue< RDMCMessage > > | pending_sends |
| Messages that are ready to be sent, but must wait until the current send finishes. More... | |
| std::vector< std::optional< RDMCMessage > > | current_sends |
| Vector of messages that are currently being sent out using RDMC, or boost::none otherwise. More... | |
| std::map< std::pair< subgroup_id_t, node_id_t >, RDMCMessage > | current_receives |
| Messages that are currently being received. More... | |
| std::map< subgroup_id_t, std::function< void(char *, size_t)> > | singleton_shard_receive_handlers |
| Receiver lambdas for shards that have only one member. More... | |
| std::map< subgroup_id_t, std::map< message_id_t, RDMCMessage > > | locally_stable_rdmc_messages |
| Messages that have finished sending/receiving but aren't yet globally stable. More... | |
| std::map< subgroup_id_t, std::map< message_id_t, SSTMessage > > | locally_stable_sst_messages |
| Same map as locally_stable_rdmc_messages, but for SST messages. More... | |
| std::map< subgroup_id_t, std::set< uint64_t > > | pending_message_timestamps |
| std::map< subgroup_id_t, std::map< message_id_t, uint64_t > > | pending_persistence |
| std::map< subgroup_id_t, std::map< message_id_t, RDMCMessage > > | non_persistent_messages |
| Messages that are currently being written to persistent storage. More... | |
| std::map< subgroup_id_t, std::map< message_id_t, SSTMessage > > | non_persistent_sst_messages |
| Messages that are currently being written to persistent storage. More... | |
| std::vector< message_id_t > | next_message_to_deliver |
| std::recursive_mutex | msg_state_mtx |
| std::condition_variable_any | sender_cv |
| unsigned int | sender_timeout |
| The time, in milliseconds, that a sender can wait to send a message before it is considered failed. More... | |
| std::atomic< bool > | thread_shutdown {false} |
| Indicates that the group is being destroyed. More... | |
| std::thread | sender_thread |
| The background thread that sends messages with RDMC. More... | |
| std::thread | timeout_thread |
| std::shared_ptr< DerechoSST > | sst |
| The SST, shared between this group and its GMS. More... | |
| std::vector< std::unique_ptr< sst::multicast_group< DerechoSST > > > | sst_multicast_group_ptrs |
| The SSTs for multicasts. More... | |
| std::list< pred_handle > | receiver_pred_handles |
| std::list< pred_handle > | stability_pred_handles |
| std::list< pred_handle > | delivery_pred_handles |
| std::list< pred_handle > | persistence_pred_handles |
| std::list< pred_handle > | sender_pred_handles |
| std::vector< bool > | last_transfer_medium |
| subgroup_post_next_version_func_t | post_next_version_callback |
| post the next version to a subgroup just before deliver a message so that the user code know the current version being handled. More... | |
| persistence_manager_callbacks_t | persistence_manager_callbacks |
| persistence manager callbacks More... | |
Friends | |
| class | ViewManager |
Implements the low-level mechanics of tracking multicasts in a Derecho group, using RDMC to deliver messages and SST to track their arrival and stability.
This class should only be used as part of a Group, since it does not know how to handle failures.
Definition at line 247 of file multicast_group.hpp.
|
private |
Definition at line 332 of file multicast_group.hpp.
| derecho::MulticastGroup::MulticastGroup | ( | std::vector< node_id_t > | members, |
| node_id_t | my_node_id, | ||
| std::shared_ptr< DerechoSST > | sst, | ||
| CallbackSet | callbacks, | ||
| uint32_t | total_num_subgroups, | ||
| const std::map< subgroup_id_t, SubgroupSettings > & | subgroup_settings_by_id, | ||
| unsigned int | sender_timeout, | ||
| const subgroup_post_next_version_func_t & | post_next_version_callback, | ||
| const persistence_manager_callbacks_t & | persistence_manager_callbacks, | ||
| std::vector< char > | already_failed = {} |
||
| ) |
Standard constructor for setting up a MulticastGroup for the first time.
| _members | A list of node IDs of members in this group |
| my_node_id | The rank (ID) of this node in the group |
| _sst | The SST this group will use; created by the GMS (membership service) for this group. |
| _callbacks | A set of functions to call when messages have reached various levels of stability |
| total_num_subgroups | The total number of subgroups in this Derecho Group |
| subgroup_settings_by_id | A list of SubgroupSettings, one for each subgroup this node belongs to, indexed by subgroup ID |
| post_next_version_callback | The callback for posting the upcoming version to be delivered in a subgroup. |
| persistence_manager_callbacks | The callbacks to PersistenceManager that will be used to persist received messages |
| already_failed | (Optional) A Boolean vector indicating which elements of _members are nodes that have already failed in this view |
Definition at line 28 of file multicast_group.cpp.
| derecho::MulticastGroup::MulticastGroup | ( | std::vector< node_id_t > | members, |
| node_id_t | my_node_id, | ||
| std::shared_ptr< DerechoSST > | sst, | ||
| MulticastGroup && | old_group, | ||
| uint32_t | total_num_subgroups, | ||
| const std::map< subgroup_id_t, SubgroupSettings > & | subgroup_settings_by_id, | ||
| const subgroup_post_next_version_func_t & | post_next_version_callback, | ||
| const persistence_manager_callbacks_t & | persistence_manager_callbacks, | ||
| std::vector< char > | already_failed = {} |
||
| ) |
Constructor to initialize a new MulticastGroup from an old one, preserving the same settings but providing a new list of members.
Definition at line 89 of file multicast_group.cpp.
| derecho::MulticastGroup::~MulticastGroup | ( | ) |
Definition at line 950 of file multicast_group.cpp.
|
private |
Checks for failures when a sender reaches its timeout.
This function implements the timeout thread.
Definition at line 1086 of file multicast_group.cpp.
| bool derecho::MulticastGroup::check_pending_sst_sends | ( | subgroup_id_t | subgroup_num | ) |
Definition at line 1314 of file multicast_group.cpp.
| const uint64_t derecho::MulticastGroup::compute_global_stability_frontier | ( | subgroup_id_t | subgroup_num | ) |
Definition at line 1076 of file multicast_group.cpp.
|
private |
Definition at line 236 of file multicast_group.cpp.
| void derecho::MulticastGroup::debug_print | ( | ) |
Debugging function; prints the current state of the SST to stdout.
Definition at line 1329 of file multicast_group.cpp.
|
private |
Delivers a single message to the application layer, either by invoking an RPC function or by calling a global stability callback.
| msg | A reference to the message |
| subgroup_num | The ID of the subgroup this message is in |
| version | The version assigned to the message |
| msg_ts | The timestamp of the message |
Definition at line 450 of file multicast_group.cpp.
|
private |
Same as the other deliver_message, but for the SSTMessage type.
| msg | A reference to the message to deliver |
| subgroup_num | The ID of the subgroup this message is in |
| version | The version assigned to the message |
| msg_ts | The timestamp of this message |
Definition at line 472 of file multicast_group.cpp.
| void derecho::MulticastGroup::deliver_messages_upto | ( | const std::vector< int32_t > & | max_indices_for_senders, |
| subgroup_id_t | subgroup_num, | ||
| uint32_t | num_shard_senders | ||
| ) |
Definition at line 538 of file multicast_group.cpp.
|
private |
Definition at line 752 of file multicast_group.cpp.
|
private |
Definition at line 1122 of file multicast_group.cpp.
|
inlineprivate |
Definition at line 410 of file multicast_group.hpp.
|
private |
Definition at line 1172 of file multicast_group.cpp.
| std::vector< uint32_t > derecho::MulticastGroup::get_shard_sst_indices | ( | subgroup_id_t | subgroup_num | ) |
Definition at line 1319 of file multicast_group.cpp.
|
inline |
Definition at line 516 of file multicast_group.hpp.
|
private |
Definition at line 1070 of file multicast_group.cpp.
|
private |
Definition at line 433 of file multicast_group.cpp.
|
private |
Definition at line 709 of file multicast_group.cpp.
|
private |
Definition at line 624 of file multicast_group.cpp.
|
private |
Definition at line 819 of file multicast_group.cpp.
|
inline |
Registers a function to be called upon receipt of a multicast RPC message.
| handler | A function that will handle RPC messages. |
Definition at line 496 of file multicast_group.hpp.
|
private |
Definition at line 590 of file multicast_group.cpp.
| bool derecho::MulticastGroup::send | ( | subgroup_id_t | subgroup_num, |
| long long unsigned int | payload_size, | ||
| const std::function< void(char *buf)> & | msg_generator, | ||
| bool | cooked_send | ||
| ) |
Send now internally calls get_sendbuffer_ptr.
The user function that generates the message is supplied to send
Definition at line 1277 of file multicast_group.cpp.
|
private |
Continuously waits for a new pending send, then sends it.
This function implements the sender thread.
Definition at line 991 of file multicast_group.cpp.
|
private |
Definition at line 639 of file multicast_group.cpp.
|
private |
Enqueues a single message for persistence with the persistence manager.
Note that this does not actually wait for the message to be persisted; you must still post a persistence request with the persistence manager.
| msg | The message that should cause a new version to be registered with PersistenceManager |
| subgroup_num | The ID of the subgroup this message is in |
| version | The version assigned to the message |
| msg_ts | The timestamp of this message |
Definition at line 494 of file multicast_group.cpp.
|
private |
Same as the other version_message, but for the SSTMessage type.
| msg | The message that should cause a new version to be registered with PersistenceManager |
| subgroup_num | The ID of the subgroup this message is in |
| version | The version assigned to the message |
| msg_ts | The timestamp of this message |
Definition at line 516 of file multicast_group.cpp.
| void derecho::MulticastGroup::wedge | ( | ) |
Stops all sending and receiving in this group, in preparation for shutting it down.
Definition at line 957 of file multicast_group.cpp.
|
friend |
Definition at line 248 of file multicast_group.hpp.
|
private |
Message-delivery event callbacks, supplied by the client, for "raw" sends.
Definition at line 260 of file multicast_group.hpp.
|
private |
Messages that are currently being received.
Definition at line 296 of file multicast_group.hpp.
|
private |
Vector of messages that are currently being sent out using RDMC, or boost::none otherwise.
one per subgroup
Definition at line 293 of file multicast_group.hpp.
|
private |
Definition at line 335 of file multicast_group.hpp.
|
private |
Stores message buffers not currently in use.
Protected by msg_state_mtx
Definition at line 279 of file multicast_group.hpp.
|
private |
Index to be used the next time get_sendbuffer_ptr is called.
When next_message is not none, then next_message.index = future_message_index-1
Definition at line 283 of file multicast_group.hpp.
|
private |
Definition at line 339 of file multicast_group.hpp.
|
private |
Messages that have finished sending/receiving but aren't yet globally stable.
Organized by [subgroup number] -> [sequence number] -> [message]
Definition at line 302 of file multicast_group.hpp.
|
private |
Same map as locally_stable_rdmc_messages, but for SST messages.
Definition at line 304 of file multicast_group.hpp.
|
private |
index of the local node in the members vector, which should also be its row index in the SST
Definition at line 258 of file multicast_group.hpp.
|
private |
vector of member id's
Definition at line 252 of file multicast_group.hpp.
|
private |
Definition at line 313 of file multicast_group.hpp.
|
private |
Definition at line 312 of file multicast_group.hpp.
|
private |
next_message is the message that will be sent when send is called the next time.
It is std::nullopt when there is no message to send.
Definition at line 287 of file multicast_group.hpp.
|
private |
inverse map of node_ids to sst_row
Definition at line 254 of file multicast_group.hpp.
|
private |
Messages that are currently being written to persistent storage.
Definition at line 308 of file multicast_group.hpp.
|
private |
Messages that are currently being written to persistent storage.
Definition at line 310 of file multicast_group.hpp.
|
private |
number of members
Definition at line 256 of file multicast_group.hpp.
|
private |
Definition at line 305 of file multicast_group.hpp.
|
private |
Definition at line 306 of file multicast_group.hpp.
|
private |
Messages that are ready to be sent, but must wait until the current send finishes.
Definition at line 290 of file multicast_group.hpp.
|
private |
Definition at line 288 of file multicast_group.hpp.
|
private |
persistence manager callbacks
Definition at line 346 of file multicast_group.hpp.
|
private |
Definition at line 336 of file multicast_group.hpp.
|
private |
post the next version to a subgroup just before deliver a message so that the user code know the current version being handled.
Definition at line 343 of file multicast_group.hpp.
|
private |
Offset to add to member ranks to form RDMC group numbers.
Definition at line 274 of file multicast_group.hpp.
|
private |
false if RDMC groups haven't been created successfully
Definition at line 276 of file multicast_group.hpp.
|
private |
Used for synchronizing receives by RDMC and SST.
Definition at line 266 of file multicast_group.hpp.
|
private |
Definition at line 333 of file multicast_group.hpp.
|
private |
These two callbacks are internal, not exposed to clients, so they're not in CallbackSet.
Definition at line 271 of file multicast_group.hpp.
|
private |
Definition at line 314 of file multicast_group.hpp.
|
private |
Definition at line 337 of file multicast_group.hpp.
|
private |
The background thread that sends messages with RDMC.
Definition at line 322 of file multicast_group.hpp.
|
private |
The time, in milliseconds, that a sender can wait to send a message before it is considered failed.
Definition at line 317 of file multicast_group.hpp.
|
private |
Receiver lambdas for shards that have only one member.
Definition at line 298 of file multicast_group.hpp.
|
private |
The SST, shared between this group and its GMS.
Definition at line 327 of file multicast_group.hpp.
|
private |
The SSTs for multicasts.
Definition at line 330 of file multicast_group.hpp.
|
private |
Definition at line 334 of file multicast_group.hpp.
|
private |
Maps subgroup IDs (for subgroups this node is a member of) to an immutable set of configuration options for that subgroup.
Definition at line 264 of file multicast_group.hpp.
|
private |
Maps subgroup IDs for which this node is a sender to the RDMC group it should use to send.
Constructed incrementally in create_rdmc_sst_groups(), so it can't be const.
Definition at line 269 of file multicast_group.hpp.
|
private |
Indicates that the group is being destroyed.
Definition at line 320 of file multicast_group.hpp.
|
private |
Definition at line 324 of file multicast_group.hpp.
|
private |
Definition at line 261 of file multicast_group.hpp.
1.8.13