12 using std::shared_ptr;
18 is_sender(num_members, 1),
19 member_ips_and_ports(num_members),
26 const std::vector<node_id_t>&
members,
28 const std::vector<std::tuple<
ip_addr_t, uint16_t, uint16_t, uint16_t,
33 is_sender(members.size(), 1),
39 if(is_sender.size()) {
45 for(std::size_t rank = 0; rank <
members.size(); ++rank) {
58 for(uint i = 0; i < rank; ++i) {
80 std::set<node_id_t> prev_members(previous_subview.
members.begin(),
81 previous_subview.
members.end());
82 std::set<node_id_t> curr_members(
members.begin(),
84 std::set_difference(curr_members.begin(), curr_members.end(),
85 prev_members.begin(), prev_members.end(),
86 std::back_inserter(
joined));
87 std::set_difference(prev_members.begin(), prev_members.end(),
88 curr_members.begin(), curr_members.end(),
93 const std::vector<std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t>>&
member_ips_and_ports,
94 const std::vector<char>& failed,
const int32_t num_failed,
95 const std::vector<node_id_t>&
joined,
96 const std::vector<node_id_t>&
departed,
97 const int32_t num_members,
98 const int32_t next_unassigned_rank,
99 const std::map<
subgroup_type_id_t, std::vector<subgroup_id_t>>& subgroup_ids_by_type_id,
100 const std::vector<std::vector<SubView>>& subgroup_shard_views,
101 const std::map<subgroup_id_t, uint32_t>& my_subgroups)
106 num_failed(num_failed),
109 num_members(num_members),
111 next_unassigned_rank(next_unassigned_rank),
112 subgroup_ids_by_type_id(subgroup_ids_by_type_id),
113 subgroup_shard_views(subgroup_shard_views),
114 my_subgroups(my_subgroups) {
130 const std::vector<std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t>>&
member_ips_and_ports,
131 const std::vector<char>&
failed,
const std::vector<node_id_t>&
joined,
132 const std::vector<node_id_t>&
departed,
145 next_unassigned_rank(next_unassigned_rank),
146 subgroup_type_order(subgroup_type_order) {
150 for(
auto c : failed) {
157 int View::rank_of(
const std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t>& who)
const {
176 const std::vector<int>& is_sender,
177 std::string profile)
const {
179 std::transform(profile.begin(), profile.end(), profile.begin(), ::toupper);
180 std::vector<std::tuple<ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t>> subview_member_ips_and_ports(with_members.size());
181 for(std::size_t subview_rank = 0; subview_rank < with_members.size(); ++subview_rank) {
182 int view_rank_of_member =
rank_of(with_members[subview_rank]);
183 if(view_rank_of_member == -1) {
190 return SubView(mode, with_members, is_sender, subview_member_ips_and_ports, profile);
194 uint32_t shard_index)
const {
199 for(std::size_t rank = 0; rank < shard_view.
members.size(); ++rank) {
218 for(
int n = 0; n <
my_rank; n++) {
219 for(
int row = 0; row <
my_rank; row++) {
233 if(
gmsSST->num_changes[myRank] <
gmsSST->num_changes[n]) {
239 if(
gmsSST->num_committed[myRank] <
gmsSST->num_committed[n])
249 for(
int c =
gmsSST->num_committed[myRank];
250 c < gmsSST->num_changes[myRank] && !found; c++) {
273 gmsSST->joiner_ips.get_base() -
gmsSST->changes.get_base());
275 gmsSST->num_changes.get_base() -
gmsSST->joiner_ips.get_base());
277 gmsSST->num_committed.get_base() -
gmsSST->num_changes.get_base());
279 gmsSST->num_acked.get_base() -
gmsSST->num_committed.get_base());
286 sizeof(
gmsSST->wedged[0]));
292 s <<
"View " <<
vid <<
": MyRank=" <<
my_rank <<
". ";
300 fs +=
failed[m] ? string(
" T ") : string(
" F ");
303 s <<
"Failed={" << fs <<
" }, num_failed=" <<
num_failed;
304 s <<
", Departed: { ";
306 s << departed_node <<
" ";
308 s <<
"} , Joined: { ";
310 s << joined_node <<
" ";
312 s <<
"}" << std::endl;
316 s <<
"Shard (" << subgroup <<
", " << shard <<
"): Members={";
320 s <<
"}, is_sender={";
uint32_t subgroup_id_t
Type alias for the internal Subgroup IDs generated by ViewManager.
std::vector< std::vector< SubView > > subgroup_shard_views
Maps subgroup ID -> shard number -> SubView for that subgroup/shard.
const std::vector< node_id_t > members
Node IDs of members in the current view, indexed by their SST rank.
std::vector< int > is_sender
vector selecting the senders, 0 for non-sender, non-0 for sender
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...
uint32_t subgroup_type_id_t
Type of the numeric ID used to refer to subgroup types within a Group; this is currently computed as ...
int32_t next_unassigned_rank
The rank of the lowest-ranked member that is not assigned to a subgroup in this View.
int rank_of(const node_id_t &who) const
Looks up the sub-view rank of a node ID.
SubView(int32_t num_members)
Creates an empty new SubView with num_members members.
int32_t my_rank
The rank of this node within the subgroup/shard, or -1 if this node is not a member of the subgroup/s...
int find_rank_of_leader() const
Returns the rank of this View's leader, based on failed[].
std::unique_ptr< MulticastGroup > multicast_group
RDMC manager object used for sending multicasts.
const std::string profile
Settings for the subview.
void increment(volatile int &member)
Thread-safe increment of an integer member of GMSTableRow; ensures there is a std::atomic_signal_fenc...
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.
std::vector< node_id_t > departed
List of IDs of nodes that left since the previous view, if any.
std::vector< node_id_t > departed
List of IDs of nodes that left since the previous view, if any.
std::vector< char > failed
failed[i] is true if members[i] is considered to have failed.
void set(volatile Elem &e, const Elem &value)
Thread-safe setter for DerechoSST members; ensures there is a std::atomic_signal_fence after writing ...
std::shared_ptr< DerechoSST > gmsSST
Pointer to the SST instance used by the GMS in this View.
std::vector< std::tuple< ip_addr_t, uint16_t, uint16_t, uint16_t, uint16_t > > member_ips_and_ports
IP addresses and ports of members in this subgroup/shard, with the same indices as members...
An exception that indicates that a subgroup membership function was unable to finish executing becaus...
int32_t num_failed
Number of current outstanding failures in this view.
bool i_am_new_leader()
Determines whether this node is the new leader after a view change.
std::string ip_addr_t
Type alias for IP addresses, currently stored as strings.
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.
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.
void merge_changes()
Merges changes lists from other SST rows into this node's SST row.
void wedge()
Wedges the view, which means wedging both SST and DerechoGroup.
int sender_rank_of(uint32_t rank) const
Looks up the sender rank of a given member.
std::string debug_string() const
Builds a human-readable string representing the state of the view.
const int32_t vid
Sequential view ID: 0, 1, ...
uint32_t node_id_t
Type alias for Node IDs in a Derecho group.
The subset of a View associated with a single shard, or a single subgroup if the subgroup is non-shar...
std::vector< node_id_t > members
Node IDs of members in this subgroup/shard, indexed by their order in the SST.
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[]. ...
uint32_t num_senders() const
returns the number of senders in the subview
Mode mode
Operation mode, raw mode does not do stability and delivery.
void init_joined_departed(const SubView &previous_subview)
Initialization helper method that initializes the joined and departed lists given the previous View's...
std::vector< std::type_index > subgroup_type_order
The order of subgroup types as they were declared in the Group's template parameters.
int32_t my_rank
The rank of this node (as returned by rank_of())
std::vector< node_id_t > joined
List of IDs of nodes that joined since the previous view, if any.
std::map< node_id_t, uint32_t > node_id_to_rank
Reverse index of members[]; maps node ID -> SST rank.
std::vector< node_id_t > joined
List of IDs of nodes that joined since the previous view, if any.
const int32_t num_members
Number of members in this view.