"Fossies" - the Fresh Open Source Software Archive

Member "opensaf-5.21.09/src/rde/rded/role.h" (14 Sep 2021, 2540 Bytes) of package /linux/misc/opensaf-5.21.09.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "role.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.21.06_vs_5.21.09.

    1 /*      -*- OpenSAF  -*-
    2  *
    3  * (C) Copyright 2016 The OpenSAF Foundation
    4  *
    5  * This program is distributed in the hope that it will be useful, but
    6  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    7  * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
    8  * under the GNU Lesser General Public License Version 2.1, February 1999.
    9  * The complete license can be accessed from the following location:
   10  * http://opensource.org/licenses/lgpl-license.php
   11  * See the Copying file included with the OpenSAF distribution for full
   12  * licensing terms.
   13  *
   14  * Author(s): Ericsson AB
   15  *
   16  */
   17 
   18 #ifndef RDE_RDED_ROLE_H_
   19 #define RDE_RDED_ROLE_H_
   20 
   21 #include <time.h>
   22 #include <cstdint>
   23 #include <set>
   24 #include <string>
   25 #include <atomic>
   26 #include "base/macros.h"
   27 #include "mds/mds_papi.h"
   28 #include "rde/agent/rda_papi.h"
   29 
   30 namespace base {
   31 class Process;
   32 }
   33 
   34 struct RDE_CONTROL_BLOCK;
   35 
   36 class Role {
   37  public:
   38   explicit Role(NODE_ID own_node_id);
   39   void AddPeer(NODE_ID node_id);
   40   bool IsCandidate();
   41   bool IsPeerPresent();
   42   void SetPeerState(PCS_RDA_ROLE node_role, NODE_ID node_id,
   43                     uint64_t peer_promote_pending);
   44   timespec* Poll(timespec* ts);
   45   uint32_t SetRole(PCS_RDA_ROLE new_role);
   46   PCS_RDA_ROLE role() const;
   47   static const char* to_string(PCS_RDA_ROLE role);
   48   static void MonitorCallback(const std::string& key,
   49                               const std::string& new_value, SYSF_MBX mbx);
   50   void NodePromoted();
   51   void PromoteNodeLate();
   52   void RefreshConsensusState(RDE_CONTROL_BLOCK* cb);
   53   void RemovePeer(NODE_ID node_id);
   54 
   55  private:
   56   static const uint64_t kDefaultDiscoverPeerTimeout = 2000;
   57   static const uint64_t kDefaultWaitPeerInfoTimeout = 2000;
   58   static const uint64_t kDefaultPreActiveScriptTimeout = 5000;
   59   void ExecutePreActiveScript();
   60   void ResetElectionTimer();
   61   void ResetPeerInfoWaitTimer();
   62   void StopPeerInfoWaitTimer();
   63   uint32_t UpdateMdsRegistration(PCS_RDA_ROLE new_role, PCS_RDA_ROLE old_role);
   64   void PromoteNode(const uint64_t cluster_size, const bool relaxed_mode);
   65 
   66   std::set<NODE_ID> known_nodes_;
   67   std::atomic<PCS_RDA_ROLE> role_;
   68   NODE_ID own_node_id_;
   69   base::Process* proc_;
   70   timespec election_end_time_;
   71   uint64_t discover_peer_timeout_;
   72   uint64_t pre_active_script_timeout_;
   73   static const char* const role_names_[];
   74   static const char* const pre_active_script_;
   75   bool received_peer_info_;
   76   timespec peer_info_wait_time_;
   77   uint64_t peer_info_wait_timeout_;
   78 
   79   DELETE_COPY_AND_MOVE_OPERATORS(Role);
   80 };
   81 
   82 #endif  // RDE_RDED_ROLE_H_