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

#include <view.hpp>

Inheritance diagram for derecho::View:
Inheritance graph
[legend]
Collaboration diagram for derecho::View:
Collaboration graph
[legend]

Public Member Functions

SubView make_subview (const std::vector< node_id_t > &with_members, const Mode mode=Mode::ORDERED, const std::vector< int > &is_sender={}, std::string profile="default") const
 Constructs a SubView containing the provided subset of this View's members. More...
 
int rank_of (const std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t > &who) const
 Looks up the SST rank of an IP address. More...
 
int rank_of (const node_id_t &who) const
 Looks up the SST rank of a node ID. More...
 
int find_rank_of_leader () const
 Returns the rank of this View's leader, based on failed[]. More...
 
bool i_am_leader () const
 
bool i_am_new_leader ()
 Determines whether this node is the new leader after a view change. More...
 
void merge_changes ()
 Merges changes lists from other SST rows into this node's SST row. More...
 
void wedge ()
 Wedges the view, which means wedging both SST and DerechoGroup. More...
 
int subview_rank_of_shard_leader (subgroup_id_t subgroup_id, uint32_t shard_index) const
 Computes the within-shard rank of a particular shard's leader, based on failed[]. More...
 
std::string debug_string () const
 Builds a human-readable string representing the state of the view. More...
 
 DEFAULT_SERIALIZATION_SUPPORT (View, vid, members, member_ips_and_ports, failed, num_failed, joined, departed, num_members, next_unassigned_rank, subgroup_ids_by_type_id, subgroup_shard_views, my_subgroups)
 
 View (const int32_t vid, const std::vector< node_id_t > &members, const std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t >> &member_ips_and_ports, const std::vector< char > &failed, const int32_t num_failed, const std::vector< node_id_t > &joined, const std::vector< node_id_t > &departed, const int32_t num_members, const int32_t next_unassigned_rank, const std::map< subgroup_type_id_t, std::vector< subgroup_id_t >> &subgroup_ids_by_type_id, const std::vector< std::vector< SubView >> &subgroup_shard_views, const std::map< subgroup_id_t, uint32_t > &my_subgroups)
 Constructor used by deserialization: constructs a View given the values of its serialized fields. More...
 
 View (const int32_t vid, const std::vector< node_id_t > &members, const std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t >> &member_ips_and_ports, const std::vector< char > &failed, const std::vector< node_id_t > &joined, const std::vector< node_id_t > &departed, const int32_t my_rank, const int32_t next_unassigned_rank, const std::vector< std::type_index > &subgroup_type_order)
 Standard constructor for making a new View. More...
 
- Public Member Functions inherited from mutils::ByteRepresentable
virtual std::size_t to_bytes (char *v) const =0
 Write this class's marshalled representation into the array found at v. More...
 
virtual void post_object (const std::function< void(char const *const, std::size_t)> &) const =0
 Pass a pointer to a buffer containing this class's marshalled representation into the function f. More...
 
virtual std::size_t bytes_size () const =0
 the size of the marshalled representation of this object. More...
 
virtual ~ByteRepresentable ()
 

Public Attributes

const int32_t vid
 Sequential view ID: 0, 1, ... More...
 
const std::vector< node_id_tmembers
 Node IDs of members in the current view, indexed by their SST rank. More...
 
const std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t > > member_ips_and_ports
 IP addresses and ports (gms, rpc, sst, rdmc in order) of members in the current view, indexed by their SST rank. More...
 
std::vector< char > failed
 failed[i] is true if members[i] is considered to have failed. More...
 
int32_t num_failed
 Number of current outstanding failures in this view. More...
 
std::vector< node_id_tjoined
 List of IDs of nodes that joined since the previous view, if any. More...
 
std::vector< node_id_tdeparted
 List of IDs of nodes that left since the previous view, if any. More...
 
const int32_t num_members
 Number of members in this view. More...
 
int32_t my_rank
 The rank of this node (as returned by rank_of()) More...
 
bool is_adequately_provisioned = true
 Set to false during MulticastGroup setup if a subgroup membership function throws a subgroup_provisioning_exception. More...
 
int32_t next_unassigned_rank
 The rank of the lowest-ranked member that is not assigned to a subgroup in this View. More...
 
std::unique_ptr< MulticastGroupmulticast_group
 RDMC manager object used for sending multicasts. More...
 
std::shared_ptr< DerechoSSTgmsSST
 Pointer to the SST instance used by the GMS in this View. More...
 
std::vector< std::type_index > subgroup_type_order
 The order of subgroup types as they were declared in the Group's template parameters. More...
 
std::map< subgroup_type_id_t, std::vector< subgroup_id_t > > subgroup_ids_by_type_id
 Maps the (type, index) pairs used by users to identify subgroups to the internal subgroup IDs generated by ViewManager during SST setup. More...
 
std::vector< std::vector< SubView > > subgroup_shard_views
 Maps subgroup ID -> shard number -> SubView for that subgroup/shard. More...
 
std::map< subgroup_id_t, uint32_t > my_subgroups
 Lists the (subgroup ID, shard num) pairs that this node is a member of. More...
 
std::map< node_id_t, uint32_t > node_id_to_rank
 Reverse index of members[]; maps node ID -> SST rank. More...
 
bool i_know_i_am_leader = false
 

Detailed Description

Definition at line 94 of file view.hpp.

Constructor & Destructor Documentation

◆ View() [1/2]

derecho::View::View ( const int32_t  vid,
const std::vector< node_id_t > &  members,
const std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t >> &  member_ips_and_ports,
const std::vector< char > &  failed,
const int32_t  num_failed,
const std::vector< node_id_t > &  joined,
const std::vector< node_id_t > &  departed,
const int32_t  num_members,
const int32_t  next_unassigned_rank,
const std::map< subgroup_type_id_t, std::vector< subgroup_id_t >> &  subgroup_ids_by_type_id,
const std::vector< std::vector< SubView >> &  subgroup_shard_views,
const std::map< subgroup_id_t, uint32_t > &  my_subgroups 
)

Constructor used by deserialization: constructs a View given the values of its serialized fields.

Warning: subgroup_type_order cannot be serialized, so it must be manually set by the receiving ViewManager after deserialization (the receiving ViewManager will always know this value).

Definition at line 92 of file view.cpp.

◆ View() [2/2]

derecho::View::View ( const int32_t  vid,
const std::vector< node_id_t > &  members,
const std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t >> &  member_ips_and_ports,
const std::vector< char > &  failed,
const std::vector< node_id_t > &  joined,
const std::vector< node_id_t > &  departed,
const int32_t  my_rank,
const int32_t  next_unassigned_rank,
const std::vector< std::type_index > &  subgroup_type_order 
)

Standard constructor for making a new View.

Definition at line 129 of file view.cpp.

Member Function Documentation

◆ debug_string()

std::string derecho::View::debug_string ( ) const

Builds a human-readable string representing the state of the view.

Used for debugging only.

Definition at line 289 of file view.cpp.

◆ DEFAULT_SERIALIZATION_SUPPORT()

derecho::View::DEFAULT_SERIALIZATION_SUPPORT ( View  ,
vid  ,
members  ,
member_ips_and_ports  ,
failed  ,
num_failed  ,
joined  ,
departed  ,
num_members  ,
next_unassigned_rank  ,
subgroup_ids_by_type_id  ,
subgroup_shard_views  ,
my_subgroups   
)

◆ find_rank_of_leader()

int derecho::View::find_rank_of_leader ( ) const

Returns the rank of this View's leader, based on failed[].

Definition at line 120 of file view.cpp.

◆ i_am_leader()

bool derecho::View::i_am_leader ( ) const
Returns
rank_of_leader() == my_rank

Definition at line 209 of file view.cpp.

◆ i_am_new_leader()

bool derecho::View::i_am_new_leader ( )

Determines whether this node is the new leader after a view change.

Definition at line 213 of file view.cpp.

◆ make_subview()

SubView derecho::View::make_subview ( const std::vector< node_id_t > &  with_members,
const Mode  mode = Mode::ORDERED,
const std::vector< int > &  is_sender = {},
std::string  profile = "default" 
) const

Constructs a SubView containing the provided subset of this View's members.

This is helpful in writing subgroup-membership functions.

Parameters
with_membersThe node IDs that will be the SubView's members vector
Returns
A SubView containing those members, the corresponding member IPs, and the subsets of joined[] and departed[] that intersect with those members
Exceptions
subgroup_provisioning_exceptionif any of the requested members are not actually in this View's members vector.

Definition at line 174 of file view.cpp.

◆ merge_changes()

void derecho::View::merge_changes ( )

Merges changes lists from other SST rows into this node's SST row.

Definition at line 229 of file view.cpp.

◆ rank_of() [1/2]

int derecho::View::rank_of ( const std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t > &  who) const

Looks up the SST rank of an IP address.

Returns -1 if that IP is not a member of this view.

Definition at line 157 of file view.cpp.

◆ rank_of() [2/2]

int derecho::View::rank_of ( const node_id_t who) const

Looks up the SST rank of a node ID.

Returns -1 if that node ID is not a member of this view.

Definition at line 166 of file view.cpp.

◆ subview_rank_of_shard_leader()

int derecho::View::subview_rank_of_shard_leader ( subgroup_id_t  subgroup_id,
uint32_t  shard_index 
) const

Computes the within-shard rank of a particular shard's leader, based on failed[].

This is not a member of SubView because it needs access to failed[], but it returns a SubView rank, not an SST rank in this View.

Definition at line 193 of file view.cpp.

◆ wedge()

void derecho::View::wedge ( )

Wedges the view, which means wedging both SST and DerechoGroup.

Definition at line 282 of file view.cpp.

Member Data Documentation

◆ departed

std::vector<node_id_t> derecho::View::departed

List of IDs of nodes that left since the previous view, if any.

Definition at line 112 of file view.hpp.

◆ failed

std::vector<char> derecho::View::failed

failed[i] is true if members[i] is considered to have failed.

Once a member is failed, it will be removed from the members list in a future view.

Definition at line 104 of file view.hpp.

◆ gmsSST

std::shared_ptr<DerechoSST> derecho::View::gmsSST

Pointer to the SST instance used by the GMS in this View.

Definition at line 128 of file view.hpp.

◆ i_know_i_am_leader

bool derecho::View::i_know_i_am_leader = false

Definition at line 149 of file view.hpp.

◆ is_adequately_provisioned

bool derecho::View::is_adequately_provisioned = true

Set to false during MulticastGroup setup if a subgroup membership function throws a subgroup_provisioning_exception.

If false, no subgroup operations will work in this View.

Definition at line 120 of file view.hpp.

◆ joined

std::vector<node_id_t> derecho::View::joined

List of IDs of nodes that joined since the previous view, if any.

Definition at line 110 of file view.hpp.

◆ member_ips_and_ports

const std::vector<std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t> > derecho::View::member_ips_and_ports

IP addresses and ports (gms, rpc, sst, rdmc in order) of members in the current view, indexed by their SST rank.

Definition at line 101 of file view.hpp.

◆ members

const std::vector<node_id_t> derecho::View::members

Node IDs of members in the current view, indexed by their SST rank.

Definition at line 99 of file view.hpp.

◆ multicast_group

std::unique_ptr<MulticastGroup> derecho::View::multicast_group

RDMC manager object used for sending multicasts.

Definition at line 126 of file view.hpp.

◆ my_rank

int32_t derecho::View::my_rank

The rank of this node (as returned by rank_of())

Definition at line 116 of file view.hpp.

◆ my_subgroups

std::map<subgroup_id_t, uint32_t> derecho::View::my_subgroups

Lists the (subgroup ID, shard num) pairs that this node is a member of.

Definition at line 145 of file view.hpp.

◆ next_unassigned_rank

int32_t derecho::View::next_unassigned_rank

The rank of the lowest-ranked member that is not assigned to a subgroup in this View.

Members with this rank or higher can be assumed to be available to assign to any subgroup and will not appear in any SubView.

Definition at line 124 of file view.hpp.

◆ node_id_to_rank

std::map<node_id_t, uint32_t> derecho::View::node_id_to_rank

Reverse index of members[]; maps node ID -> SST rank.

Definition at line 147 of file view.hpp.

◆ num_failed

int32_t derecho::View::num_failed

Number of current outstanding failures in this view.

After transitioning to a new view that excludes a failed member, this count will decrease by one.

Definition at line 108 of file view.hpp.

◆ num_members

const int32_t derecho::View::num_members

Number of members in this view.

Definition at line 114 of file view.hpp.

◆ subgroup_ids_by_type_id

std::map<subgroup_type_id_t, std::vector<subgroup_id_t> > derecho::View::subgroup_ids_by_type_id

Maps the (type, index) pairs used by users to identify subgroups to the internal subgroup IDs generated by ViewManager during SST setup.

The order of ids in the vector follows the order in which the user created those subgroups of the same type.

Definition at line 139 of file view.hpp.

◆ subgroup_shard_views

std::vector<std::vector<SubView> > derecho::View::subgroup_shard_views

Maps subgroup ID -> shard number -> SubView for that subgroup/shard.

Note that this contains an entry for every subgroup and shard, even those that the current node does not belong to.

Definition at line 143 of file view.hpp.

◆ subgroup_type_order

std::vector<std::type_index> derecho::View::subgroup_type_order

The order of subgroup types as they were declared in the Group's template parameters.

This never changes at runtime, but it is stored here so that the subgroup allocation function can read it. A subgroup type's ID is its position in this vector.

Definition at line 133 of file view.hpp.

◆ vid

const int32_t derecho::View::vid

Sequential view ID: 0, 1, ...

Definition at line 97 of file view.hpp.


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