Derecho  0.9
Distributed systems toolkit for RDMA
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
derecho::DefaultSubgroupAllocator Class Reference

Functor of type shard_view_generator_t that implements the default subgroup allocation algorithm, parameterized based on a policy for each subgroup type (i.e. More...

#include <subgroup_functions.hpp>

Collaboration diagram for derecho::DefaultSubgroupAllocator:
Collaboration graph
[legend]

Public Member Functions

 DefaultSubgroupAllocator (const std::map< std::type_index, std::variant< SubgroupAllocationPolicy, CrossProductPolicy >> &policies_by_subgroup_type)
 
 DefaultSubgroupAllocator (const DefaultSubgroupAllocator &to_copy)
 
 DefaultSubgroupAllocator (DefaultSubgroupAllocator &&)=default
 
subgroup_allocation_map_t operator() (const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, View &curr_view) const
 

Protected Member Functions

std::map< std::type_index, std::vector< std::vector< uint32_t > > > compute_standard_shard_sizes (const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, const View &curr_view) const
 Determines how many members each shard can have in the current view, based on each shard's policy (minimum and maximum number of nodes) and the size of the current view. More...
 
subgroup_shard_layout_t allocate_standard_subgroup_type (const std::type_index subgroup_type, View &curr_view, const std::map< std::type_index, std::vector< std::vector< uint32_t >>> &shard_sizes) const
 Creates and returns an initial membership allocation for a single subgroup type, based on the input map of shard sizes. More...
 
subgroup_shard_layout_t update_standard_subgroup_type (const std::type_index subgroup_type, const subgroup_type_id_t subgroup_type_id, const std::unique_ptr< View > &prev_view, View &curr_view, const std::map< std::type_index, std::vector< std::vector< uint32_t >>> &shard_sizes) const
 Creates and returns a new membership allocation for a single subgroup type, based on its previous allocation and its newly-assigned sizes. More...
 
void compute_standard_memberships (const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, View &curr_view, subgroup_allocation_map_t &subgroup_layouts) const
 Helper function that implements the subgroup allocation algorithm for all "standard" (non-cross-product) subgroups. More...
 
void compute_cross_product_memberships (const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, View &curr_view, subgroup_allocation_map_t &subgroup_layouts) const
 Helper function that implements the subgroup allocation algorithm for all cross-product subgroups. More...
 

Protected Attributes

const std::map< std::type_index, std::variant< SubgroupAllocationPolicy, CrossProductPolicy > > policies
 The entry for each type of subgroup is either a SubgroupAllocationPolicy if that type should use the standard "partitioning" allocator, or a CrossProductPolicy if that type should use the "cross-product" allocator instead. More...
 

Detailed Description

Functor of type shard_view_generator_t that implements the default subgroup allocation algorithm, parameterized based on a policy for each subgroup type (i.e.

Replicated Object type). Its operator() will throw a subgroup_provisioning_exception if there are not enough nodes in the current view to populate all of the subgroups and shards.

Definition at line 250 of file subgroup_functions.hpp.

Constructor & Destructor Documentation

◆ DefaultSubgroupAllocator() [1/3]

derecho::DefaultSubgroupAllocator::DefaultSubgroupAllocator ( const std::map< std::type_index, std::variant< SubgroupAllocationPolicy, CrossProductPolicy >> &  policies_by_subgroup_type)
inline

Definition at line 347 of file subgroup_functions.hpp.

◆ DefaultSubgroupAllocator() [2/3]

derecho::DefaultSubgroupAllocator::DefaultSubgroupAllocator ( const DefaultSubgroupAllocator to_copy)
inline

Definition at line 351 of file subgroup_functions.hpp.

◆ DefaultSubgroupAllocator() [3/3]

derecho::DefaultSubgroupAllocator::DefaultSubgroupAllocator ( DefaultSubgroupAllocator &&  )
default

Member Function Documentation

◆ allocate_standard_subgroup_type()

subgroup_shard_layout_t derecho::DefaultSubgroupAllocator::allocate_standard_subgroup_type ( const std::type_index  subgroup_type,
View curr_view,
const std::map< std::type_index, std::vector< std::vector< uint32_t >>> &  shard_sizes 
) const
protected

Creates and returns an initial membership allocation for a single subgroup type, based on the input map of shard sizes.

Parameters
subgroup_typeThe subgroup type to allocate members for
curr_viewThe current view, whose next_unassigned_rank will be updated
shard_sizesThe map of membership sizes for every subgroup and shard
Returns
A subgroup layout for this subgroup type

Definition at line 228 of file subgroup_functions.cpp.

◆ compute_cross_product_memberships()

void derecho::DefaultSubgroupAllocator::compute_cross_product_memberships ( const std::vector< std::type_index > &  subgroup_type_order,
const std::unique_ptr< View > &  prev_view,
View curr_view,
subgroup_allocation_map_t subgroup_layouts 
) const
protected

Helper function that implements the subgroup allocation algorithm for all cross-product subgroups.

It must be run second so that it can refer to the allocations created for the "standard" subgroups. It creates entries for the cross-product subgroups in the out-parameter subgroup_layouts.

Parameters
subgroup_type_orderThe same subgroup type order passed in to the operator() function
prev_viewThe same previous view passed in to the operator() function
curr_viewThe same current view passed in to the operator() function
subgroup_layoutsThe map of subgroup types to subgroup layouts that operator() will end up returning; this function will fill in the entries for some of the types.

Definition at line 314 of file subgroup_functions.cpp.

◆ compute_standard_memberships()

void derecho::DefaultSubgroupAllocator::compute_standard_memberships ( const std::vector< std::type_index > &  subgroup_type_order,
const std::unique_ptr< View > &  prev_view,
View curr_view,
subgroup_allocation_map_t subgroup_layouts 
) const
protected

Helper function that implements the subgroup allocation algorithm for all "standard" (non-cross-product) subgroups.

It creates entries for those subgroups in the out-parameter subgroup_layouts.

Parameters
subgroup_type_orderThe same subgroup type order passed in to the operator() function
prev_viewThe same previous view passed in to the operator() function
curr_viewThe same current view passed in to the operator() function
subgroup_layoutsThe map of subgroup types to subgroup layouts that operator() will end up returning; this function will fill in the entries for some of the types.

Definition at line 97 of file subgroup_functions.cpp.

◆ compute_standard_shard_sizes()

std::map< std::type_index, std::vector< std::vector< uint32_t > > > derecho::DefaultSubgroupAllocator::compute_standard_shard_sizes ( const std::vector< std::type_index > &  subgroup_type_order,
const std::unique_ptr< View > &  prev_view,
const View curr_view 
) const
protected

Determines how many members each shard can have in the current view, based on each shard's policy (minimum and maximum number of nodes) and the size of the current view.

This function first assigns the minimum number of nodes to each shard, then evenly increments every shard's size by 1 (in order of subgroup_type_order and in order of shard number within each subgroup) until either all shards are at their maximum size or all of the View's members are accounted for. It throws a subgroup_provisioning_exception if the View doesn't have enough members for even the minimum-size allocation.

Parameters
subgroup_type_orderThe same subgroup type order passed in to the operator() function
prev_viewThe previous View, if there is one. This is used to ensure that every shard can keep the non-failed nodes it had in the previous View, even if the even-incrementing rule would assign it fewer nodes in this View.
curr_viewThe current View
Returns
A map from subgroup type -> subgroup index -> shard number -> number of nodes in that shard

Definition at line 132 of file subgroup_functions.cpp.

◆ operator()()

subgroup_allocation_map_t derecho::DefaultSubgroupAllocator::operator() ( const std::vector< std::type_index > &  subgroup_type_order,
const std::unique_ptr< View > &  prev_view,
View curr_view 
) const

Definition at line 381 of file subgroup_functions.cpp.

◆ update_standard_subgroup_type()

subgroup_shard_layout_t derecho::DefaultSubgroupAllocator::update_standard_subgroup_type ( const std::type_index  subgroup_type,
const subgroup_type_id_t  subgroup_type_id,
const std::unique_ptr< View > &  prev_view,
View curr_view,
const std::map< std::type_index, std::vector< std::vector< uint32_t >>> &  shard_sizes 
) const
protected

Creates and returns a new membership allocation for a single subgroup type, based on its previous allocation and its newly-assigned sizes.

Parameters
subgroup_typeThe subgroup type to allocate members for
subgroup_type_idThe numeric "type ID" for this subgroup type (its position in the subgroup_type_order list)
prev_viewThe previous View, now known to be non-null
curr_viewThe current View, whose next_unassigned_rank will be updated
shard_sizesThe map of membership sizes for every subgroup and shard in curr_view
Returns
A subgroup layout for this subgroup type.

Definition at line 266 of file subgroup_functions.cpp.

Member Data Documentation

◆ policies

const std::map<std::type_index, std::variant<SubgroupAllocationPolicy, CrossProductPolicy> > derecho::DefaultSubgroupAllocator::policies
protected

The entry for each type of subgroup is either a SubgroupAllocationPolicy if that type should use the standard "partitioning" allocator, or a CrossProductPolicy if that type should use the "cross-product" allocator instead.

Definition at line 258 of file subgroup_functions.hpp.


The documentation for this class was generated from the following files: