The top-level object for creating a Derecho group. More...
#include <group.hpp>
Public Member Functions | |
void | set_replicated_pointer (std::type_index type, uint32_t subgroup_num, void **ret) |
void | set_external_caller_pointer (std::type_index type, uint32_t subgroup_num, void **ret) |
Group (const CallbackSet &callbacks, const SubgroupInfo &subgroup_info, IDeserializationContext *deserialization_context, std::vector< view_upcall_t > _view_upcalls={}, Factory< ReplicatedTypes >... factories) | |
Constructor that starts a new managed Derecho group with this node as the leader. More... | |
Group (const SubgroupInfo &subgroup_info, Factory< ReplicatedTypes >... factories) | |
Constructor that starts a new managed Derecho group with this node as the leader. More... | |
~Group () | |
template<typename SubgroupType > | |
Replicated< SubgroupType > & | get_subgroup (uint32_t subgroup_index=0) |
Gets the "handle" for the subgroup of the specified type and index, which is a Replicated<T>, assuming this node is a member of the desired subgroup. More... | |
template<typename SubgroupType > | |
ExternalCaller< SubgroupType > & | get_nonmember_subgroup (uint32_t subgroup_index=0) |
Gets the "handle" for a subgroup of the specified type and index, assuming this node is not a member of the subgroup. More... | |
template<typename SubgroupType > | |
ShardIterator< SubgroupType > | get_shard_iterator (uint32_t subgroup_index=0) |
void | leave (bool group_shutdown=true) |
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... | |
template<typename SubgroupType > | |
std::vector< std::vector< node_id_t > > | get_subgroup_members (uint32_t subgroup_index=0) |
Gets a list of the nodes currently assigned to the subgroup of the specified type and index, organized by shard. More... | |
std::int32_t | get_my_rank () |
Returns the order of this node in the sequence of members of the group. More... | |
node_id_t | get_my_id () |
Returns the id of local node. More... | |
template<typename SubgroupType > | |
std::int32_t | get_my_shard (uint32_t subgroup_index=0) |
Returns the shard number that this node is a member of in the specified subgroup (by subgroup type and index), or -1 if this node is not a member of any shard in the specified subgroup. 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 | debug_print_status () const |
template<typename SubgroupType > | |
int32_t | get_my_shard (uint32_t subgroup_index) |
Public Member Functions inherited from derecho::_Group | |
virtual | ~_Group ()=default |
template<typename SubgroupType > | |
auto & | get_subgroup (uint32_t subgroup_num=0) |
template<typename SubgroupType > | |
auto & | get_nonmember_subgroup (uint32_t subgroup_num=0) |
template<typename SubgroupType > | |
std::size_t | get_number_of_shards (uint32_t subgroup_index=0) |
template<typename SubgroupType > | |
std::vector< std::vector< node_id_t > > | get_subgroup_members (uint32_t subgroup_index=0) |
Public Member Functions inherited from derecho::GroupProjection< ReplicatedTypes > | |
Replicated< ReplicatedTypes > & | get_subgroup (uint32_t subgroup_num=0) |
ExternalCaller< ReplicatedTypes > & | get_nonmember_subgroup (uint32_t subgroup_index=0) |
std::vector< std::vector< node_id_t > > | get_subgroup_members (uint32_t subgroup_index=0) |
std::size_t | get_number_of_shards (uint32_t subgroup_index=0) |
Protected Member Functions | |
uint32_t | get_index_of_type (const std::type_info &) override |
ViewManager & | get_view_manager () override |
Private Types | |
using | pred_handle = sst::Predicates< DerechoSST >::pred_handle |
template<typename T > | |
using | external_caller_index_map = std::map< uint32_t, ExternalCaller< T > > |
Private Member Functions | |
void | receive_objects (const std::set< std::pair< subgroup_id_t, node_id_t >> &subgroups_and_leaders) |
Updates the state of the replicated objects that correspond to subgroups identified in the provided map, by receiving serialized state from the shard leader whose ID is paired with that subgroup ID. More... | |
void | set_up_components () |
Constructor helper that wires together the component objects of Group. More... | |
template<typename... Empty> | |
std::enable_if_t< 0==sizeof...(Empty), std::set< std::pair< subgroup_id_t, node_id_t > > > | construct_objects (const View &, const vector_int64_2d &) |
Base case for the construct_objects template. More... | |
template<typename FirstType , typename... RestTypes> | |
std::set< std::pair< subgroup_id_t, node_id_t > > | construct_objects (const View &curr_view, const vector_int64_2d &old_shard_leaders) |
Constructor helper that unpacks this Group's template parameter pack. More... | |
Private Attributes | |
const node_id_t | my_id |
bool | is_starting_leader |
std::optional< tcp::socket > | leader_connection |
IDeserializationContext * | user_deserialization_context |
The shared pointer holding deserialization context is obsolete. More... | |
PersistenceManager | persistence_manager |
Persist the objects. More... | |
std::shared_ptr< tcp::tcp_connections > | tcp_sockets |
Contains a TCP connection to each member of the group, for the purpose of transferring state information to new members during a view change. More... | |
ViewManager | view_manager |
Contains all state related to managing Views, including the MulticastGroup and SST (since those change when the view changes). More... | |
rpc::RPCManager | rpc_manager |
Contains all state related to receiving and handling RPC function calls for any Replicated objects implemented by this group. More... | |
mutils::KindMap< Factory, ReplicatedTypes... > | factories |
Maps a type to the Factory for that type. More... | |
mutils::KindMap< replicated_index_map, ReplicatedTypes... > | replicated_objects |
Maps each type T to a map of (index -> Replicated<T>) for that type's subgroup(s). More... | |
mutils::KindMap< external_caller_index_map, ReplicatedTypes... > | external_callers |
Maps each type T to a map of (index -> ExternalCaller<T>) for the subgroup(s) of that type that this node is not a member of. More... | |
std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject > > | objects_by_subgroup_id |
Alternate view of the Replicated<T>s, indexed by subgroup ID. More... | |
The top-level object for creating a Derecho group.
This implements the group management service (GMS) features and contains a MulticastGroup instance that manages the actual sending and tracking of messages within the group.
ReplicatedTypes | The types of user-provided objects that will represent state and RPC functions for subgroups of this group. |
|
private |
|
private |
derecho::Group< ReplicatedTypes >::Group | ( | const CallbackSet & | callbacks, |
const SubgroupInfo & | subgroup_info, | ||
IDeserializationContext * | deserialization_context, | ||
std::vector< view_upcall_t > | _view_upcalls = {} , |
||
Factory< ReplicatedTypes >... | factories | ||
) |
Constructor that starts a new managed Derecho group with this node as the leader.
callbacks | The set of callback functions for message delivery events in this group. |
subgroup_info | The set of functions that define how membership in each subgroup and shard will be determined in this group. |
deserialization_context | The context used for deserialization purpose. The application is responsible to keep it alive during Group object lifetime. |
_view_upcalls | A list of functions to be called when the group experiences a View-Change event (optional). |
factories | A variable number of Factory functions, one for each template parameter of Group, providing a way to construct instances of each Replicated Object |
Definition at line 119 of file group_impl.hpp.
derecho::Group< ReplicatedTypes >::Group | ( | const SubgroupInfo & | subgroup_info, |
Factory< ReplicatedTypes >... | factories | ||
) |
Constructor that starts a new managed Derecho group with this node as the leader.
subgroup_info | The set of functions that define how membership in each subgroup and shard will be determined in this group. |
factories | A variable number of Factory functions, one for each template parameter of Group, providing a way to construct instances of each Replicated Object |
Definition at line 205 of file group_impl.hpp.
derecho::Group< ReplicatedTypes >::~Group | ( | ) |
Definition at line 209 of file group_impl.hpp.
void derecho::Group< ReplicatedTypes >::barrier_sync | ( | ) |
Waits until all members of the group have called this function.
Definition at line 431 of file group_impl.hpp.
|
inlineprivate |
Base case for the construct_objects template.
Note that the neat "varargs trick" (defining construct_objects(...) as the base case) doesn't work because varargs can't match const references, and will force a copy constructor on View. So std::enable_if is the only way to match an empty template pack.
|
private |
Constructor helper that unpacks this Group's template parameter pack.
Constructs Replicated<T> wrappers for each object being replicated, using the corresponding Factory<T> saved in Group::factories. If this node is not a member of the subgroup for a type T, an "empty" Replicated<T> will be constructed with no corresponding object. If this node is joining an existing group and there was a previous leader for its shard of a subgroup, an "empty" Replicated<T> will also be constructed for that subgroup, since all object state will be received from the shard leader.
curr_view | A reference to the current view as reported by View_manager |
old_shard_leaders | The array of old shard leaders for each subgroup (indexed by subgroup ID), which will contain -1 if there is no previous leader for that shard. |
Definition at line 220 of file group_impl.hpp.
void derecho::Group< ReplicatedTypes >::debug_print_status | ( | ) | const |
Definition at line 436 of file group_impl.hpp.
|
overrideprotectedvirtual |
Implements derecho::_Group.
Definition at line 93 of file group_impl.hpp.
std::vector< node_id_t > derecho::Group< ReplicatedTypes >::get_members | ( | ) |
Returns a vector listing the nodes that are currently members of the group.
Definition at line 405 of file group_impl.hpp.
node_id_t derecho::Group< ReplicatedTypes >::get_my_id | ( | ) |
Returns the id of local node.
Definition at line 426 of file group_impl.hpp.
int32_t derecho::Group< ReplicatedTypes >::get_my_rank | ( | ) |
Returns the order of this node in the sequence of members of the group.
Definition at line 421 of file group_impl.hpp.
std::int32_t derecho::Group< ReplicatedTypes >::get_my_shard | ( | uint32_t | subgroup_index = 0 | ) |
Returns the shard number that this node is a member of in the specified subgroup (by subgroup type and index), or -1 if this node is not a member of any shard in the specified subgroup.
int32_t derecho::Group< ReplicatedTypes >::get_my_shard | ( | uint32_t | subgroup_index | ) |
Definition at line 416 of file group_impl.hpp.
ExternalCaller< SubgroupType > & derecho::Group< ReplicatedTypes >::get_nonmember_subgroup | ( | uint32_t | subgroup_index = 0 | ) |
Gets the "handle" for a subgroup of the specified type and index, assuming this node is not a member of the subgroup.
The returned ExternalCaller can be used to make peer-to-peer RPC calls to a specific member of the subgroup.
subgroup_index | The index of the subgroup within the set of subgroups that replicate the same type of object. |
SubgroupType | The object type identifying the subgroup |
invalid_subgroup_exception | If this node is actually a member of the requested subgroup, or if no such subgroup exists |
Definition at line 335 of file group_impl.hpp.
ShardIterator< SubgroupType > derecho::Group< ReplicatedTypes >::get_shard_iterator | ( | uint32_t | subgroup_index = 0 | ) |
Definition at line 345 of file group_impl.hpp.
Replicated< SubgroupType > & derecho::Group< ReplicatedTypes >::get_subgroup | ( | uint32_t | subgroup_index = 0 | ) |
Gets the "handle" for the subgroup of the specified type and index, which is a Replicated<T>, assuming this node is a member of the desired subgroup.
The Replicated<T> will contain the replicated state of an object of type T (if it has any state) and be usable to send multicasts to this node's shard of the subgroup.
subgroup_index | The index of the subgroup within the set of subgroups that replicate the same type of object. Defaults to 0, so if there is only one subgroup of type T, it can be retrieved with get_subgroup<T>(); |
SubgroupType | The object type identifying the subgroup |
subgroup_provisioning_exception | If there are no subgroups because the current View is inadequately provisioned |
invalid_subgroup_exception | If this node is not a member of the requested subgroup. |
Definition at line 322 of file group_impl.hpp.
std::vector< std::vector< node_id_t > > derecho::Group< ReplicatedTypes >::get_subgroup_members | ( | uint32_t | subgroup_index = 0 | ) |
Gets a list of the nodes currently assigned to the subgroup of the specified type and index, organized by shard.
The outer vector has an entry for each shard in the subgroup, and the vector at each position contains the IDs of the nodes in that shard.
Definition at line 411 of file group_impl.hpp.
|
overrideprotectedvirtual |
Implements derecho::GroupProjection< ReplicatedTypes >.
Definition at line 103 of file group_impl.hpp.
void derecho::Group< ReplicatedTypes >::leave | ( | bool | group_shutdown = true | ) |
Causes this node to cleanly leave the group by setting itself to "failed.".
group_shutdown | True if all nodes in the group are going to leave. |
Definition at line 396 of file group_impl.hpp.
|
private |
Updates the state of the replicated objects that correspond to subgroups identified in the provided map, by receiving serialized state from the shard leader whose ID is paired with that subgroup ID.
subgroups_and_leaders | Pairs of (subgroup ID, leader's node ID) for subgroups that need to have their state initialized from the leader. |
Definition at line 364 of file group_impl.hpp.
void derecho::Group< ReplicatedTypes >::report_failure | ( | const node_id_t | who | ) |
Reports to the GMS that the given node has failed.
Definition at line 391 of file group_impl.hpp.
|
virtual |
Implements derecho::GroupProjection< ReplicatedTypes >.
Definition at line 108 of file group_impl.hpp.
|
virtual |
Implements derecho::GroupProjection< ReplicatedTypes >.
Definition at line 83 of file group_impl.hpp.
|
private |
Constructor helper that wires together the component objects of Group.
Definition at line 299 of file group_impl.hpp.
|
private |
Maps each type T to a map of (index -> ExternalCaller<T>) for the subgroup(s) of that type that this node is not a member of.
The ExternalCaller for subgroup i of type T can be used to contact any member of any shard of that subgroup, so shards are not indexed.
|
private |
|
private |
|
private |
|
private |
|
private |
Alternate view of the Replicated<T>s, indexed by subgroup ID.
The entry at index X is a reference to the Replicated<T> for this node's shard of subgroup X, which may or may not be valid. The references are the abstract base type ReplicatedObject because they are only used for state transfer, not ordered sends. Since the values in this map are references to objects that are owned by replicated_objects, it is NOT thread-safe to use it outside of view_manager's predicates - a reference may become temporarily null during a view change if the Replicated<T> it points to is deleted by the view change. Note that this is a std::map solely so that we can initialize it out-of-order; its keys are continuous integers starting at 0 and it should be a std::vector.
|
private |
|
private |
Maps each type T to a map of (index -> Replicated<T>) for that type's subgroup(s).
If this node is not a member of a subgroup for a type, the map will have no entry for that type and index. (Instead, external_callers will have an entry for that type-index pair). If this node is a member of a subgroup, the Replicated<T> will refer to the one shard that this node belongs to.
|
private |
Contains all state related to receiving and handling RPC function calls for any Replicated objects implemented by this group.
|
private |
Contains a TCP connection to each member of the group, for the purpose of transferring state information to new members during a view change.
This connection pool is shared between Group and ViewManager
|
private |
The shared pointer holding deserialization context is obsolete.
I (Weijia) removed it because it complicated things: the deserialization context is generally a big object containing the group handle; however, the group handle need to hold a shared pointer to the object, which causes a dependency loop and results in an object indirectly holding a shared pointer to its self. Another side effect is double free. So I change it back to the raw pointer. The user deserialization context for all objects serialized and deserialized.
|
private |
Contains all state related to managing Views, including the MulticastGroup and SST (since those change when the view changes).