derecho/view_manager.cpp
/* ------------- 2. Predicate-Triggers That Implement View Management Logic ---------- */
2. Predicate-Triggers That Implement View Management Logic
2 . Predicate - Triggers That Implement View Management Logic
void ViewManager::new_suspicion(DerechoSST& gmsSST) {
    logger->debug("Suspected[] changed");
    View& Vc = *curr_view;
    int myRank = curr_view->my_rank;
    for(int r = 0; r < Vc.num_members; r++) {
        for(int who = 0; who < Vc.num_members; who++) {
            gmssst::set(gmsSST.suspected[myRank][who], gmsSST.suspected[myRank][who] || gmsSST.suspected[r][who]);
        }
    }
    for(int q = 0; q < Vc.num_members; q++) {
        if(gmsSST.suspected[myRank][q] && !Vc.failed[q]) {
            logger->debug("New suspicion: node {}", Vc.members[q]);
            last_suspected[q] = gmsSST.suspected[myRank][q];
            if(Vc.num_failed >= (Vc.num_members + 1) / 2) {
                throw derecho_exception("Majority of a Derecho group simultaneously failed ... shutting down");
            }
            logger->debug("GMS telling SST to freeze row {}", q);
            gmsSST.freeze(q);  
            Vc.multicast_group->wedge();
            gmssst::set(gmsSST.wedged[myRank], true);  
            Vc.failed[q] = true;
            Vc.num_failed++;
            if(Vc.num_failed >= (Vc.num_members + 1) / 2) {
                throw derecho_exception("Potential partitioning event: this node is no longer in the majority and must shut down!");
            }
            gmsSST.put(gmsSST.suspected.get_base() - gmsSST.getBaseAddress(), gmsSST.changes.get_base() - gmsSST.suspected.get_base());
            gmsSST.put(gmsSST.wedged.get_base() - gmsSST.getBaseAddress(), sizeof(gmsSST.wedged[0]));
            if(Vc.i_am_leader() && !changes_contains(gmsSST, Vc.members[q]))  
            {
                const int next_change_index = gmsSST.num_changes[myRank] - gmsSST.num_installed[myRank];
                if(next_change_index == (int)gmsSST.changes.size()) {
                    throw derecho_exception("Ran out of room in the pending changes list");
                }
                gmssst::set(gmsSST.changes[myRank][next_change_index], Vc.members[q]);  
                gmssst::increment(gmsSST.num_changes[myRank]);
                logger->debug("Leader proposed a change to remove failed node {}", Vc.members[q]);
                gmsSST.put((char*)std::addressof(gmsSST.changes[0][next_change_index]) - gmsSST.getBaseAddress(),
                           sizeof(gmsSST.changes[0][next_change_index]));
                gmsSST.put(gmsSST.num_changes.get_base() - gmsSST.getBaseAddress(), sizeof(gmsSST.num_changes[0]));
            }
        }
    }
}
void ViewManager :: new_suspicion ( DerechoSST & gmsSST ) { logger -> debug ( " " ) ; View & Vc = * curr_view ; int myRank = curr_view -> my_rank ; for ( int r = 0 ; r < Vc . num_members ; r ++ ) { for ( int who = 0 ; who < Vc . num_members ; who ++ ) { gmssst :: set ( gmsSST . suspected [ myRank ] [ who ] , gmsSST . suspected [ myRank ] [ who ] || gmsSST . suspected [ r ] [ who ] ) ; } } for ( int q = 0 ; q < Vc . num_members ; q ++ ) { if ( gmsSST . suspected [ myRank ] [ q ] && ! Vc . failed [ q ] ) { logger -> debug ( " " , Vc . members [ q ] ) ; last_suspected [ q ] = gmsSST . suspected [ myRank ] [ q ] ; if ( Vc . num_failed >= ( Vc . num_members + 1 ) / 2 ) { throw derecho_exception ( " " ) ; } logger -> debug ( " " , q ) ; gmsSST . freeze ( q ) ; Vc . multicast_group -> wedge ( ) ; gmssst :: set ( gmsSST . wedged [ myRank ] , true ) ; Vc . failed [ q ] = true ; Vc . num_failed ++ ; if ( Vc . num_failed >= ( Vc . num_members + 1 ) / 2 ) { throw derecho_exception ( " " ) ; } gmsSST . put ( gmsSST . suspected . get_base ( ) - gmsSST . getBaseAddress ( ) , gmsSST . changes . get_base ( ) - gmsSST . suspected . get_base ( ) ) ; gmsSST . put ( gmsSST . wedged . get_base ( ) - gmsSST . getBaseAddress ( ) , sizeof ( gmsSST . wedged [ 0 ] ) ) ; if ( Vc . i_am_leader ( ) && ! changes_contains ( gmsSST , Vc . members [ q ] ) ) { const int next_change_index = gmsSST . num_changes [ myRank ] - gmsSST . num_installed [ myRank ] ; if ( next_change_index == ( int ) gmsSST . changes . size ( ) ) { throw derecho_exception ( " " ) ; } gmssst :: set ( gmsSST . changes [ myRank ] [ next_change_index ] , Vc . members [ q ] ) ; gmssst :: increment ( gmsSST . num_changes [ myRank ] ) ; logger -> debug ( " " , Vc . members [ q ] ) ; gmsSST . put ( ( char * ) std :: addressof ( gmsSST . changes [ 0 ] [ next_change_index ] ) - gmsSST . getBaseAddress ( ) , sizeof ( gmsSST . changes [ 0 ] [ next_change_index ] ) ) ; gmsSST . put ( gmsSST . num_changes . get_base ( ) - gmsSST . getBaseAddress ( ) , sizeof ( gmsSST . num_changes [ 0 ] ) ) ; } } } }
2
2 .
// Aggregate suspicions into gmsSST[myRank].Suspected; //If this is a new suspicion //This is safer than copy_suspected, since suspected[] might change during this loop // Cease to accept new updates from q // RDMC has halted new sends and receives in theView // push change to gmsSST.suspected[myRank] // push change to gmsSST.wedged[myRank] // Leader initiated // Reports the failure (note that q NotIn members)