MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
trp_node.hpp
1 /*
2  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef trp_node_hpp
19 #define trp_node_hpp
20 
21 #include <ndb_global.h>
22 #include <kernel/NodeInfo.hpp>
23 #include <kernel/NodeState.hpp>
24 
25 class NdbOut;
26 NdbOut& operator<<(NdbOut&, const struct trp_node&);
27 
28 struct trp_node
29 {
30  trp_node();
31 
32  NodeInfo m_info;
33  NodeState m_state;
34 
35  Uint32 minDbVersion;
36  bool defined;
37  bool compatible; // Version is compatible
38  bool nfCompleteRep; // NF Complete Rep has arrived
39  bool m_alive; // Node is alive
40  bool m_node_fail_rep;// NodeFailRep has arrived
41 private:
42  bool m_connected; // Transporter connected
43  bool m_api_reg_conf;// API_REGCONF has arrived
44 public:
45 
46  void set_connected(bool connected) {
47  assert(defined);
48  m_connected = connected;
49  }
50  bool is_connected(void) const {
51  const bool connected = m_connected;
52  // Must be defined if connected
53  assert(!connected ||
54  (connected && defined));
55  return connected;
56  }
57 
58  void set_confirmed(bool confirmed) {
59  if (confirmed)
60  assert(is_connected());
61  m_api_reg_conf = confirmed;
62  }
63 
64  bool is_confirmed(void) const {
65  const bool confirmed = m_api_reg_conf;
66  assert(!confirmed ||
67  (confirmed && is_connected()));
68  return confirmed;
69  }
70 
71  bool operator==(const trp_node& other) const;
72 
73 private:
74 
75  friend NdbOut& operator<<(NdbOut&, const trp_node&);
76 };
77 
78 #endif